File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import unittest
33
44
5- class FinderTests (unittest . TestCase , metaclass = abc .ABCMeta ):
5+ class FinderTests (metaclass = abc .ABCMeta ):
66
77 """Basic tests for a finder to pass."""
88
@@ -39,7 +39,7 @@ def test_failure(self):
3939 pass
4040
4141
42- class LoaderTests (unittest . TestCase , metaclass = abc .ABCMeta ):
42+ class LoaderTests (metaclass = abc .ABCMeta ):
4343
4444 @abc .abstractmethod
4545 def test_module (self ):
Original file line number Diff line number Diff line change 66import sys
77import unittest
88
9- class FinderTests (abc .FinderTests ):
9+ class FinderTests (unittest . TestCase , abc .FinderTests ):
1010
1111 """Test find_module() for built-in modules."""
1212
@@ -46,10 +46,5 @@ def test_ignore_path(self):
4646
4747
4848
49- def test_main ():
50- from test .support import run_unittest
51- run_unittest (FinderTests )
52-
53-
5449if __name__ == '__main__' :
55- test_main ()
50+ unittest . main ()
Original file line number Diff line number Diff line change 99import unittest
1010
1111
12- class LoaderTests (abc .LoaderTests ):
12+ class LoaderTests (unittest . TestCase , abc .LoaderTests ):
1313
1414 """Test load_module() for built-in modules."""
1515
Original file line number Diff line number Diff line change 44
55import unittest
66
7- class FinderTests (abc .FinderTests ):
7+ class FinderTests (unittest . TestCase , abc .FinderTests ):
88
99 """Test the finder for extension modules."""
1010
Original file line number Diff line number Diff line change 88import unittest
99
1010
11- class LoaderTests (abc .LoaderTests ):
11+ class LoaderTests (unittest . TestCase , abc .LoaderTests ):
1212
1313 """Test load_module() for extension modules."""
1414
Original file line number Diff line number Diff line change 44import unittest
55
66
7- class FinderTests (abc .FinderTests ):
7+ class FinderTests (unittest . TestCase , abc .FinderTests ):
88
99 """Test finding frozen modules."""
1010
Original file line number Diff line number Diff line change 77import types
88
99
10- class LoaderTests (abc .LoaderTests ):
10+ class LoaderTests (unittest . TestCase , abc .LoaderTests ):
1111
1212 def test_module (self ):
1313 with util .uncache ('__hello__' ), captured_stdout () as stdout :
Original file line number Diff line number Diff line change 1919from test .support import make_legacy_pyc , unload
2020
2121
22- class SimpleTest (unittest .TestCase ):
22+ class SimpleTest (unittest .TestCase , abc . LoaderTests ):
2323
2424 """Should have no issue importing a source module [basic]. And if there is
2525 a syntax error, it should raise a SyntaxError [syntax error].
@@ -177,6 +177,11 @@ def test_timestamp_overflow(self):
177177 # The pyc file was created.
178178 os .stat (compiled )
179179
180+ def test_unloadable (self ):
181+ loader = machinery .SourceFileLoader ('good name' , {})
182+ with self .assertRaises (ImportError ):
183+ loader .load_module ('bad name' )
184+
180185
181186class BadBytecodeTest (unittest .TestCase ):
182187
Original file line number Diff line number Diff line change 1313import warnings
1414
1515
16- class FinderTests (abc .FinderTests ):
16+ class FinderTests (unittest . TestCase , abc .FinderTests ):
1717
1818 """For a top-level module, it should just be found directly in the
1919 directory being searched. This is true for a directory with source
You can’t perform that action at this time.
0 commit comments