mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Properly close a test file in test_cprofile.
This commit is contained in:
parent
2d562f8081
commit
5ede149342
1 changed files with 10 additions and 9 deletions
|
@ -18,15 +18,16 @@ class CProfileTest(ProfileTest):
|
|||
def test_bad_counter_during_dealloc(self):
|
||||
import _lsprof
|
||||
# Must use a file as StringIO doesn't trigger the bug.
|
||||
sys.stderr = open(TESTFN, 'w')
|
||||
try:
|
||||
obj = _lsprof.Profiler(lambda: int)
|
||||
obj.enable()
|
||||
obj = _lsprof.Profiler(1)
|
||||
obj.disable()
|
||||
finally:
|
||||
sys.stderr = sys.__stderr__
|
||||
unlink(TESTFN)
|
||||
with open(TESTFN, 'w') as file:
|
||||
sys.stderr = file
|
||||
try:
|
||||
obj = _lsprof.Profiler(lambda: int)
|
||||
obj.enable()
|
||||
obj = _lsprof.Profiler(1)
|
||||
obj.disable()
|
||||
finally:
|
||||
sys.stderr = sys.__stderr__
|
||||
unlink(TESTFN)
|
||||
|
||||
|
||||
def test_main():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue