@@ -3687,18 +3687,22 @@ def test_template_constant_dict(self):
36873687 my_arch = st .get_cpu_architecture ()
36883688
36893689 # add Java dep with version specified using a dict value
3690- toy_ec_txt += '\n ' .join ([
3691- "dependencies += [" ,
3692- " ('Python', '3.7.2'),"
3693- " ('Java', {" ,
3694- " 'arch=%s': '1.8.0_221'," % my_arch ,
3695- " 'arch=fooarch': '1.8.0-foo'," ,
3696- " })" ,
3697- "]" ,
3698- "builddependencies = [" ,
3699- " ('CMake', '3.18.4')," ,
3700- "]" ,
3701- ])
3690+ toy_ec_txt += textwrap .dedent ("""
3691+ dependencies += [
3692+ ('Python', '3.7.2'),
3693+ ('Java', {
3694+ 'arch=<arch>': '1.8.0_221',
3695+ 'arch=fooarch': '1.8.0-foo',
3696+ }),
3697+ ('Perl', {
3698+ 'arch=<arch>': False,
3699+ 'arch=fooarch': '1.42',
3700+ }),
3701+ ]
3702+ builddependencies = [
3703+ ('CMake', '3.18.4'),
3704+ ]
3705+ """ ).replace ('<arch>' , my_arch )
37023706
37033707 test_ec = os .path .join (self .test_prefix , 'test.eb' )
37043708 write_file (test_ec , toy_ec_txt )
@@ -3733,39 +3737,28 @@ def test_template_constant_dict(self):
37333737 }
37343738
37353739 # proper EasyConfig instance
3736- ec = EasyConfig (test_ec )
3737-
3738- # CMake should *not* be included, since it's a build-only dependency
3739- dep_names = [x ['name' ] for x in ec ['dependencies' ]]
3740- self .assertFalse ('CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3741- res = template_constant_dict (ec )
3742- dep_names = [x ['name' ] for x in ec ['dependencies' ]]
3743- self .assertFalse ('CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3744-
3745- self .assertIn ('arch' , res )
3746- arch = res .pop ('arch' )
3747- self .assertTrue (arch_regex .match (arch ), "'%s' matches with pattern '%s'" % (arch , arch_regex .pattern ))
3748-
3749- self .assertEqual (res , expected )
3750-
3740+ full_ec = EasyConfig (test_ec )
3741+ expected_full = expected
37513742 # only perform shallow/quick parse (as is done in list_software function)
3752- ec = EasyConfigParser (filename = test_ec ).get_config_dict ()
3753-
3754- expected ['module_name' ] = None
3743+ shallow_ec = EasyConfigParser (filename = test_ec ).get_config_dict ()
3744+ expected_shallow = expected . copy ()
3745+ expected_shallow ['module_name' ] = None
37553746 for key in ('bitbucket_account' , 'github_account' , 'versionprefix' ):
3756- del expected [key ]
3747+ del expected_shallow [key ]
37573748
3758- dep_names = [ x [ 0 ] for x in ec [ 'dependencies' ]]
3759- self . assertFalse ( 'CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3760- res = template_constant_dict ( ec )
3761- dep_names = [x [0 ] for x in ec ['dependencies' ]]
3762- self . assertFalse ( 'CMake' in dep_names , "CMake should not be included in list of dependencies: %s" % dep_names )
3749+ for name , ec , expected in (( 'Full' , full_ec , expected_full ), ( 'Shallow' , shallow_ec , expected_shallow )):
3750+ with self . subTest ( f' { name } easyconfig' ):
3751+ # CMake should *not* be included, since it's a build-only dependency
3752+ dep_names = [x [ 'name' ] if isinstance ( x , dict ) else x [0 ] for x in ec ['dependencies' ]]
3753+ self . assertNotIn ( 'CMake' , dep_names )
37633754
3764- self .assertIn ('arch' , res )
3765- arch = res .pop ('arch' )
3766- self .assertTrue (arch_regex .match (arch ), "'%s' matches with pattern '%s'" % (arch , arch_regex .pattern ))
3755+ res = template_constant_dict (ec )
3756+ self .assertIn ('arch' , res )
3757+ arch = res .pop ('arch' )
3758+ self .assertRegex (arch , arch_regex )
37673759
3768- self .assertEqual (res , expected )
3760+ self .assertNotIn ('perlver' , res , "Perl should be filtered out" )
3761+ self .assertEqual (res , expected )
37693762
37703763 # also check result of template_constant_dict when dict representing extension is passed
37713764 ext_dict = {
0 commit comments