mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-40275: Use new test.support helper submodules in tests (GH-21449)
This commit is contained in:
parent
488512bf49
commit
a7f5d93bb6
20 changed files with 154 additions and 132 deletions
|
@ -7,6 +7,7 @@ from unittest.mock import patch
|
|||
from test.support.script_helper import (assert_python_ok, assert_python_failure,
|
||||
interpreter_requires_environment)
|
||||
from test import support
|
||||
from test.support import os_helper
|
||||
|
||||
try:
|
||||
import _testcapi
|
||||
|
@ -287,11 +288,11 @@ class TestTracemallocEnabled(unittest.TestCase):
|
|||
self.assertGreater(snapshot.traces[1].traceback.total_nframe, 10)
|
||||
|
||||
# write on disk
|
||||
snapshot.dump(support.TESTFN)
|
||||
self.addCleanup(support.unlink, support.TESTFN)
|
||||
snapshot.dump(os_helper.TESTFN)
|
||||
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
||||
|
||||
# load from disk
|
||||
snapshot2 = tracemalloc.Snapshot.load(support.TESTFN)
|
||||
snapshot2 = tracemalloc.Snapshot.load(os_helper.TESTFN)
|
||||
self.assertEqual(snapshot2.traces, snapshot.traces)
|
||||
|
||||
# tracemalloc must be tracing memory allocations to take a snapshot
|
||||
|
@ -306,11 +307,11 @@ class TestTracemallocEnabled(unittest.TestCase):
|
|||
# take a snapshot with a new attribute
|
||||
snapshot = tracemalloc.take_snapshot()
|
||||
snapshot.test_attr = "new"
|
||||
snapshot.dump(support.TESTFN)
|
||||
self.addCleanup(support.unlink, support.TESTFN)
|
||||
snapshot.dump(os_helper.TESTFN)
|
||||
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
||||
|
||||
# load() should recreate the attribute
|
||||
snapshot2 = tracemalloc.Snapshot.load(support.TESTFN)
|
||||
snapshot2 = tracemalloc.Snapshot.load(os_helper.TESTFN)
|
||||
self.assertEqual(snapshot2.test_attr, "new")
|
||||
|
||||
def fork_child(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue