@@ -3676,18 +3676,22 @@ def test_template_constant_dict(self):
36763676 my_arch = st .get_cpu_architecture ()
36773677
36783678 # add Java dep with version specified using a dict value
3679- toy_ec_txt += '\n ' .join ([
3680- "dependencies += [" ,
3681- " ('Python', '3.7.2'),"
3682- " ('Java', {" ,
3683- " 'arch=%s': '1.8.0_221'," % my_arch ,
3684- " 'arch=fooarch': '1.8.0-foo'," ,
3685- " })" ,
3686- "]" ,
3687- "builddependencies = [" ,
3688- " ('CMake', '3.18.4')," ,
3689- "]" ,
3690- ])
3679+ toy_ec_txt += textwrap .dedent ("""
3680+ dependencies += [
3681+ ('Python', '3.7.2'),
3682+ ('Java', {
3683+ 'arch=<arch>': '1.8.0_221',
3684+ 'arch=fooarch': '1.8.0-foo',
3685+ }),
3686+ ('Perl', {
3687+ 'arch=<arch>': False,
3688+ 'arch=fooarch': '1.42',
3689+ }),
3690+ ]
3691+ builddependencies = [
3692+ ('CMake', '3.18.4'),
3693+ ]
3694+ """ ).replace ('<arch>' , my_arch )
36913695
36923696 test_ec = os .path .join (self .test_prefix , 'test.eb' )
36933697 write_file (test_ec , toy_ec_txt )
@@ -3722,39 +3726,29 @@ def test_template_constant_dict(self):
37223726 }
37233727
37243728 # proper EasyConfig instance
3725- ec = EasyConfig (test_ec )
3726-
3727- # CMake should *not* be included, since it's a build-only dependency
3728- dep_names = [x ['name' ] for x in ec ['dependencies' ]]
3729- self .assertFalse ('CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3730- res = template_constant_dict (ec )
3731- dep_names = [x ['name' ] for x in ec ['dependencies' ]]
3732- self .assertFalse ('CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3733-
3734- self .assertIn ('arch' , res )
3735- arch = res .pop ('arch' )
3736- self .assertTrue (arch_regex .match (arch ), "'%s' matches with pattern '%s'" % (arch , arch_regex .pattern ))
3737-
3738- self .assertEqual (res , expected )
3739-
3729+ full_ec = EasyConfig (test_ec )
3730+ expected_full = expected
37403731 # only perform shallow/quick parse (as is done in list_software function)
3741- ec = EasyConfigParser (filename = test_ec ).get_config_dict ()
3742-
3743- expected ['module_name' ] = None
3732+ shallow_ec = EasyConfigParser (filename = test_ec ).get_config_dict ()
3733+ expected_shallow = expected . copy ()
3734+ expected_shallow ['module_name' ] = None
37443735 for key in ('bitbucket_account' , 'github_account' , 'versionprefix' ):
3745- del expected [key ]
3736+ del expected_shallow [key ]
37463737
3747- dep_names = [ x [ 0 ] for x in ec [ 'dependencies' ]]
3748- self . assertFalse ( 'CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3749- res = template_constant_dict ( ec )
3750- dep_names = [x [0 ] for x in ec ['dependencies' ]]
3751- self . assertFalse ( 'CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3738+ for name , ec , expected in (( 'Full' , full_ec , expected_full ), ( 'Shallow' , shallow_ec , expected_shallow )):
3739+ with self . subTest ( f' { name } easyconfig' ):
3740+ # CMake should *not* be included, since it's a build-only dependency
3741+ dep_names = [x [ 'name' ] if isinstance ( x , dict ) else x [0 ] for x in ec ['dependencies' ]]
3742+ self . assertNotIn ( 'CMake' , dep_names )
37523743
3753- self .assertIn ('arch' , res )
3754- arch = res .pop ('arch' )
3755- self .assertTrue (arch_regex .match (arch ), "'%s' matches with pattern '%s'" % (arch , arch_regex .pattern ))
3744+ res = template_constant_dict (ec )
3745+ self .assertIn ('arch' , res )
3746+ arch = res .pop ('arch' )
3747+ self .assertRegex (arch , arch_regex )
37563748
3757- self .assertEqual (res , expected )
3749+ self .assertNotIn ('perlver' , res , "Perl should be filtered out" )
3750+
3751+ self .assertEqual (res , expected )
37583752
37593753 # also check result of template_constant_dict when dict representing extension is passed
37603754 ext_dict = {
0 commit comments