bpo-40275: Use new test.support helper submodules in tests (GH-21449)

This commit is contained in:
Hai Shi 2020-08-04 00:41:24 +08:00 committed by GitHub
parent 488512bf49
commit a7f5d93bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 154 additions and 132 deletions

View file

@ -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):