import unittest
-class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+class FinderTests(metaclass=abc.ABCMeta):
"""Basic tests for a finder to pass."""
pass
-class LoaderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+class LoaderTests(metaclass=abc.ABCMeta):
@abc.abstractmethod
def test_module(self):
import sys
import unittest
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test find_module() for built-in modules."""
-def test_main():
- from test.support import run_unittest
- run_unittest(FinderTests)
-
-
if __name__ == '__main__':
- test_main()
+ unittest.main()
import unittest
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
"""Test load_module() for built-in modules."""
import unittest
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test the finder for extension modules."""
import unittest
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
"""Test load_module() for extension modules."""
import unittest
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
"""Test finding frozen modules."""
import types
-class LoaderTests(abc.LoaderTests):
+class LoaderTests(unittest.TestCase, abc.LoaderTests):
def test_module(self):
with util.uncache('__hello__'), captured_stdout() as stdout:
from test.support import make_legacy_pyc, unload
-class SimpleTest(unittest.TestCase):
+class SimpleTest(unittest.TestCase, abc.LoaderTests):
"""Should have no issue importing a source module [basic]. And if there is
a syntax error, it should raise a SyntaxError [syntax error].
# The pyc file was created.
os.stat(compiled)
+ def test_unloadable(self):
+ loader = machinery.SourceFileLoader('good name', {})
+ with self.assertRaises(ImportError):
+ loader.load_module('bad name')
+
class BadBytecodeTest(unittest.TestCase):
import warnings
-class FinderTests(abc.FinderTests):
+class FinderTests(unittest.TestCase, abc.FinderTests):
"""For a top-level module, it should just be found directly in the
directory being searched. This is true for a directory with source