mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
bpo-40275: Use new test.support helper submodules in tests (GH-21448)
This commit is contained in:
parent
bb0424b122
commit
4660597b51
20 changed files with 185 additions and 154 deletions
|
@ -3,6 +3,8 @@ Test script for doctest.
|
|||
"""
|
||||
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from test.support import os_helper
|
||||
import doctest
|
||||
import functools
|
||||
import os
|
||||
|
@ -441,7 +443,7 @@ We'll simulate a __file__ attr that ends in pyc:
|
|||
>>> tests = finder.find(sample_func)
|
||||
|
||||
>>> print(tests) # doctest: +ELLIPSIS
|
||||
[<DocTest sample_func from ...:25 (1 example)>]
|
||||
[<DocTest sample_func from ...:27 (1 example)>]
|
||||
|
||||
The exact name depends on how test_doctest was invoked, so allow for
|
||||
leading path components.
|
||||
|
@ -705,7 +707,7 @@ class TestDocTestFinder(unittest.TestCase):
|
|||
try:
|
||||
mod = importlib.import_module(pkg_name)
|
||||
finally:
|
||||
support.forget(pkg_name)
|
||||
import_helper.forget(pkg_name)
|
||||
sys.path.pop()
|
||||
|
||||
include_empty_finder = doctest.DocTestFinder(exclude_empty=False)
|
||||
|
@ -2758,7 +2760,7 @@ whitespace if doctest does not correctly do the newline conversion.
|
|||
>>> dn = tempfile.mkdtemp()
|
||||
>>> pkg = os.path.join(dn, "doctest_testpkg")
|
||||
>>> os.mkdir(pkg)
|
||||
>>> support.create_empty_file(os.path.join(pkg, "__init__.py"))
|
||||
>>> os_helper.create_empty_file(os.path.join(pkg, "__init__.py"))
|
||||
>>> fn = os.path.join(pkg, "doctest_testfile.txt")
|
||||
>>> with open(fn, 'wb') as f:
|
||||
... f.write(
|
||||
|
@ -2840,7 +2842,8 @@ With those preliminaries out of the way, we'll start with a file with two
|
|||
simple tests and no errors. We'll run both the unadorned doctest command, and
|
||||
the verbose version, and then check the output:
|
||||
|
||||
>>> from test.support import script_helper, temp_dir
|
||||
>>> from test.support import script_helper
|
||||
>>> from test.support.os_helper import temp_dir
|
||||
>>> with temp_dir() as tmpdir:
|
||||
... fn = os.path.join(tmpdir, 'myfile.doc')
|
||||
... with open(fn, 'w') as f:
|
||||
|
@ -2891,7 +2894,8 @@ ability to process more than one file on the command line and, since the second
|
|||
file ends in '.py', its handling of python module files (as opposed to straight
|
||||
text files).
|
||||
|
||||
>>> from test.support import script_helper, temp_dir
|
||||
>>> from test.support import script_helper
|
||||
>>> from test.support.os_helper import temp_dir
|
||||
>>> with temp_dir() as tmpdir:
|
||||
... fn = os.path.join(tmpdir, 'myfile.doc')
|
||||
... with open(fn, 'w') as f:
|
||||
|
@ -3109,7 +3113,7 @@ def test_main():
|
|||
|
||||
|
||||
def test_coverage(coverdir):
|
||||
trace = support.import_module('trace')
|
||||
trace = import_helper.import_module('trace')
|
||||
tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,],
|
||||
trace=0, count=1)
|
||||
tracer.run('test_main()')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue