diff options
-rw-r--r-- | coverage/backward.py | 12 | ||||
-rw-r--r-- | setup.cfg | 4 | ||||
-rw-r--r-- | tests/conftest.py | 19 |
3 files changed, 25 insertions, 10 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 9d1d78e5..8af3452b 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -245,15 +245,17 @@ def import_local_file(modname, modfile=None): """ try: - from importlib.machinery import SourceFileLoader + import importlib.util as importlib_util except ImportError: - SourceFileLoader = None + importlib_util = None if modfile is None: modfile = modname + '.py' - if SourceFileLoader: - # pylint: disable=no-value-for-parameter, deprecated-method - mod = SourceFileLoader(modname, modfile).load_module() + if importlib_util: + spec = importlib_util.spec_from_file_location(modname, modfile) + mod = importlib_util.module_from_spec(spec) + sys.modules[modname] = mod + spec.loader.exec_module(mod) else: for suff in imp.get_suffixes(): # pragma: part covered if suff[0] == '.py': @@ -2,10 +2,12 @@ addopts = -q -n3 --strict --force-flaky --no-flaky-report -rfe --failed-first markers = expensive: too slow to run during "make smoke" -# How come this warning is suppressed successfully here, but not in conftest.py?? + +# How come these warnings are suppressed successfully here, but not in conftest.py?? filterwarnings = ignore:dns.hash module will be removed:DeprecationWarning ignore:Using or importing the ABCs:DeprecationWarning + # xfail tests that pass should fail the test suite xfail_strict=true diff --git a/tests/conftest.py b/tests/conftest.py index 82a6b0f2..10761cdd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -25,21 +25,32 @@ def set_warnings(): warnings.simplefilter("default") warnings.simplefilter("once", DeprecationWarning) - # A warning to suppress: + # Warnings to suppress: + # How come these warnings are successfully suppressed here, but not in setup.cfg?? + # setuptools/py33compat.py:54: DeprecationWarning: The value of convert_charrefs will become # True in 3.5. You are encouraged to set the value explicitly. # unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape) - # How come this warning is successfully suppressed here, but not in setup.cfg?? warnings.filterwarnings( "ignore", category=DeprecationWarning, - message="The value of convert_charrefs will become True in 3.5.", + message=r"The value of convert_charrefs will become True in 3.5.", ) + warnings.filterwarnings( "ignore", category=DeprecationWarning, - message=".* instead of inspect.getfullargspec", + message=r".* instead of inspect.getfullargspec", ) + + # <frozen importlib._bootstrap>:681: + # ImportWarning: VendorImporter.exec_module() not found; falling back to load_module() + warnings.filterwarnings( + "ignore", + category=ImportWarning, + message=r".*exec_module\(\) not found; falling back to load_module\(\)", + ) + if env.PYPY3: # pypy3 warns about unclosed files a lot. warnings.filterwarnings("ignore", r".*unclosed file", category=ResourceWarning) |