mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Issue #7449, part 10: test_cmd imports trace module using test_support.import_module()
Use test_support.import_module() instead of import to raise a SkipTest exception if the import fail. Import trace fails if the threading module is missing. See also part 3: test_doctest: import trace module in test_coverage().
This commit is contained in:
parent
47c884129d
commit
c73a05f775
1 changed files with 3 additions and 2 deletions
|
@ -7,6 +7,7 @@ Original by Michael Schneider
|
||||||
|
|
||||||
import cmd
|
import cmd
|
||||||
import sys
|
import sys
|
||||||
|
from test import test_support
|
||||||
|
|
||||||
class samplecmdclass(cmd.Cmd):
|
class samplecmdclass(cmd.Cmd):
|
||||||
"""
|
"""
|
||||||
|
@ -168,11 +169,11 @@ class samplecmdclass(cmd.Cmd):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def test_main(verbose=None):
|
def test_main(verbose=None):
|
||||||
from test import test_support, test_cmd
|
from test import test_cmd
|
||||||
test_support.run_doctest(test_cmd, verbose)
|
test_support.run_doctest(test_cmd, verbose)
|
||||||
|
|
||||||
def test_coverage(coverdir):
|
def test_coverage(coverdir):
|
||||||
import trace
|
trace = test_support.import_module('trace')
|
||||||
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
|
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
|
||||||
trace=0, count=1)
|
trace=0, count=1)
|
||||||
tracer.run('reload(cmd);test_main()')
|
tracer.run('reload(cmd);test_main()')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue