Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9c460cc1
Commit
9c460cc1
authored
Oct 06, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a trival fix to let test_profile pass if it runs after test_cprofile
parent
79615d1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
Lib/test/test_cprofile.py
Lib/test/test_cprofile.py
+7
-3
Lib/test/test_profile.py
Lib/test/test_profile.py
+13
-8
No files found.
Lib/test/test_cprofile.py
View file @
9c460cc1
...
...
@@ -10,6 +10,9 @@ from test.test_profile import ProfileTest, regenerate_expected_output
class
CProfileTest
(
ProfileTest
):
profilerclass
=
cProfile
.
Profile
def
get_expected_output
(
self
):
return
_ProfileOutput
def
test_main
():
run_unittest
(
CProfileTest
)
...
...
@@ -23,7 +26,8 @@ def main():
# Don't remove this comment. Everything below it is auto-generated.
#--cut--------------------------------------------------------------------------
CProfileTest
.
expected_output
[
'print_stats'
]
=
"""
\
_ProfileOutput
=
{}
_ProfileOutput
[
'print_stats'
]
=
"""
\
28 0.028 0.001 0.028 0.001 profilee.py:110(__getattr__)
1 0.270 0.270 1.000 1.000 profilee.py:25(testfunc)
23/3 0.150 0.007 0.170 0.057 profilee.py:35(factorial)
...
...
@@ -33,7 +37,7 @@ CProfileTest.expected_output['print_stats'] = """\
2 0.000 0.000 0.140 0.070 profilee.py:84(helper2_indirect)
8 0.312 0.039 0.400 0.050 profilee.py:88(helper2)
8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper)"""
CProfileTest
.
expected_o
utput
[
'print_callers'
]
=
"""
\
_ProfileO
utput
[
'print_callers'
]
=
"""
\
profilee.py:110(__getattr__) <- 16 0.016 0.016 profilee.py:98(subhelper)
profilee.py:25(testfunc) <- 1 0.270 1.000 <string>:1(<module>)
profilee.py:35(factorial) <- 1 0.014 0.130 profilee.py:25(testfunc)
...
...
@@ -50,7 +54,7 @@ profilee.py:98(subhelper) <- 8 0.064 0.080
{built-in method hasattr} <- 4 0.000 0.004 profilee.py:73(helper1)
8 0.000 0.008 profilee.py:88(helper2)
{method 'append' of 'list' objects} <- 4 0.000 0.000 profilee.py:73(helper1)"""
CProfileTest
.
expected_o
utput
[
'print_callees'
]
=
"""
\
_ProfileO
utput
[
'print_callees'
]
=
"""
\
<string>:1(<module>) -> 1 0.270 1.000 profilee.py:25(testfunc)
profilee.py:110(__getattr__) ->
profilee.py:25(testfunc) -> 1 0.014 0.130 profilee.py:35(factorial)
...
...
Lib/test/test_profile.py
View file @
9c460cc1
...
...
@@ -16,7 +16,9 @@ class ProfileTest(unittest.TestCase):
profilerclass
=
profile
.
Profile
methodnames
=
[
'print_stats'
,
'print_callers'
,
'print_callees'
]
expected_output
=
{}
def
get_expected_output
(
self
):
return
_ProfileOutput
@
classmethod
def
do_profiling
(
cls
):
...
...
@@ -41,14 +43,15 @@ class ProfileTest(unittest.TestCase):
def
test_cprofile
(
self
):
results
=
self
.
do_profiling
()
expected
=
self
.
get_expected_output
()
self
.
assertEqual
(
results
[
0
],
1000
)
for
i
,
method
in
enumerate
(
self
.
methodnames
):
if
results
[
i
+
1
]
!=
self
.
expected_output
[
method
]:
if
results
[
i
+
1
]
!=
expected
[
method
]:
print
(
"Stats.%s output for %s doesn't fit expectation!"
%
(
method
,
self
.
profilerclass
.
__name__
))
print
(
'
\
n
'
.
join
(
unified_diff
(
results
[
i
+
1
].
split
(
'
\
n
'
),
self
.
expected_output
[
method
].
split
(
'
\
n
'
))))
expected
[
method
].
split
(
'
\
n
'
))))
def
regenerate_expected_output
(
filename
,
cls
):
...
...
@@ -65,9 +68,10 @@ def regenerate_expected_output(filename, cls):
with
open
(
filename
,
'w'
)
as
f
:
f
.
writelines
(
newfile
)
f
.
write
(
"_ProfileOutput = {}
\
n
"
)
for
i
,
method
in
enumerate
(
cls
.
methodnames
):
f
.
write
(
'
%s.expected_o
utput[%r] = """
\
\
\
n
%s"""
\
n
'
%
(
cls
.
__name__
,
method
,
results
[
i
+
1
]))
f
.
write
(
'
_ProfileO
utput[%r] = """
\
\
\
n
%s"""
\
n
'
%
(
method
,
results
[
i
+
1
]))
f
.
write
(
'
\
n
if __name__ == "__main__":
\
n
main()
\
n
'
)
...
...
@@ -83,7 +87,8 @@ def main():
# Don't remove this comment. Everything below it is auto-generated.
#--cut--------------------------------------------------------------------------
ProfileTest
.
expected_output
[
'print_stats'
]
=
"""
\
_ProfileOutput
=
{}
_ProfileOutput
[
'print_stats'
]
=
"""
\
28 27.972 0.999 27.972 0.999 profilee.py:110(__getattr__)
1 269.996 269.996 999.769 999.769 profilee.py:25(testfunc)
23/3 149.937 6.519 169.917 56.639 profilee.py:35(factorial)
...
...
@@ -93,7 +98,7 @@ ProfileTest.expected_output['print_stats'] = """\
2 -0.006 -0.003 139.946 69.973 profilee.py:84(helper2_indirect)
8 311.976 38.997 399.912 49.989 profilee.py:88(helper2)
8 63.976 7.997 79.960 9.995 profilee.py:98(subhelper)"""
ProfileTest
.
expected_o
utput
[
'print_callers'
]
=
"""
\
_ProfileO
utput
[
'print_callers'
]
=
"""
\
:0(append) <- profilee.py:73(helper1)(4) 119.964
:0(exc_info) <- profilee.py:73(helper1)(4) 119.964
:0(hasattr) <- profilee.py:73(helper1)(4) 119.964
...
...
@@ -111,7 +116,7 @@ profilee.py:84(helper2_indirect) <- profilee.py:55(helper)(2) 599.830
profilee.py:88(helper2) <- profilee.py:55(helper)(6) 599.830
profilee.py:84(helper2_indirect)(2) 139.946
profilee.py:98(subhelper) <- profilee.py:88(helper2)(8) 399.912"""
ProfileTest
.
expected_o
utput
[
'print_callees'
]
=
"""
\
_ProfileO
utput
[
'print_callees'
]
=
"""
\
:0(hasattr) -> profilee.py:110(__getattr__)(12) 27.972
<string>:1(<module>) -> profilee.py:25(testfunc)(1) 999.769
profilee.py:110(__getattr__) ->
...
...
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