@@ -86,12 +86,12 @@ def check_extra_options_format(extra_options):
8686 """Make sure extra_options value is of correct format."""
8787 # EasyBuild v2.0: dict with <string> keys and <list> values
8888 # (breaks backward compatibility compared to v1.x)
89- self .assertTrue ( isinstance ( extra_options , dict ) ) # conversion to a dict works
89+ self .assertIsInstance ( extra_options , dict ) # conversion to a dict works
9090 extra_options .items ()
9191 extra_options .keys ()
9292 extra_options .values ()
9393 for key in extra_options .keys ():
94- self .assertTrue ( isinstance ( extra_options [key ], list ) )
94+ self .assertIsInstance ( extra_options [key ], list )
9595 self .assertEqual (len (extra_options [key ]), 3 )
9696
9797 name = "pi"
@@ -202,7 +202,7 @@ def test_load_module(self):
202202
203203 # we expect $TMPDIR to be tweaked by the prepare step (OpenMPI 2.x doesn't like long $TMPDIR values)
204204 tweaked_tmpdir = os .environ .get ('TMPDIR' )
205- self .assertTrue (tweaked_tmpdir != orig_tmpdir )
205+ self .assertNotEqual (tweaked_tmpdir , orig_tmpdir )
206206
207207 eb .make_module_step ()
208208 eb .load_module ()
@@ -234,7 +234,7 @@ def test_fake_module_load(self):
234234 if get_module_syntax () == 'Lua' :
235235 pi_modfile += '.lua'
236236
237- self .assertTrue ( os . path . exists ( pi_modfile ) )
237+ self .assertExists ( pi_modfile )
238238
239239 # check whether temporary module file is marked as default
240240 if get_module_syntax () == 'Lua' :
@@ -668,7 +668,7 @@ def test_make_module_extra(self):
668668 if get_module_syntax () == 'Lua' :
669669 modpath += '.lua'
670670
671- self .assertTrue ( os . path . exists ( modpath ), "%s exists" % modpath )
671+ self .assertExists ( modpath )
672672 txt = read_file (modpath )
673673 patterns = [
674674 r"^prepend[-_]path.*TEST_PATH_VAR.*root.*foo" ,
@@ -1203,7 +1203,7 @@ def test_make_module_step(self):
12031203 modpath = os .path .join (eb .make_module_step (), name , version )
12041204 if get_module_syntax () == 'Lua' :
12051205 modpath += '.lua'
1206- self .assertTrue ( os . path . exists ( modpath ), "%s exists" % modpath )
1206+ self .assertExists ( modpath )
12071207
12081208 # verify contents of module
12091209 txt = read_file (modpath )
@@ -1374,13 +1374,13 @@ def test_make_builddir(self):
13741374 builddir = eb .builddir
13751375 testfile = os .path .join (builddir , 'test123' , 'foobar.txt' )
13761376 write_file (testfile , 'test123' )
1377- self .assertTrue ( os . path . exists ( testfile ) )
1377+ self .assertExists ( testfile )
13781378
13791379 eb .make_builddir ()
13801380 self .assertEqual (builddir , eb .builddir )
13811381 # file is gone because directory was removed and re-created
1382- self .assertFalse ( os . path . exists ( testfile ) )
1383- self .assertFalse (os .path .exists ( os . path . dirname (testfile ) ))
1382+ self .assertNotExists ( testfile )
1383+ self .assertNotExists (os .path .dirname (testfile ))
13841384 self .assertEqual (os .listdir (eb .builddir ), [])
13851385
13861386 # make sure that build directory does *not* get re-created when we're building in installation directory
@@ -1392,7 +1392,7 @@ def test_make_builddir(self):
13921392 builddir = eb .builddir
13931393 testfile = os .path .join (builddir , 'test123' , 'foobar.txt' )
13941394 write_file (testfile , 'test123' )
1395- self .assertTrue ( os . path . exists ( testfile ) )
1395+ self .assertExists ( testfile )
13961396 self .assertEqual (os .listdir (eb .builddir ), ['test123' ])
13971397 self .assertEqual (os .listdir (os .path .join (eb .builddir , 'test123' )), ['foobar.txt' ])
13981398
@@ -1401,7 +1401,7 @@ def test_make_builddir(self):
14011401 eb .make_builddir ()
14021402 eb .make_installdir ()
14031403 self .assertEqual (builddir , eb .builddir )
1404- self .assertTrue ( os . path . exists ( testfile ) )
1404+ self .assertExists ( testfile )
14051405 self .assertEqual (os .listdir (eb .builddir ), ['test123' ])
14061406 self .assertEqual (os .listdir (os .path .join (eb .builddir , 'test123' )), ['foobar.txt' ])
14071407
@@ -1410,8 +1410,8 @@ def test_make_builddir(self):
14101410 eb .make_builddir ()
14111411 eb .make_installdir ()
14121412 self .assertEqual (builddir , eb .builddir )
1413- self .assertFalse ( os . path . exists ( testfile ) )
1414- self .assertFalse (os .path .exists ( os . path . dirname (testfile ) ))
1413+ self .assertNotExists ( testfile )
1414+ self .assertNotExists (os .path .dirname (testfile ))
14151415 self .assertEqual (os .listdir (eb .builddir ), [])
14161416
14171417 def test_get_easyblock_instance (self ):
@@ -1421,7 +1421,7 @@ def test_get_easyblock_instance(self):
14211421
14221422 ec = process_easyconfig (os .path .join (testdir , 'easyconfigs' , 'test_ecs' , 't' , 'toy' , 'toy-0.0.eb' ))[0 ]
14231423 eb = get_easyblock_instance (ec )
1424- self .assertTrue ( isinstance ( eb , EB_toy ) )
1424+ self .assertIsInstance ( eb , EB_toy )
14251425
14261426 # check whether 'This is easyblock' log message is there
14271427 tup = ('EB_toy' , 'easybuild.easyblocks.toy' , '.*test/framework/sandbox/easybuild/easyblocks/t/toy.pyc*' )
@@ -1483,9 +1483,9 @@ def test_fetch_sources(self):
14831483 self .assertEqual (len (eb .src ), 3 )
14841484 for idx in range (3 ):
14851485 self .assertEqual (eb .src [idx ]['name' ], expected_sources [idx ])
1486- self .assertTrue ( os . path . exists ( eb .src [idx ]['path' ]) )
1486+ self .assertExists ( eb .src [idx ]['path' ])
14871487 source_loc = os .path .join (toy_source_dir , expected_sources [idx ])
1488- self .assertTrue ( os . path . exists ( source_loc ) )
1488+ self .assertExists ( source_loc )
14891489 self .assertTrue (os .path .samefile (eb .src [idx ]['path' ], source_loc ))
14901490 self .assertEqual (eb .src [0 ]['cmd' ], None )
14911491 self .assertEqual (eb .src [1 ]['cmd' ], "gunzip %s" )
@@ -1751,7 +1751,7 @@ def test_obtain_file(self):
17511751
17521752 # toy tarball was indeed re-downloaded to tmpdir
17531753 self .assertEqual (res , os .path .join (tmpdir , 't' , 'toy' , toy_tarball ))
1754- self .assertTrue (os .path .exists ( os . path . join (tmpdir , 't' , 'toy' , toy_tarball ) ))
1754+ self .assertExists (os .path .join (tmpdir , 't' , 'toy' , toy_tarball ))
17551755
17561756 # obtain_file yields error for non-existing files
17571757 fn = 'thisisclearlyanonexistingfile'
@@ -1784,7 +1784,7 @@ def test_obtain_file(self):
17841784 if res is not None :
17851785 loc = os .path .join (tmpdir , 't' , 'toy' , fn )
17861786 self .assertEqual (res , loc )
1787- self .assertTrue ( os . path . exists ( loc ), "%s file is found at %s" % ( fn , loc ) )
1787+ self .assertExists ( loc )
17881788 txt = read_file (loc )
17891789 eb_regex = re .compile ("EasyBuild: building software with ease" )
17901790 self .assertTrue (eb_regex .search (txt ), "Pattern '%s' found in: %s" % (eb_regex .pattern , txt ))
@@ -1834,7 +1834,7 @@ def test_collect_exts_file_info(self):
18341834
18351835 exts_file_info = toy_eb .collect_exts_file_info ()
18361836
1837- self .assertTrue ( isinstance ( exts_file_info , list ) )
1837+ self .assertIsInstance ( exts_file_info , list )
18381838 self .assertEqual (len (exts_file_info ), 4 )
18391839
18401840 self .assertEqual (exts_file_info [0 ], {'name' : 'ls' })
@@ -1859,7 +1859,7 @@ def test_collect_exts_file_info(self):
18591859 # location of files is missing when fetch_files is set to False
18601860 exts_file_info = toy_eb .collect_exts_file_info (fetch_files = False , verify_checksums = False )
18611861
1862- self .assertTrue ( isinstance ( exts_file_info , list ) )
1862+ self .assertIsInstance ( exts_file_info , list )
18631863 self .assertEqual (len (exts_file_info ), 4 )
18641864
18651865 self .assertEqual (exts_file_info [0 ], {'name' : 'ls' })
@@ -1898,7 +1898,7 @@ def test_obtain_file_extension(self):
18981898 ext = ExtensionEasyBlock (toy_eb , test_ext )
18991899 ext_src_path = ext .obtain_file (test_ext_src_fn )
19001900 self .assertEqual (os .path .basename (ext_src_path ), 'toy-0.0.tar.gz' )
1901- self .assertTrue ( os . path . exists ( ext_src_path ) )
1901+ self .assertExists ( ext_src_path )
19021902
19031903 def test_check_readiness (self ):
19041904 """Test check_readiness method."""
@@ -2136,7 +2136,7 @@ def test_guess_start_dir(self):
21362136 ec = process_easyconfig (os .path .join (test_easyconfigs , 't' , 'toy' , 'toy-0.0.eb' ))[0 ]
21372137
21382138 cwd = os .getcwd ()
2139- self .assertTrue ( os . path . exists ( cwd ) )
2139+ self .assertExists ( cwd )
21402140
21412141 def check_start_dir (expected_start_dir ):
21422142 """Check start dir."""
@@ -2171,7 +2171,7 @@ def test_extension_set_start_dir(self):
21712171 ec = process_easyconfig (os .path .join (test_easyconfigs , 't' , 'toy' , 'toy-0.0.eb' ))[0 ]
21722172
21732173 cwd = os .getcwd ()
2174- self .assertTrue ( os . path . exists ( cwd ) )
2174+ self .assertExists ( cwd )
21752175
21762176 def check_ext_start_dir (expected_start_dir , unpack_src = True ):
21772177 """Check start dir."""
@@ -2659,8 +2659,8 @@ def run_checks():
26592659 def test_this_is_easybuild (self ):
26602660 """Test 'this_is_easybuild' function (and get_git_revision function used by it)."""
26612661 # make sure both return a non-Unicode string
2662- self .assertTrue ( isinstance ( get_git_revision (), str ) )
2663- self .assertTrue ( isinstance ( this_is_easybuild (), str ) )
2662+ self .assertIsInstance ( get_git_revision (), str )
2663+ self .assertIsInstance ( this_is_easybuild (), str )
26642664
26652665 def test_stale_module_caches (self ):
26662666 """Test whether module caches are reset between builds."""
0 commit comments