5050 TESTFN , rmtree , temp_umask , TESTFN_UNENCODABLE )
5151from test .support import script_helper
5252from test .support import threading_helper
53+ from test .support .testcase import ExtraAssertions
5354from test .test_importlib .util import uncache
5455from types import ModuleType
5556try :
@@ -364,7 +365,7 @@ def _from_subinterp(cls, name, interpid, pipe, script_kwargs):
364365
365366
366367@force_not_colorized_test_class
367- class ImportTests (unittest .TestCase ):
368+ class ImportTests (unittest .TestCase , ExtraAssertions ):
368369
369370 def setUp (self ):
370371 remove_files (TESTFN )
@@ -570,7 +571,7 @@ def test_import_name_binding(self):
570571 import test as x
571572 import test .support
572573 self .assertIs (x , test , x .__name__ )
573- self .assertTrue ( hasattr ( test .support , "__file__" ) )
574+ self .assertHasAttr ( test .support , "__file__" )
574575
575576 # import x.y.z as w binds z as w
576577 import test .support as y
@@ -641,7 +642,7 @@ def test_file_to_source(self):
641642 sys .path .insert (0 , os .curdir )
642643 try :
643644 mod = __import__ (TESTFN )
644- self .assertTrue (mod .__file__ . endswith ( '.py' ) )
645+ self .assertEndsWith (mod .__file__ , '.py' )
645646 os .remove (source )
646647 del sys .modules [TESTFN ]
647648 make_legacy_pyc (source )
@@ -1447,7 +1448,7 @@ def test_foreign_code(self):
14471448 self .assertEqual (mod .constant .co_filename , foreign_code .co_filename )
14481449
14491450
1450- class PathsTests (unittest .TestCase ):
1451+ class PathsTests (unittest .TestCase , ExtraAssertions ):
14511452 SAMPLES = ('test' , 'test\u00e4 \u00f6 \u00fc \u00df ' , 'test\u00e9 \u00e8 ' ,
14521453 'test\u00b0 \u00b3 \u00b2 ' )
14531454 path = TESTFN
@@ -1497,11 +1498,11 @@ def test_UNC_path(self):
14971498 self .fail ("could not import 'test_unc_path' from %r: %r"
14981499 % (unc , e ))
14991500 self .assertEqual (mod .testdata , 'test_unc_path' )
1500- self .assertTrue (mod .__file__ . startswith ( unc ), mod . __file__ )
1501+ self .assertStartsWith (mod .__file__ , unc )
15011502 unload ("test_unc_path" )
15021503
15031504
1504- class RelativeImportTests (unittest .TestCase ):
1505+ class RelativeImportTests (unittest .TestCase , ExtraAssertions ):
15051506
15061507 def tearDown (self ):
15071508 unload ("test.relimport" )
@@ -1510,7 +1511,7 @@ def tearDown(self):
15101511 def test_relimport_star (self ):
15111512 # This will import * from .test_import.
15121513 from .. import relimport
1513- self .assertTrue ( hasattr ( relimport , "RelativeImportTests" ) )
1514+ self .assertHasAttr ( relimport , "RelativeImportTests" )
15141515
15151516 def test_issue3221 (self ):
15161517 # Note for mergers: the 'absolute' tests from the 2.x branch
@@ -1827,7 +1828,7 @@ def test_symlinked_dir_importable(self):
18271828
18281829
18291830@cpython_only
1830- class ImportlibBootstrapTests (unittest .TestCase ):
1831+ class ImportlibBootstrapTests (unittest .TestCase , ExtraAssertions ):
18311832 # These tests check that importlib is bootstrapped.
18321833
18331834 def test_frozen_importlib (self ):
@@ -1840,15 +1841,15 @@ def test_frozen_importlib_is_bootstrap(self):
18401841 self .assertIs (mod , _bootstrap )
18411842 self .assertEqual (mod .__name__ , 'importlib._bootstrap' )
18421843 self .assertEqual (mod .__package__ , 'importlib' )
1843- self .assertTrue (mod .__file__ . endswith ( '_bootstrap.py' ), mod . __file__ )
1844+ self .assertEndsWith (mod .__file__ , '_bootstrap.py' )
18441845
18451846 def test_frozen_importlib_external_is_bootstrap_external (self ):
18461847 from importlib import _bootstrap_external
18471848 mod = sys .modules ['_frozen_importlib_external' ]
18481849 self .assertIs (mod , _bootstrap_external )
18491850 self .assertEqual (mod .__name__ , 'importlib._bootstrap_external' )
18501851 self .assertEqual (mod .__package__ , 'importlib' )
1851- self .assertTrue (mod .__file__ . endswith ( '_bootstrap_external.py' ), mod . __file__ )
1852+ self .assertEndsWith (mod .__file__ , '_bootstrap_external.py' )
18521853
18531854 def test_there_can_be_only_one (self ):
18541855 # Issue #15386 revealed a tricky loophole in the bootstrapping
@@ -2698,7 +2699,7 @@ def parse(cls, text):
26982699
26992700
27002701@requires_singlephase_init
2701- class SinglephaseInitTests (unittest .TestCase ):
2702+ class SinglephaseInitTests (unittest .TestCase , ExtraAssertions ):
27022703
27032704 NAME = '_testsinglephase'
27042705
@@ -2869,7 +2870,7 @@ def check_common(self, loaded):
28692870 self .assertEqual (mod .__file__ , self .FILE )
28702871 self .assertEqual (mod .__spec__ .origin , self .ORIGIN )
28712872 if not isolated :
2872- self .assertTrue ( issubclass ( mod .error , Exception ) )
2873+ self .assertIsSubclass ( mod .error , Exception )
28732874 self .assertEqual (mod .int_const , 1969 )
28742875 self .assertEqual (mod .str_const , 'something different' )
28752876 self .assertIsInstance (mod ._module_initialized , float )
0 commit comments