cpython: b26e6e3e8037 (original) (raw)

--- a/Lib/test/test_importlib/frozen/test_finder.py +++ b/Lib/test/test_importlib/frozen/test_finder.py @@ -1,15 +1,17 @@ -from importlib import machinery from .. import abc +from .. import util + +machinery = util.import_importlib('importlib.machinery') import unittest -class FinderTests(unittest.TestCase, abc.FinderTests): +class FinderTests(abc.FinderTests): """Test finding frozen modules.""" def find(self, name, path=None):

def test_module(self): @@ -37,11 +39,9 @@ class FinderTests(unittest.TestCase, abc loader = self.find('') self.assertIsNone(loader) - -def test_main():

+Frozen_FinderTests, Source_FinderTests = util.test_both(FinderTests,

if name == 'main':

--- a/Lib/test/test_importlib/frozen/test_loader.py +++ b/Lib/test/test_importlib/frozen/test_loader.py @@ -1,20 +1,21 @@ from .. import abc from .. import util -from importlib import machinery +machinery = util.import_importlib('importlib.machinery') + import unittest from test.support import captured_stdout import types -class LoaderTests(unittest.TestCase, abc.LoaderTests): +class LoaderTests(abc.LoaderTests): def test_module(self): with util.uncache('hello'), captured_stdout() as stdout:

@@ -23,11 +24,11 @@ class LoaderTests(unittest.TestCase, abc def test_package(self): with util.uncache('phello'), captured_stdout() as stdout:

@@ -40,10 +41,10 @@ class LoaderTests(unittest.TestCase, abc def test_lacking_parent(self): with util.uncache('phello', 'phello.spam'), [](#l2.45) captured_stdout() as stdout:

@@ -55,15 +56,15 @@ class LoaderTests(unittest.TestCase, abc def test_module_reuse(self): with util.uncache('hello'), captured_stdout() as stdout:

def test_module_repr(self): with util.uncache('hello'), captured_stdout():

@@ -72,13 +73,16 @@ class LoaderTests(unittest.TestCase, abc pass def test_unloadable(self):

+Frozen_LoaderTests, Source_LoaderTests = util.test_both(LoaderTests,

-class InspectLoaderTests(unittest.TestCase): + +class InspectLoaderTests: """Tests for the InspectLoader methods for FrozenImporter.""" @@ -86,7 +90,7 @@ class InspectLoaderTests(unittest.TestCa # Make sure that the code object is good. name = 'hello' with captured_stdout() as stdout:

@@ -94,7 +98,7 @@ class InspectLoaderTests(unittest.TestCa def test_get_source(self): # Should always return None.

def test_is_package(self): @@ -102,22 +106,20 @@ class InspectLoaderTests(unittest.TestCa test_for = (('hello', False), ('phello', True), ('phello.spam', False)) for name, is_package in test_for:

def test_failure(self): # Raise ImportError for modules that are not frozen. for meth_name in ('get_code', 'get_source', 'is_package'):

- -def test_main():

+Frozen_ILTests, Source_ILTests = util.test_both(InspectLoaderTests,

if name == 'main':