mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-40275: Use new test.support helper submodules in tests (GH-21315)
This commit is contained in:
parent
883bc63833
commit
a089d21df1
20 changed files with 69 additions and 49 deletions
|
@ -6,6 +6,7 @@ import os.path
|
|||
import tempfile
|
||||
import tokenize
|
||||
from test import support
|
||||
from test.support import os_helper
|
||||
|
||||
|
||||
FILENAME = linecache.__file__
|
||||
|
@ -44,7 +45,7 @@ class TempFile:
|
|||
with tempfile.NamedTemporaryFile(delete=False) as fp:
|
||||
self.file_name = fp.name
|
||||
fp.write(self.file_byte_string)
|
||||
self.addCleanup(support.unlink, self.file_name)
|
||||
self.addCleanup(os_helper.unlink, self.file_name)
|
||||
|
||||
|
||||
class GetLineTestsGoodData(TempFile):
|
||||
|
@ -124,10 +125,10 @@ class LineCacheTests(unittest.TestCase):
|
|||
self.assertEqual(empty, [])
|
||||
|
||||
def test_no_ending_newline(self):
|
||||
self.addCleanup(support.unlink, support.TESTFN)
|
||||
with open(support.TESTFN, "w") as fp:
|
||||
self.addCleanup(os_helper.unlink, os_helper.TESTFN)
|
||||
with open(os_helper.TESTFN, "w") as fp:
|
||||
fp.write(SOURCE_3)
|
||||
lines = linecache.getlines(support.TESTFN)
|
||||
lines = linecache.getlines(os_helper.TESTFN)
|
||||
self.assertEqual(lines, ["\n", "def f():\n", " return 3\n"])
|
||||
|
||||
def test_clearcache(self):
|
||||
|
@ -150,8 +151,8 @@ class LineCacheTests(unittest.TestCase):
|
|||
def test_checkcache(self):
|
||||
getline = linecache.getline
|
||||
# Create a source file and cache its contents
|
||||
source_name = support.TESTFN + '.py'
|
||||
self.addCleanup(support.unlink, source_name)
|
||||
source_name = os_helper.TESTFN + '.py'
|
||||
self.addCleanup(os_helper.unlink, source_name)
|
||||
with open(source_name, 'w') as source:
|
||||
source.write(SOURCE_1)
|
||||
getline(source_name, 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue