3939 TESTFN , rmtree , temp_umask , TESTFN_UNENCODABLE )
4040from test .support import script_helper
4141from test .support import threading_helper
42+ from test .support .testcase import ExtraAssertions
4243from test .test_importlib .util import uncache
4344from types import ModuleType
4445try :
@@ -352,7 +353,7 @@ def _from_subinterp(cls, name, interpid, pipe, script_kwargs):
352353 return cls .parse (text .decode ())
353354
354355
355- class ImportTests (unittest .TestCase ):
356+ class ImportTests (unittest .TestCase , ExtraAssertions ):
356357
357358 def setUp (self ):
358359 remove_files (TESTFN )
@@ -558,7 +559,7 @@ def test_import_name_binding(self):
558559 import test as x
559560 import test .support
560561 self .assertIs (x , test , x .__name__ )
561- self .assertTrue ( hasattr ( test .support , "__file__" ) )
562+ self .assertHasAttr ( test .support , "__file__" )
562563
563564 # import x.y.z as w binds z as w
564565 import test .support as y
@@ -629,7 +630,7 @@ def test_file_to_source(self):
629630 sys .path .insert (0 , os .curdir )
630631 try :
631632 mod = __import__ (TESTFN )
632- self .assertTrue (mod .__file__ . endswith ( '.py' ) )
633+ self .assertEndsWith (mod .__file__ , '.py' )
633634 os .remove (source )
634635 del sys .modules [TESTFN ]
635636 make_legacy_pyc (source )
@@ -1462,11 +1463,11 @@ def test_UNC_path(self):
14621463 self .fail ("could not import 'test_unc_path' from %r: %r"
14631464 % (unc , e ))
14641465 self .assertEqual (mod .testdata , 'test_unc_path' )
1465- self .assertTrue (mod .__file__ . startswith ( unc ), mod . __file__ )
1466+ self .assertStartsWith (mod .__file__ , unc )
14661467 unload ("test_unc_path" )
14671468
14681469
1469- class RelativeImportTests (unittest .TestCase ):
1470+ class RelativeImportTests (unittest .TestCase , ExtraAssertions ):
14701471
14711472 def tearDown (self ):
14721473 unload ("test.relimport" )
@@ -1475,7 +1476,7 @@ def tearDown(self):
14751476 def test_relimport_star (self ):
14761477 # This will import * from .test_import.
14771478 from .. import relimport
1478- self .assertTrue ( hasattr ( relimport , "RelativeImportTests" ) )
1479+ self .assertHasAttr ( relimport , "RelativeImportTests" )
14791480
14801481 def test_issue3221 (self ):
14811482 # Note for mergers: the 'absolute' tests from the 2.x branch
@@ -1792,7 +1793,7 @@ def test_symlinked_dir_importable(self):
17921793
17931794
17941795@cpython_only
1795- class ImportlibBootstrapTests (unittest .TestCase ):
1796+ class ImportlibBootstrapTests (unittest .TestCase , ExtraAssertions ):
17961797 # These tests check that importlib is bootstrapped.
17971798
17981799 def test_frozen_importlib (self ):
@@ -1805,15 +1806,15 @@ def test_frozen_importlib_is_bootstrap(self):
18051806 self .assertIs (mod , _bootstrap )
18061807 self .assertEqual (mod .__name__ , 'importlib._bootstrap' )
18071808 self .assertEqual (mod .__package__ , 'importlib' )
1808- self .assertTrue (mod .__file__ . endswith ( '_bootstrap.py' ), mod . __file__ )
1809+ self .assertEndsWith (mod .__file__ , '_bootstrap.py' )
18091810
18101811 def test_frozen_importlib_external_is_bootstrap_external (self ):
18111812 from importlib import _bootstrap_external
18121813 mod = sys .modules ['_frozen_importlib_external' ]
18131814 self .assertIs (mod , _bootstrap_external )
18141815 self .assertEqual (mod .__name__ , 'importlib._bootstrap_external' )
18151816 self .assertEqual (mod .__package__ , 'importlib' )
1816- self .assertTrue (mod .__file__ . endswith ( '_bootstrap_external.py' ), mod . __file__ )
1817+ self .assertEndsWith (mod .__file__ , '_bootstrap_external.py' )
18171818
18181819 def test_there_can_be_only_one (self ):
18191820 # Issue #15386 revealed a tricky loophole in the bootstrapping
@@ -2648,7 +2649,7 @@ def parse(cls, text):
26482649
26492650
26502651@requires_singlephase_init
2651- class SinglephaseInitTests (unittest .TestCase ):
2652+ class SinglephaseInitTests (unittest .TestCase , ExtraAssertions ):
26522653
26532654 NAME = '_testsinglephase'
26542655
@@ -2819,7 +2820,7 @@ def check_common(self, loaded):
28192820 self .assertEqual (mod .__file__ , self .FILE )
28202821 self .assertEqual (mod .__spec__ .origin , self .ORIGIN )
28212822 if not isolated :
2822- self .assertTrue ( issubclass ( mod .error , Exception ) )
2823+ self .assertIsSubclass ( mod .error , Exception )
28232824 self .assertEqual (mod .int_const , 1969 )
28242825 self .assertEqual (mod .str_const , 'something different' )
28252826 self .assertIsInstance (mod ._module_initialized , float )
0 commit comments