mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Added global runctx function to profile to fix SF Bug #716587
This commit is contained in:
parent
706933821c
commit
1eb4bfc657
5 changed files with 46 additions and 7 deletions
|
|
@ -1,6 +1,8 @@
|
|||
"""Test suite for the profile module."""
|
||||
|
||||
import profile
|
||||
import os
|
||||
from test.test_support import TESTFN, vereq
|
||||
|
||||
# In order to have reproducible time, we simulate a timer in the global
|
||||
# variable 'ticks', which represents simulated time in milliseconds.
|
||||
|
|
@ -82,5 +84,17 @@ class C:
|
|||
ticks += 1
|
||||
raise AttributeError
|
||||
|
||||
|
||||
def test_2():
|
||||
d = globals().copy()
|
||||
def testfunc():
|
||||
global x
|
||||
x = 1
|
||||
d['testfunc'] = testfunc
|
||||
profile.runctx("testfunc()", d, d, TESTFN)
|
||||
vereq (x, 1)
|
||||
os.unlink (TESTFN)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
test_2()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue