Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
b071d4f3
Kaydet (Commit)
b071d4f3
authored
12 years ago
tarafından
Giampaolo Rodola'
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
profile/cProfile: add tests for run() and runctx() functions
üst
f29fb5ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
test_cprofile.py
Lib/test/test_cprofile.py
+2
-0
test_profile.py
Lib/test/test_profile.py
+28
-1
No files found.
Lib/test/test_cprofile.py
Dosyayı görüntüle @
b071d4f3
...
...
@@ -6,9 +6,11 @@ from test.support import run_unittest, TESTFN, unlink
# rip off all interesting stuff from test_profile
import
cProfile
from
test.test_profile
import
ProfileTest
,
regenerate_expected_output
from
test.profilee
import
testfunc
class
CProfileTest
(
ProfileTest
):
profilerclass
=
cProfile
.
Profile
profilermodule
=
cProfile
expected_max_output
=
"{built-in method max}"
def
get_expected_output
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_profile.py
Dosyayı görüntüle @
b071d4f3
...
...
@@ -3,9 +3,11 @@
import
sys
import
pstats
import
unittest
import
os
from
difflib
import
unified_diff
from
io
import
StringIO
from
test.support
import
run_unittest
from
test.support
import
TESTFN
,
run_unittest
,
unlink
from
contextlib
import
contextmanager
import
profile
from
test.profilee
import
testfunc
,
timer
...
...
@@ -14,9 +16,13 @@ from test.profilee import testfunc, timer
class
ProfileTest
(
unittest
.
TestCase
):
profilerclass
=
profile
.
Profile
profilermodule
=
profile
methodnames
=
[
'print_stats'
,
'print_callers'
,
'print_callees'
]
expected_max_output
=
':0(max)'
def
tearDown
(
self
):
unlink
(
TESTFN
)
def
get_expected_output
(
self
):
return
_ProfileOutput
...
...
@@ -74,6 +80,19 @@ class ProfileTest(unittest.TestCase):
self
.
assertIn
(
self
.
expected_max_output
,
res
,
"Profiling {0!r} didn't report max:
\n
{1}"
.
format
(
stmt
,
res
))
def
test_run
(
self
):
with
silent
():
self
.
profilermodule
.
run
(
"testfunc()"
)
self
.
profilermodule
.
run
(
"testfunc()"
,
filename
=
TESTFN
)
self
.
assertTrue
(
os
.
path
.
exists
(
TESTFN
))
def
test_runctx
(
self
):
with
silent
():
self
.
profilermodule
.
runctx
(
"testfunc()"
,
globals
(),
locals
())
self
.
profilermodule
.
runctx
(
"testfunc()"
,
globals
(),
locals
(),
filename
=
TESTFN
)
self
.
assertTrue
(
os
.
path
.
exists
(
TESTFN
))
def
regenerate_expected_output
(
filename
,
cls
):
filename
=
filename
.
rstrip
(
'co'
)
...
...
@@ -95,6 +114,14 @@ def regenerate_expected_output(filename, cls):
method
,
results
[
i
+
1
]))
f
.
write
(
'
\n
if __name__ == "__main__":
\n
main()
\n
'
)
@contextmanager
def
silent
():
stdout
=
sys
.
stdout
try
:
sys
.
stdout
=
StringIO
()
yield
finally
:
sys
.
stdout
=
stdout
def
test_main
():
run_unittest
(
ProfileTest
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment