diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index f7a0a25ab4..220b90e695 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -19,4 +19,4 @@ jobs: - name: Run flake8 run: | flake8 easybuild/tools - \ No newline at end of file + flake8 test/ diff --git a/test/framework/config.py b/test/framework/config.py index 63ce53700c..14d9750f25 100644 --- a/test/framework/config.py +++ b/test/framework/config.py @@ -190,8 +190,8 @@ def test_error_env_var_typo(self): os.environ['EASYBUILD_THERESNOSUCHCONFIGURATIONOPTION'] = 'whatever' error = r"Found 2 environment variable\(s\) that are prefixed with %s " % CONFIG_ENV_VAR_PREFIX - error += "but do not match valid option\(s\): " - error += ','.join(['EASYBUILD_FOO', 'EASYBUILD_THERESNOSUCHCONFIGURATIONOPTION']) + error += r"but do not match valid option\(s\): " + error += r','.join(['EASYBUILD_FOO', 'EASYBUILD_THERESNOSUCHCONFIGURATIONOPTION']) self.assertErrorRegex(EasyBuildError, error, init_config) del os.environ['EASYBUILD_THERESNOSUCHCONFIGURATIONOPTION'] @@ -365,7 +365,7 @@ def test_build_options(self): # only valid keys can be set BuildOptions.__class__._instances.clear() - msg = "Encountered unknown keys .* \(known keys: .*" + msg = r"Encountered unknown keys .* \(known keys: .*" self.assertErrorRegex(KeyError, msg, BuildOptions, {'thisisclearlynotavalidbuildoption': 'FAIL'}) # test init_build_options and build_option functions diff --git a/test/framework/containers.py b/test/framework/containers.py index b89d5882e8..3a3447e8fe 100644 --- a/test/framework/containers.py +++ b/test/framework/containers.py @@ -362,7 +362,7 @@ def test_end2end_singularity_image(self): args.append('--container-tmpdir=%s' % self.test_prefix) stdout, stderr = self.run_main(args) self.assertFalse(stderr) - regexs[-3] = "^== Running 'sudo\s*SINGULARITY_TMPDIR=%s \S*/singularity build .*" % self.test_prefix + regexs[-3] = r"^== Running 'sudo\s*SINGULARITY_TMPDIR=%s \S*/singularity build .*" % self.test_prefix self.check_regexs(regexs, stdout) def test_end2end_dockerfile(self): @@ -459,10 +459,10 @@ def test_end2end_docker_image(self): stdout, stderr = self.run_main(args) self.assertFalse(stderr) regexs = [ - "^== docker tool found at %s/bin/docker" % self.test_prefix, - "^== Dockerfile definition file created at %s/containers/Dockerfile\.toy-0.0" % self.test_prefix, - "^== Running 'sudo docker build -f .* -t .* \.', you may need to enter your 'sudo' password...", - "^== Docker image created at toy-0.0:latest", + r"^== docker tool found at %s/bin/docker" % self.test_prefix, + r"^== Dockerfile definition file created at %s/containers/Dockerfile\.toy-0.0" % self.test_prefix, + r"^== Running 'sudo docker build -f .* -t .* \.', you may need to enter your 'sudo' password...", + r"^== Docker image created at toy-0.0:latest", ] self.check_regexs(regexs, stdout) diff --git a/test/framework/docs.py b/test/framework/docs.py index 7a12ed04db..f6716ea171 100644 --- a/test/framework/docs.py +++ b/test/framework/docs.py @@ -109,7 +109,7 @@ def test_license_docs(self): self.assertTrue(gplv3 in lic_docs, "%s found in: %s" % (gplv3, lic_docs)) lic_docs = avail_easyconfig_licenses(output_format='rst') - regex = re.compile("^``GPLv3``\s*The GNU General Public License", re.M) + regex = re.compile(r"^``GPLv3``\s*The GNU General Public License", re.M) self.assertTrue(regex.search(lic_docs), "%s found in: %s" % (regex.pattern, lic_docs)) def test_list_software(self): @@ -260,7 +260,7 @@ def test_list_software(self): ] txt = list_software(output_format='txt', detailed=True) lines = txt.split('\n') - expected_found = any([lines[i:i+len(expected)] == expected for i in range(len(lines))]) + expected_found = any([lines[i:i + len(expected)] == expected for i in range(len(lines))]) self.assertTrue(expected_found, "%s found in: %s" % (expected, lines)) expected = [ @@ -283,7 +283,7 @@ def test_list_software(self): ] txt = list_software(output_format='rst', detailed=True) lines = txt.split('\n') - expected_found = any([lines[i:i+len(expected)] == expected for i in range(len(lines))]) + expected_found = any([lines[i:i + len(expected)] == expected for i in range(len(lines))]) self.assertTrue(expected_found, "%s found in: %s" % (expected, lines)) diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index 1c0caafe12..884dedbf4d 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -288,7 +288,7 @@ def test_make_module_extend_modpath(self): elif get_module_syntax() == 'Lua': regexs = [r'^prepend_path\("MODULEPATH", ".*/modules/funky/Compiler/pi/3.14/%s"\)$' % c for c in modclasses] home = r'os.getenv\("HOME"\)' - pj_usermodsdir = 'pathJoin\("%s", "funky", "Compiler/pi/3.14"\)' % usermodsdir + pj_usermodsdir = r'pathJoin\("%s", "funky", "Compiler/pi/3.14"\)' % usermodsdir regexs.extend([ # extension for user modules is guarded r'if isDir\(pathJoin\(%s, %s\)\) then' % (home, pj_usermodsdir), @@ -1061,7 +1061,7 @@ def test_make_module_step(self): # [==[ or ]==] in description is fatal if get_module_syntax() == 'Lua': - error_pattern = "Found unwanted '\[==\[' or '\]==\]' in: .*" + error_pattern = r"Found unwanted '\[==\[' or '\]==\]' in: .*" for descr in ["test [==[", "]==] foo"]: ectxt = read_file(self.eb_file) write_file(self.eb_file, re.sub('description.*', 'description = "%s"' % descr, ectxt)) @@ -1263,7 +1263,7 @@ def test_fetch_sources(self): # old format for specifying source with custom extract command is deprecated eb.src = [] - error_msg = "DEPRECATED \(since v4.0\).*Using a 2-element list/tuple.*" + error_msg = r"DEPRECATED \(since v4.0\).*Using a 2-element list/tuple.*" self.assertErrorRegex(EasyBuildError, error_msg, eb.fetch_sources, [('toy-0.0_gzip.patch.gz', "gunzip %s")], checksums=[]) diff --git a/test/framework/easyconfig.py b/test/framework/easyconfig.py index a3123d9748..1f373d812b 100644 --- a/test/framework/easyconfig.py +++ b/test/framework/easyconfig.py @@ -558,12 +558,12 @@ def test_tweaking(self): homepage = "http://www.justatest.com" tweaks = { - 'version': ver, - 'versionprefix': verpref, - 'versionsuffix': versuff, - 'toolchain_version': tcver, - 'patches': new_patches - } + 'version': ver, + 'versionprefix': verpref, + 'versionsuffix': versuff, + 'toolchain_version': tcver, + 'patches': new_patches + } tweak_one(self.eb_file, tweaked_fn, tweaks) eb = EasyConfig(tweaked_fn) @@ -939,11 +939,11 @@ def trim_path(path): def test_templating(self): """ test easyconfig templating """ inp = { - 'name': 'PI', - # purposely using minor version that starts with a 0, to check for correct version_minor value - 'version': '3.04', - 'namelower': 'pi', - 'cmd': 'tar xfvz %s', + 'name': 'PI', + # purposely using minor version that starts with a 0, to check for correct version_minor value + 'version': '3.04', + 'namelower': 'pi', + 'cmd': 'tar xfvz %s', } # don't use any escaping insanity here, since it is templated itself self.contents = '\n'.join([ @@ -1072,8 +1072,8 @@ def test_constant_doc(self): doc = avail_easyconfig_constants() # expected length: 1 per constant and 1 extra per constantgroup temps = [ - easyconfig.constants.EASYCONFIG_CONSTANTS, - ] + easyconfig.constants.EASYCONFIG_CONSTANTS, + ] self.assertEqual(len(doc.split('\n')), sum([len(temps)] + [len(x) for x in temps])) def test_build_options(self): @@ -2259,17 +2259,17 @@ def test_dump_comments(self): # check internal structure to keep track of comments self.assertEqual(ec.parser._formatter.comments['above'], { - 'dependencies': [ - '# this is a multiline comment above dependencies', - '# I said multiline', - '# multi > 3', - ], - 'sanity_check_paths': ['# how about comments above and in a dict value?'], - 'source_urls': ['# how about # a comment with # multple additional hashes'], - 'sources': ['# after toolchain, before sources comment', - '', - '# this comment contains another #, uh-oh...'], - 'version': ["# the version doesn't matter much here"], + 'dependencies': [ + '# this is a multiline comment above dependencies', + '# I said multiline', + '# multi > 3', + ], + 'sanity_check_paths': ['# how about comments above and in a dict value?'], + 'source_urls': ['# how about # a comment with # multple additional hashes'], + 'sources': ['# after toolchain, before sources comment', + '', + '# this comment contains another #, uh-oh...'], + 'version': ["# the version doesn't matter much here"], }) self.assertEqual(ec.parser._formatter.comments['header'], [ '# this is a header', diff --git a/test/framework/easyconfigversion.py b/test/framework/easyconfigversion.py index 2fc9b0c60f..8649a3812d 100644 --- a/test/framework/easyconfigversion.py +++ b/test/framework/easyconfigversion.py @@ -114,10 +114,10 @@ def test_versop_overlap_conflict(self): ('> 2 suffix:-x1', '< 1 suffix:-x1', (False, False)), # suffix equal, no conflict (and no overlap) ] - for l, r, res in overlap_conflict: - vl = VersionOperator(l) - vr = VersionOperator(r) - self.assertEqual(vl.test_overlap_and_conflict(vr), res) + for left, right, res in overlap_conflict: + verop_left = VersionOperator(left) + verop_right = VersionOperator(right) + self.assertEqual(verop_left.test_overlap_and_conflict(verop_right), res) def test_versop_gt(self): """Test strict greater then ordering""" @@ -135,8 +135,8 @@ def test_versop_gt(self): # suffix ('> 2 suffix:-x1', '> 1 suffix:-x1'), # equal suffixes, regular ordering ] - for l, r in left_gt_right: - self.assertTrue(VersionOperator(l) > VersionOperator(r), "%s gt %s" % (l, r)) + for left, right in left_gt_right: + self.assertTrue(VersionOperator(left) > VersionOperator(right), "%s gt %s" % (left, right)) def test_ordered_versop_expressions(self): """Given set of ranges, order them according to version/operator (most recent/specific first)""" @@ -215,7 +215,7 @@ def test_toolchain_versop_test(self): (tc, '1.2.2', False), # version not ok, name ok ('x' + tc, '1.2.3', False), # version ok, name not ok ('x' + tc, '1.2.2', False), # version not ok, name not ok - )), + )), ] for txt, subtests in tests: tcversop = ToolchainVersionOperator(txt) diff --git a/test/framework/filetools.py b/test/framework/filetools.py index bd9c22cd2d..5931bac379 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -171,7 +171,6 @@ def test_find_glob_pattern(self): self.assertErrorRegex(EasyBuildError, "Was expecting exactly", ft.find_glob_pattern, os.path.join(tmpdir, 'python*')) - def test_encode_class_name(self): """Test encoding of class names.""" for (class_name, encoded_class_name) in self.class_names: @@ -929,7 +928,7 @@ def test_multidiff(self): expected = "29 %s+ postinstallcmds = " % green self.assertTrue(any([line.startswith(expected) for line in lines])) expected = "30 %s+%s (1/2) toy-0.0" % (green, endcol) - self.assertTrue(any(l.startswith(expected) for l in lines), "Found '%s' in: %s" % (expected, lines)) + self.assertTrue(any(line.startswith(expected) for line in lines), "Found '%s' in: %s" % (expected, lines)) self.assertEqual(lines[-1], "=====") lines = multidiff(toy_ec, other_toy_ecs, colored=False).split('\n') @@ -948,9 +947,9 @@ def test_multidiff(self): # no postinstallcmds in toy-0.0-deps.eb expected = "29 + postinstallcmds = " - self.assertTrue(any(l.startswith(expected) for l in lines), "Found '%s' in: %s" % (expected, lines)) + self.assertTrue(any(line.startswith(expected) for line in lines), "Found '%s' in: %s" % (expected, lines)) expected = "30 + (1/2) toy-0.0-" - self.assertTrue(any(l.startswith(expected) for l in lines), "Found '%s' in: %s" % (expected, lines)) + self.assertTrue(any(line.startswith(expected) for line in lines), "Found '%s' in: %s" % (expected, lines)) self.assertEqual(lines[-1], "=====") diff --git a/test/framework/general.py b/test/framework/general.py index 0f2227226e..07e8c36011 100644 --- a/test/framework/general.py +++ b/test/framework/general.py @@ -49,9 +49,9 @@ def test_error_reporting(self): easybuild_loc = os.path.dirname(os.path.dirname(os.path.abspath(easybuild.framework.__file__))) log_method_regexes = [ - re.compile("log\.error\("), - re.compile("log\.exception\("), - re.compile("log\.raiseException\("), + re.compile(r"log\.error\("), + re.compile(r"log\.exception\("), + re.compile(r"log\.raiseException\("), ] for dirpath, _, filenames in os.walk(easybuild_loc): diff --git a/test/framework/github.py b/test/framework/github.py index 8ff3f212c4..8885a04069 100644 --- a/test/framework/github.py +++ b/test/framework/github.py @@ -87,9 +87,11 @@ def test_walk(self): return try: - expected = [(None, ['a_directory', 'second_dir'], ['README.md']), - ('a_directory', ['a_subdirectory'], ['a_file.txt']), ('a_directory/a_subdirectory', [], - ['a_file.txt']), ('second_dir', [], ['a_file.txt'])] + expected = [ + (None, ['a_directory', 'second_dir'], ['README.md']), + ('a_directory', ['a_subdirectory'], ['a_file.txt']), + ('a_directory/a_subdirectory', [], ['a_file.txt']), ('second_dir', [], ['a_file.txt']), + ] self.assertEqual([x for x in self.ghfs.walk(None)], expected) except IOError: pass @@ -432,7 +434,7 @@ def test_find_easybuild_easyconfig(self): print("Skipping test_find_easybuild_easyconfig, no GitHub token available?") return path = gh.find_easybuild_easyconfig(github_user=GITHUB_TEST_ACCOUNT) - expected = os.path.join('e', 'EasyBuild', 'EasyBuild-[1-9]+\.[0-9]+\.[0-9]+\.eb') + expected = os.path.join('e', 'EasyBuild', r'EasyBuild-[1-9]+\.[0-9]+\.[0-9]+\.eb') regex = re.compile(expected) self.assertTrue(regex.search(path), "Pattern '%s' found in '%s'" % (regex.pattern, path)) self.assertTrue(os.path.exists(path), "Path %s exists" % path) @@ -618,9 +620,9 @@ def test_det_patch_specs(self): patch_paths = [os.path.join(self.test_prefix, p) for p in ['1.patch', '2.patch', '3.patch']] file_info = {'ecs': [ - {'name': 'A', 'patches': ['1.patch'], 'exts_list': []}, - {'name': 'B', 'patches': [], 'exts_list': []}, - ] + {'name': 'A', 'patches': ['1.patch'], 'exts_list': []}, + {'name': 'B', 'patches': [], 'exts_list': []}, + ] } error_pattern = "Failed to determine software name to which patch file .*/2.patch relates" self.mock_stdout(True) diff --git a/test/framework/include.py b/test/framework/include.py index 9bf791e50e..16dd73986e 100644 --- a/test/framework/include.py +++ b/test/framework/include.py @@ -41,7 +41,7 @@ def up(path, cnt): """Return path N times up.""" if cnt > 0: - path = up(os.path.dirname(path), cnt-1) + path = up(os.path.dirname(path), cnt - 1) return path diff --git a/test/framework/lib.py b/test/framework/lib.py index ae11225828..5f8f1a82b5 100644 --- a/test/framework/lib.py +++ b/test/framework/lib.py @@ -79,8 +79,8 @@ def configure(self): def test_run_cmd(self): """Test use of run_cmd function in the context of using EasyBuild framework as a library.""" - error_pattern = "Undefined build option: .*" - error_pattern += " Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" + error_pattern = r"Undefined build option: .*" + error_pattern += r" Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" self.assertErrorRegex(EasyBuildError, error_pattern, run_cmd, "echo hello") self.configure() @@ -95,8 +95,8 @@ def test_mkdir(self): test_dir = os.path.join(self.tmpdir, 'test123') - error_pattern = "Undefined build option: .*" - error_pattern += " Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" + error_pattern = r"Undefined build option: .*" + error_pattern += r" Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" self.assertErrorRegex(EasyBuildError, error_pattern, mkdir, test_dir) self.configure() @@ -109,8 +109,8 @@ def test_mkdir(self): def test_modules_tool(self): """Test use of modules_tool function in the context of using EasyBuild framework as a library.""" - error_pattern = "Undefined build option: .*" - error_pattern += " Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" + error_pattern = r"Undefined build option: .*" + error_pattern += r" Make sure you have set up the EasyBuild configuration using set_up_configuration\(\)" self.assertErrorRegex(EasyBuildError, error_pattern, modules_tool) self.configure() diff --git a/test/framework/module_generator.py b/test/framework/module_generator.py index 439091a3a3..f381baee36 100644 --- a/test/framework/module_generator.py +++ b/test/framework/module_generator.py @@ -1327,11 +1327,11 @@ def test_ec(ecfile, short_modname, mod_subdir, modpath_exts, user_modpath_exts, init_config(build_options=build_options) test_ecs = { - 'GCC-6.4.0-2.28.eb': ('compiler/GCC/6.4.0-2.28', '', [], [], []), + 'GCC-6.4.0-2.28.eb': ('compiler/GCC/6.4.0-2.28', '', [], [], []), 'OpenMPI-2.1.2-GCC-6.4.0-2.28.eb': ('mpi/OpenMPI/2.1.2-GCC-6.4.0-2.28', '', [], [], []), - 'gzip-1.5-foss-2018a.eb': ('tools/gzip/1.5-foss-2018a', '', [], [], []), - 'foss-2018a.eb': ('toolchain/foss/2018a', '', [], [], []), - 'impi-5.1.2.150.eb': ('mpi/impi/5.1.2.150', '', [], [], []), + 'gzip-1.5-foss-2018a.eb': ('tools/gzip/1.5-foss-2018a', '', [], [], []), + 'foss-2018a.eb': ('toolchain/foss/2018a', '', [], [], []), + 'impi-5.1.2.150.eb': ('mpi/impi/5.1.2.150', '', [], [], []), } for ecfile, mns_vals in test_ecs.items(): test_ec(ecfile, *mns_vals) diff --git a/test/framework/modules.py b/test/framework/modules.py index 521159ec6c..07a8d2ffb2 100644 --- a/test/framework/modules.py +++ b/test/framework/modules.py @@ -360,10 +360,10 @@ def test_exist(self): remove_file(os.path.join(java_mod_dir, '.modulerc')) write_file(os.path.join(java_mod_dir, '.modulerc.lua'), '\n'.join([ - 'module_version("Java/1.8.0_181", "1.8")', - 'module_version("Java/1.8.0_181", "site_default")', - 'module_alias("JavaAlias", "Java/1.8")', - ])) + 'module_version("Java/1.8.0_181", "1.8")', + 'module_version("Java/1.8.0_181", "site_default")', + 'module_alias("JavaAlias", "Java/1.8")', + ])) avail_mods = self.modtool.available() self.assertTrue('Java/1.8.0_181' in avail_mods) diff --git a/test/framework/options.py b/test/framework/options.py index f1e57ede24..93f061a05f 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -126,12 +126,12 @@ def test_help_short(self, txt=None): if txt is None: topt = EasyBuildOptions( - go_args=['-h'], - go_nosystemexit=True, # when printing help, optparse ends with sys.exit - go_columns=100, # fix col size for reproducible unittest output - help_to_string=True, # don't print to stdout, but to StingIO fh, - prog='easybuildoptions_test', # generate as if called from generaloption.py - ) + go_args=['-h'], + go_nosystemexit=True, # when printing help, optparse ends with sys.exit + go_columns=100, # fix col size for reproducible unittest output + help_to_string=True, # don't print to stdout, but to StingIO fh, + prog='easybuildoptions_test', # generate as if called from generaloption.py + ) outtxt = topt.parser.help_to_file.getvalue() else: @@ -149,12 +149,12 @@ def test_help_long(self): """Test long help message.""" topt = EasyBuildOptions( - go_args=['-H'], - go_nosystemexit=True, # when printing help, optparse ends with sys.exit - go_columns=200, # fix col size for reproducible unittest output - help_to_string=True, # don't print to stdout, but to StingIO fh, - prog='easybuildoptions_test', # generate as if called from generaloption.py - ) + go_args=['-H'], + go_nosystemexit=True, # when printing help, optparse ends with sys.exit + go_columns=200, # fix col size for reproducible unittest output + help_to_string=True, # don't print to stdout, but to StingIO fh, + prog='easybuildoptions_test', # generate as if called from generaloption.py + ) outtxt = topt.parser.help_to_file.getvalue() self.assertTrue(re.search("-H OUTPUT_FORMAT, --help=OUTPUT_FORMAT", outtxt), @@ -199,9 +199,9 @@ def test_info(self): for info_arg in ['--info']: args = [ - 'nosuchfile.eb', - info_arg, - ] + 'nosuchfile.eb', + info_arg, + ] outtxt = self.eb_main(args) error_tmpl = "%s log messages are included when using %s ( out: %s)" @@ -237,9 +237,9 @@ def test_force(self): # check log message without --force args = [ - eb_file, - '--debug', - ] + eb_file, + '--debug', + ] outtxt, error_thrown = self.eb_main(args, return_error=True) error_msg = "No error is thrown if software is already installed (error_thrown: %s)" % error_thrown @@ -318,7 +318,7 @@ def test_skip(self): # make sure that sanity check is *NOT* skipped under --skip test_ec = os.path.join(self.test_prefix, 'test.eb') test_ec_txt = read_file(toy_ec) - regex = re.compile("sanity_check_paths = \{(.|\n)*\}", re.M) + regex = re.compile(r"sanity_check_paths = \{(.|\n)*\}", re.M) test_ec_txt = regex.sub("sanity_check_paths = {'files': ['bin/nosuchfile'], 'dirs': []}", test_ec_txt) write_file(test_ec, test_ec_txt) args = [ @@ -351,12 +351,12 @@ def check_args(job_args, passed_args=None): write_file(self.logfile, '') args = [ - eb_file, - '--job', - ] + job_args + eb_file, + '--job', + ] + job_args outtxt = self.eb_main(args) - job_msg = "INFO.* Command template for jobs: .* && eb %%\(spec\)s.* %s.*\n" % ' .*'.join(passed_args) + job_msg = r"INFO.* Command template for jobs: .* && eb %%\(spec\)s.* %s.*\n" % ' .*'.join(passed_args) assertmsg = "Info log msg with job command template for --job (job_msg: %s, outtxt: %s)" % (job_msg, outtxt) self.assertTrue(re.search(job_msg, outtxt), assertmsg) @@ -501,7 +501,7 @@ def run_test(custom=None, extra_params=[], fmt=None): param_start = 0 for param in params: # regex for parameter name (with optional '*') & description, matches both txt and rst formats - regex = re.compile("^[`]*%s(?:\*)?[`]*\s+\w+" % param, re.M) + regex = re.compile(r"^[`]*%s(?:\*)?[`]*\s+\w+" % param, re.M) tup = (param, avail_arg, args, regex.pattern, logtxt) msg = "Parameter %s is listed with help in output of eb %s (args: %s, regex: %s): %s" % tup res = regex.search(logtxt) @@ -529,9 +529,9 @@ def test__list_toolchains(self): os.close(fd) args = [ - '--list-toolchains', - '--unittest-file=%s' % self.logfile, - ] + '--list-toolchains', + '--unittest-file=%s' % self.logfile, + ] self.eb_main(args, logfile=dummylogfn, raise_error=True) info_msg = r"INFO List of known toolchains \(toolchainname: module\[,module\.\.\.\]\):" @@ -544,7 +544,7 @@ def test__list_toolchains(self): 'intel': ['icc', 'ifort', 'imkl', 'impi'], } for tc, tcelems in tcs.items(): - res = re.findall("^\s*%s: .*" % tc, logtxt, re.M) + res = re.findall(r"^\s*%s: .*" % tc, logtxt, re.M) self.assertTrue(res, "Toolchain %s is included in list of known compiler toolchains" % tc) # every toolchain should only be mentioned once n = len(res) @@ -619,9 +619,9 @@ def test_avail_lists(self): } for (name, items) in name_items.items(): args = [ - '--avail-%s' % name, - '--unittest-file=%s' % self.logfile, - ] + '--avail-%s' % name, + '--unittest-file=%s' % self.logfile, + ] self.eb_main(args, logfile=dummylogfn) logtxt = read_file(self.logfile) @@ -629,7 +629,7 @@ def test_avail_lists(self): info_msg = r"INFO List of supported %s:" % words self.assertTrue(re.search(info_msg, logtxt), "Info message with list of available %s" % words) for item in items: - res = re.findall("^\s*%s" % item, logtxt, re.M) + res = re.findall(r"^\s*%s" % item, logtxt, re.M) self.assertTrue(res, "%s is included in list of available %s" % (item, words)) # every item should only be mentioned once n = len(res) @@ -685,9 +685,9 @@ def test_list_easyblocks(self): write_file(self.logfile, '') args = [ - list_arg, - '--unittest-file=%s' % self.logfile, - ] + list_arg, + '--unittest-file=%s' % self.logfile, + ] self.eb_main(args, logfile=dummylogfn) logtxt = read_file(self.logfile) @@ -726,9 +726,9 @@ def test_list_easyblocks(self): # detailed view args = [ - '--list-easyblocks=detailed', - '--unittest-file=%s' % self.logfile, - ] + '--list-easyblocks=detailed', + '--unittest-file=%s' % self.logfile, + ] self.eb_main(args, logfile=dummylogfn) logtxt = read_file(self.logfile) @@ -829,7 +829,7 @@ def test_search(self): txt = self.get_stdout() self.mock_stdout(False) - self.assertTrue(re.search('^CFGS\d+=', txt, re.M), "CFGS line message found in '%s'" % txt) + self.assertTrue(re.search(r'^CFGS\d+=', txt, re.M), "CFGS line message found in '%s'" % txt) for ec in ["toy-0.0.eb", "toy-0.0-multiple.eb"]: regex = re.compile(r" \* \$CFGS\d+/*%s" % ec, re.M) self.assertTrue(regex.search(txt), "Found pattern '%s' in: %s" % (regex.pattern, txt)) @@ -1228,7 +1228,7 @@ def test_try_robot_force(self): ("FFTW-3.3.7-gompi-2018b.eb", "FFTW/3.3.7-gompi-2018b", 'F'), ] for ec, mod, mark in ecs_mods: - regex = re.compile("^ \* \[%s\] \S+%s \(module: %s\)$" % (mark, ec, mod), re.M) + regex = re.compile(r"^ \* \[%s\] \S+%s \(module: %s\)$" % (mark, ec, mod), re.M) self.assertTrue(regex.search(outtxt), "Found match for pattern %s in '%s'" % (regex.pattern, outtxt)) def test_try_toolchain_mapping(self): @@ -1399,7 +1399,7 @@ def test_dry_run_hierarchical(self): ("gzip-1.5-foss-2018a.eb", "MPI/GCC/6.4.0-2.28/OpenMPI/2.1.2", "gzip/1.5", ' '), ] for ec, mod_subdir, mod_name, mark in ecs_mods: - regex = re.compile("^ \* \[%s\] \S+%s \(module: %s \| %s\)$" % (mark, ec, mod_subdir, mod_name), re.M) + regex = re.compile(r"^ \* \[%s\] \S+%s \(module: %s \| %s\)$" % (mark, ec, mod_subdir, mod_name), re.M) self.assertTrue(regex.search(outtxt), "Found match for pattern %s in '%s'" % (regex.pattern, outtxt)) if os.path.exists(dummylogfn): @@ -1440,7 +1440,7 @@ def test_dry_run_categorized(self): ("gzip-1.5-foss-2018a.eb", "MPI/GCC/6.4.0-2.28/OpenMPI/2.1.2/tools", "gzip/1.5", ' '), ] for ec, mod_subdir, mod_name, mark in ecs_mods: - regex = re.compile("^ \* \[%s\] \S+%s \(module: %s \| %s\)$" % (mark, ec, mod_subdir, mod_name), re.M) + regex = re.compile(r"^ \* \[%s\] \S+%s \(module: %s \| %s\)$" % (mark, ec, mod_subdir, mod_name), re.M) self.assertTrue(regex.search(outtxt), "Found match for pattern %s in '%s'" % (regex.pattern, outtxt)) if os.path.exists(dummylogfn): @@ -1633,10 +1633,10 @@ def test_no_such_software(self): """Test using no arguments.""" args = [ - '--software-name=nosuchsoftware', - '--robot=.', - '--debug', - ] + '--software-name=nosuchsoftware', + '--robot=.', + '--debug', + ] outtxt = self.eb_main(args) # error message when template is not found @@ -1802,7 +1802,7 @@ def test_ignore_osdeps(self): regex = re.compile("Checking OS dependencies") self.assertTrue(regex.search(outtxt), "OS dependencies are checked, outtxt: %s" % outtxt) msg = "One or more OS dependencies were not found: " - msg += "\[\('nosuchosdependency',\), \('nosuchdep_option1', 'nosuchdep_option2'\)\]" + msg += r"\[\('nosuchosdependency',\), \('nosuchdep_option1', 'nosuchdep_option2'\)\]" regex = re.compile(r'%s' % msg, re.M) self.assertTrue(regex.search(outtxt), "OS dependencies are honored, outtxt: %s" % outtxt) @@ -2023,7 +2023,7 @@ def test_try(self): for extra_args, mod in test_cases: outtxt = self.eb_main(args + extra_args, verbose=True, raise_error=True) - mod_regex = re.compile("\(module: %s\)$" % mod, re.M) + mod_regex = re.compile(r"\(module: %s\)$" % mod, re.M) self.assertTrue(mod_regex.search(outtxt), "Pattern %s found in %s" % (mod_regex.pattern, outtxt)) for extra_arg in ['--try-software=foo', '--try-toolchain=gompi', '--try-toolchain=gomp,2018a,-a-suffix']: @@ -2179,7 +2179,6 @@ def test_recursive_try(self): mod_regex = re.compile(r"\(module: %s\)$" % mod, re.M) self.assertFalse(mod_regex.search(outtxt), "Pattern %s found in %s" % (mod_regex.pattern, outtxt)) - def test_cleanup_builddir(self): """Test cleaning up of build dir and --disable-cleanup-builddir.""" toy_ec = os.path.join(os.path.dirname(__file__), 'easyconfigs', 'test_ecs', 't', 'toy', 'toy-0.0.eb') @@ -2378,8 +2377,8 @@ def test_hide_toolchains(self): '--hide-toolchains=GCC', ] outtxt = self.eb_main(args) - self.assertTrue(re.search('module: GCC/\.4\.9\.2', outtxt)) - self.assertTrue(re.search('module: gzip/1\.6-GCC-4\.9\.2', outtxt)) + self.assertTrue(re.search(r'module: GCC/\.4\.9\.2', outtxt)) + self.assertTrue(re.search(r'module: gzip/1\.6-GCC-4\.9\.2', outtxt)) def test_test_report_env_filter(self): """Test use of --test-report-env-filter.""" @@ -2447,7 +2446,7 @@ def test_robot(self): eb_file, '--robot-paths=%s' % test_ecs_path, ] - error_regex = "Missing modules for dependencies .*: toy/\.0.0-deps" + error_regex = r"Missing modules for dependencies .*: toy/\.0.0-deps" self.assertErrorRegex(EasyBuildError, error_regex, self.eb_main, args, raise_error=True, do_build=True) # enable robot, but without passing path required to resolve toy dependency => FAIL @@ -3204,7 +3203,7 @@ def check_tmpdir(tmpdir): mytmpdir = set_tmpdir(tmpdir=tmpdir) - parent = re.sub('[^\w/.-]', 'X', parent) + parent = re.sub(r'[^\w/.-]', 'X', parent) for var in ['TMPDIR', 'TEMP', 'TMP']: self.assertTrue(os.environ[var].startswith(os.path.join(parent, 'eb-'))) @@ -3270,8 +3269,8 @@ def test_minimal_toolchains(self): txt = self.get_stdout() self.mock_stdout(False) comp = 'Compiler/GCC/6.4.0-2.28' - sqlite_regex = re.compile("hwloc-1.11.8-GCC-6.4.0-2.28.eb \(module: %s \| hwloc/" % comp, re.M) - sqlite_regex = re.compile("SQLite-3.8.10.2-GCC-6.4.0-2.28.eb \(module: %s \| SQLite/" % comp, re.M) + sqlite_regex = re.compile(r"hwloc-1.11.8-GCC-6.4.0-2.28.eb \(module: %s \| hwloc/" % comp, re.M) + sqlite_regex = re.compile(r"SQLite-3.8.10.2-GCC-6.4.0-2.28.eb \(module: %s \| SQLite/" % comp, re.M) self.assertTrue(sqlite_regex.search(txt), "Pattern '%s' found in: %s" % (sqlite_regex.pattern, txt)) def test_extended_dry_run(self): @@ -3478,7 +3477,6 @@ def test_new_branch_github(self): ] self._assert_regexs(regexs, txt) - def test_new_pr_from_branch(self): """Test --new-pr-from-branch.""" if self.github_token is None: @@ -3704,7 +3702,7 @@ def test_new_update_pr(self): args.append('--pr-commit-msg=this is just a test') txt, _ = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False) - regex = re.compile('^\* title: "this is just a test"', re.M) + regex = re.compile(r'^\* title: "this is just a test"', re.M) self.assertTrue(regex.search(txt), "Pattern '%s' is found in: %s" % (regex.pattern, txt)) args = [ @@ -3752,9 +3750,9 @@ def test_new_update_pr(self): # check whether comments/buildstats get filtered out regexs = [ - "# Built with EasyBuild", - "# Build statistics", - "buildstats\s*=", + r"# Built with EasyBuild", + r"# Build statistics", + r"buildstats\s*=", ] self._assert_regexs(regexs, txt, assert_true=False) @@ -4143,9 +4141,9 @@ def test_show_config_cfg_levels(self): stdout, _ = self._run_mock_eb(args, raise_error=True, redo_init_config=False) patterns = [ - "^# Current EasyBuild configuration", - "^module-syntax\s*\(C\) = Tcl", - "^modules-tool\s*\(E\) = EnvironmentModulesC", + r"^# Current EasyBuild configuration", + r"^module-syntax\s*\(C\) = Tcl", + r"^modules-tool\s*\(E\) = EnvironmentModulesC", ] for pattern in patterns: regex = re.compile(pattern, re.M) @@ -4165,9 +4163,9 @@ def test_modules_tool_vs_syntax_check(self): self.assertErrorRegex(EasyBuildError, error_pattern, self._run_mock_eb, args, raise_error=True) patterns = [ - "^# Current EasyBuild configuration", - "^module-syntax\s*\(C\) = Tcl", - "^modules-tool\s*\(E\) = EnvironmentModulesC", + r"^# Current EasyBuild configuration", + r"^module-syntax\s*\(C\) = Tcl", + r"^modules-tool\s*\(E\) = EnvironmentModulesC", ] # EnvironmentModulesC modules tool + Tcl module syntax is fine @@ -4179,7 +4177,7 @@ def test_modules_tool_vs_syntax_check(self): # default modules tool (Lmod) with Tcl module syntax is also fine del os.environ['EASYBUILD_MODULES_TOOL'] - patterns[-1] = "^modules-tool\s*\(D\) = Lmod" + patterns[-1] = r"^modules-tool\s*\(D\) = Lmod" stdout, _ = self._run_mock_eb(args, do_build=True, raise_error=True, testing=False, redo_init_config=False) for pattern in patterns: regex = re.compile(pattern, re.M) @@ -4189,7 +4187,7 @@ def test_prefix(self): """Test which configuration settings are affected by --prefix.""" txt, _ = self._run_mock_eb(['--show-full-config', '--prefix=%s' % self.test_prefix], raise_error=True) - regex = re.compile("(?P\S*).*%s.*" % self.test_prefix, re.M) + regex = re.compile(r"(?P\S*).*%s.*" % self.test_prefix, re.M) expected = ['buildpath', 'containerpath', 'installpath', 'packagepath', 'prefix', 'repositorypath'] self.assertEqual(sorted(regex.findall(txt)), expected) @@ -4275,7 +4273,7 @@ def test_fetch(self): regex = re.compile(pattern, re.M) self.assertTrue(regex.search(stdout), "Pattern '%s' not found in: %s" % (regex.pattern, stdout)) - regex = re.compile("^== creating build dir, resetting environment\.\.\.$") + regex = re.compile(r"^== creating build dir, resetting environment\.\.\.$") self.assertFalse(regex.search(stdout), "Pattern '%s' found in: %s" % (regex.pattern, stdout)) def test_parse_external_modules_metadata(self): @@ -4429,19 +4427,19 @@ def test_use_color(self): def test_list_prs(self): """Test --list-prs.""" args = ['--list-prs', 'foo'] - error_msg = "must be one of \['open', 'closed', 'all'\]" + error_msg = r"must be one of \['open', 'closed', 'all'\]" self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True) args = ['--list-prs', 'open,foo'] - error_msg = "must be one of \['created', 'updated', 'popularity', 'long-running'\]" + error_msg = r"must be one of \['created', 'updated', 'popularity', 'long-running'\]" self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True) args = ['--list-prs', 'open,created,foo'] - error_msg = "must be one of \['asc', 'desc'\]" + error_msg = r"must be one of \['asc', 'desc'\]" self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True) args = ['--list-prs', 'open,created,asc,foo'] - error_msg = "must be in the format 'state\[,order\[,direction\]\]" + error_msg = r"must be in the format 'state\[,order\[,direction\]\]" self.assertErrorRegex(EasyBuildError, error_msg, self.eb_main, args, raise_error=True) args = ['--list-prs', 'closed,updated,asc'] @@ -4928,17 +4926,17 @@ def test_inject_checksums(self): bar_patch_bis = 'bar-0.0_fix-very-silly-typo-in-printf-statement.patch' bar_patch_bis_sha256 = 'd0bf102f9c5878445178c5f49b7cd7546e704c33fe2060c7354b7e473cfeb52b' patterns = [ - "^== injecting sha256 checksums in .*/test\.eb$", - "^== fetching sources & patches for test\.eb\.\.\.$", - "^== backup of easyconfig file saved to .*/test\.eb\.bak_[0-9]+_[0-9]+\.\.\.$", - "^== injecting sha256 checksums for sources & patches in test\.eb\.\.\.$", - "^== \* toy-0.0\.tar\.gz: %s$" % toy_source_sha256, - "^== \* toy-0\.0_fix-silly-typo-in-printf-statement\.patch: %s$" % toy_patch_sha256, - "^== injecting sha256 checksums for extensions in test\.eb\.\.\.$", - "^== \* bar-0\.0\.tar\.gz: %s$" % bar_tar_gz_sha256, - "^== \* %s: %s$" % (bar_patch, bar_patch_sha256), - "^== \* %s: %s$" % (bar_patch_bis, bar_patch_bis_sha256), - "^== \* barbar-0\.0\.tar\.gz: a33100d1837d6d54edff7d19f195056c4bd9a4c8d399e72feaf90f0216c4c91c$", + r"^== injecting sha256 checksums in .*/test\.eb$", + r"^== fetching sources & patches for test\.eb\.\.\.$", + r"^== backup of easyconfig file saved to .*/test\.eb\.bak_[0-9]+_[0-9]+\.\.\.$", + r"^== injecting sha256 checksums for sources & patches in test\.eb\.\.\.$", + r"^== \* toy-0.0\.tar\.gz: %s$" % toy_source_sha256, + r"^== \* toy-0\.0_fix-silly-typo-in-printf-statement\.patch: %s$" % toy_patch_sha256, + r"^== injecting sha256 checksums for extensions in test\.eb\.\.\.$", + r"^== \* bar-0\.0\.tar\.gz: %s$" % bar_tar_gz_sha256, + r"^== \* %s: %s$" % (bar_patch, bar_patch_sha256), + r"^== \* %s: %s$" % (bar_patch_bis, bar_patch_bis_sha256), + r"^== \* barbar-0\.0\.tar\.gz: a33100d1837d6d54edff7d19f195056c4bd9a4c8d399e72feaf90f0216c4c91c$", ] for pattern in patterns: regex = re.compile(pattern, re.M) @@ -5041,7 +5039,7 @@ def test_inject_checksums(self): toy_ec_txt = read_file(toy_ec) # get rid of existing checksums - regex = re.compile('^checksums(?:.|\n)*?\]\s*$', re.M) + regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M) toy_ec_txt = regex.sub('', toy_ec_txt) self.assertFalse('checksums = ' in toy_ec_txt) @@ -5051,13 +5049,13 @@ def test_inject_checksums(self): stdout, stderr = self._run_mock_eb(args, raise_error=True, strip=True) patterns = [ - "^== injecting md5 checksums in .*/test\.eb$", - "^== fetching sources & patches for test\.eb\.\.\.$", - "^== backup of easyconfig file saved to .*/test\.eb\.bak_[0-9]+_[0-9]+\.\.\.$", - "^== injecting md5 checksums for sources & patches in test\.eb\.\.\.$", - "^== \* toy-0.0\.tar\.gz: be662daa971a640e40be5c804d9d7d10$", + r"^== injecting md5 checksums in .*/test\.eb$", + r"^== fetching sources & patches for test\.eb\.\.\.$", + r"^== backup of easyconfig file saved to .*/test\.eb\.bak_[0-9]+_[0-9]+\.\.\.$", + r"^== injecting md5 checksums for sources & patches in test\.eb\.\.\.$", + r"^== \* toy-0.0\.tar\.gz: be662daa971a640e40be5c804d9d7d10$", r"^== \* toy-0\.0_fix-silly-typo-in-printf-statement\.patch: a99f2a72cee1689a2f7e3ace0356efb1$", - "^== \* toy-extra\.txt: 3b0787b3bf36603ae1398c4a49097893$", + r"^== \* toy-extra\.txt: 3b0787b3bf36603ae1398c4a49097893$", ] for pattern in patterns: regex = re.compile(pattern, re.M) @@ -5112,7 +5110,7 @@ def test_force_download(self): ] stdout, stderr = self._run_mock_eb(args, do_build=True, raise_error=True, verbose=True, strip=True) self.assertEqual(stdout, '') - regex = re.compile("^WARNING: Found file toy-0.0.tar.gz at .*, but re-downloading it anyway\.\.\.$") + regex = re.compile(r"^WARNING: Found file toy-0.0.tar.gz at .*, but re-downloading it anyway\.\.\.$") self.assertTrue(regex.match(stderr), "Pattern '%s' matches: %s" % (regex.pattern, stderr)) # check that existing source tarball was backed up @@ -5134,7 +5132,7 @@ def test_enforce_checksums(self): # checksum is missing for patch of 'bar' extension, so --enforce-checksums should result in an error copy_file(toy_ec, test_ec) - error_pattern = "Missing checksum for bar-0.0[^ ]*\.patch" + error_pattern = r"Missing checksum for bar-0.0[^ ]*\.patch" self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True) # get rid of checksums for extensions, should result in different error message @@ -5143,13 +5141,13 @@ def test_enforce_checksums(self): test_ec_txt = regex.sub('', read_file(test_ec)) self.assertFalse("'checksums':" in test_ec_txt) write_file(test_ec, test_ec_txt) - error_pattern = "Missing checksum for bar-0\.0\.tar\.gz" + error_pattern = r"Missing checksum for bar-0\.0\.tar\.gz" self.assertErrorRegex(EasyBuildError, error_pattern, self.eb_main, args, do_build=True, raise_error=True) # wipe both exts_list and checksums, so we can check whether missing checksum for main source is caught test_ec_txt = read_file(test_ec) for param in ['checksums', 'exts_list']: - regex = re.compile('^%s(?:.|\n)*?\]\s*$' % param, re.M) + regex = re.compile(r'^%s(?:.|\n)*?\]\s*$' % param, re.M) test_ec_txt = regex.sub('', test_ec_txt) self.assertFalse('%s = ' % param in test_ec_txt) @@ -5161,24 +5159,24 @@ def test_show_system_info(self): """Test for --show-system-info.""" txt, _ = self._run_mock_eb(['--show-system-info'], raise_error=True) patterns = [ - "^System information \(.*\):$", - "^\* OS:$", - "^ -> name: ", - "^ -> type: ", - "^ -> version: ", - "^ -> platform name: ", - "^\* CPU:$", - "^ -> vendor: ", - "^ -> architecture: ", - "^ -> family: ", - "^ -> model: ", - "^ -> speed: [0-9.]+", - "^ -> cores: [0-9]+", - "^ -> features: ", - "^\* software:$", - "^ -> glibc version: ", - "^ -> Python binary: .*/[pP]ython[0-9]?", - "^ -> Python version: [0-9.]+", + r"^System information \(.*\):$", + r"^\* OS:$", + r"^ -> name: ", + r"^ -> type: ", + r"^ -> version: ", + r"^ -> platform name: ", + r"^\* CPU:$", + r"^ -> vendor: ", + r"^ -> architecture: ", + r"^ -> family: ", + r"^ -> model: ", + r"^ -> speed: [0-9.]+", + r"^ -> cores: [0-9]+", + r"^ -> features: ", + r"^\* software:$", + r"^ -> glibc version: ", + r"^ -> Python binary: .*/[pP]ython[0-9]?", + r"^ -> Python version: [0-9.]+", ] if HAVE_ARCHSPEC: diff --git a/test/framework/parallelbuild.py b/test/framework/parallelbuild.py index 79608c5b24..b438dd9881 100644 --- a/test/framework/parallelbuild.py +++ b/test/framework/parallelbuild.py @@ -86,6 +86,7 @@ def mock(*args, **kwargs): class MockPbsJob(object): """Mocking class for PbsJob.""" + def __init__(self, *args, **kwargs): self.deps = [] self.jobid = None @@ -299,17 +300,17 @@ def test_submit_jobs(self): # these patterns must be found regexs = [ - ' --debug ', + r' --debug ', # values got wrapped in single quotes (to avoid interpretation by shell) - " --tmpdir='/tmp' ", - " --parallel='2' ", + r" --tmpdir='/tmp' ", + r" --parallel='2' ", # (unparsed) optarch value got wrapped in single quotes, double quotes got stripped - " --optarch='GCC:O3 -mtune=generic;Intel:O3 -xHost' ", + r" --optarch='GCC:O3 -mtune=generic;Intel:O3 -xHost' ", # templates to be completed via build_easyconfigs_in_parallel -> create_job - ' eb %\(spec\)s ', - ' %\(add_opts\)s ', - ' --testoutput=%\(output_dir\)s', - ' --disable-job ', + r' eb %\(spec\)s ', + r' %\(add_opts\)s ', + r' --testoutput=%\(output_dir\)s', + r' --disable-job ', ] for regex in regexs: regex = re.compile(regex) diff --git a/test/framework/robot.py b/test/framework/robot.py index 578985ef00..e50f570a37 100644 --- a/test/framework/robot.py +++ b/test/framework/robot.py @@ -578,7 +578,7 @@ def test_resolve_dependencies_missing(self): }], } - error = "Missing dependencies: somedep/4.5.6 \(no easyconfig file or existing module found\)" + error = r"Missing dependencies: somedep/4.5.6 \(no easyconfig file or existing module found\)" self.assertErrorRegex(EasyBuildError, error, resolve_dependencies, [ec], self.modtool) # check behaviour if only module file is available @@ -587,7 +587,7 @@ def test_resolve_dependencies_missing(self): self.assertEqual(len(res), 1) self.assertEqual(res[0]['full_mod_name'], 'test/123') - error = "Missing dependencies: somedep/4.5.6 \(no easyconfig file found in robot search path\)" + error = r"Missing dependencies: somedep/4.5.6 \(no easyconfig file found in robot search path\)" self.assertErrorRegex(EasyBuildError, error, resolve_dependencies, [ec], self.modtool, retain_all_deps=True) res = resolve_dependencies([ec], self.modtool, retain_all_deps=True, raise_error_missing_ecs=False) diff --git a/test/framework/run.py b/test/framework/run.py index 5150838d80..ad881a09fe 100644 --- a/test/framework/run.py +++ b/test/framework/run.py @@ -233,7 +233,7 @@ def test_run_cmd_bis(self): # a more 'complex' command to run, make sure all required output is there (out, ec) = run_cmd("for j in `seq 1 3`; do for i in `seq 1 100`; do echo hello; done; sleep 1.4; done") self.assertTrue(out.startswith('hello\nhello\n')) - self.assertEqual(len(out), len("hello\n"*300)) + self.assertEqual(len(out), len("hello\n" * 300)) self.assertEqual(ec, 0) def test_run_cmd_log_output(self): diff --git a/test/framework/sandbox/easybuild/easyblocks/__init__.py b/test/framework/sandbox/easybuild/easyblocks/__init__.py index 34b9c8ff71..089b74322c 100644 --- a/test/framework/sandbox/easybuild/easyblocks/__init__.py +++ b/test/framework/sandbox/easybuild/easyblocks/__init__.py @@ -1,11 +1,11 @@ import pkgutil -subdirs = [chr(l) for l in range(ord('a'), ord('z') + 1)] + ['0'] +subdirs = [chr(x) for x in range(ord('a'), ord('z') + 1)] + ['0'] for subdir in subdirs: __path__ = pkgutil.extend_path(__path__, '%s.%s' % (__name__, subdir)) del subdir, subdirs -if 'l' in dir(): - del l +if 'x' in dir(): + del x __path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/test/framework/sandbox/easybuild/easyblocks/g/gcc.py b/test/framework/sandbox/easybuild/easyblocks/g/gcc.py index 02d96ef2d9..2324891789 100644 --- a/test/framework/sandbox/easybuild/easyblocks/g/gcc.py +++ b/test/framework/sandbox/easybuild/easyblocks/g/gcc.py @@ -29,5 +29,6 @@ """ from easybuild.framework.easyblock import EasyBlock + class EB_GCC(EasyBlock): pass diff --git a/test/framework/sandbox/easybuild/easyblocks/generic/configuremake.py b/test/framework/sandbox/easybuild/easyblocks/generic/configuremake.py index ae580258a4..099e2e3e14 100644 --- a/test/framework/sandbox/easybuild/easyblocks/generic/configuremake.py +++ b/test/framework/sandbox/easybuild/easyblocks/generic/configuremake.py @@ -31,6 +31,7 @@ from easybuild.framework.easyblock import EasyBlock from easybuild.framework.easyconfig import CUSTOM + class ConfigureMake(EasyBlock): """Dummy support for building and installing applications with configure/make/make install.""" diff --git a/test/framework/sandbox/easybuild/easyblocks/generic/dummyextension.py b/test/framework/sandbox/easybuild/easyblocks/generic/dummyextension.py index af97c3f254..88591809f0 100644 --- a/test/framework/sandbox/easybuild/easyblocks/generic/dummyextension.py +++ b/test/framework/sandbox/easybuild/easyblocks/generic/dummyextension.py @@ -30,6 +30,7 @@ from easybuild.framework.extensioneasyblock import ExtensionEasyBlock + class DummyExtension(ExtensionEasyBlock): """Support for building/installing dummy extensions.""" diff --git a/test/framework/sandbox/easybuild/easyblocks/generic/toolchain.py b/test/framework/sandbox/easybuild/easyblocks/generic/toolchain.py index fd1de3a89e..d31635817b 100644 --- a/test/framework/sandbox/easybuild/easyblocks/generic/toolchain.py +++ b/test/framework/sandbox/easybuild/easyblocks/generic/toolchain.py @@ -29,13 +29,18 @@ """ from easybuild.framework.easyblock import EasyBlock + class Toolchain(EasyBlock): """Dummy support for toolchains.""" + def configure_step(self): pass + def build_step(self): pass + def install_step(self): pass + def sanity_check_step(self): pass diff --git a/test/framework/sandbox/easybuild/easyblocks/h/hpl.py b/test/framework/sandbox/easybuild/easyblocks/h/hpl.py index 0b89ba202c..db4e660653 100644 --- a/test/framework/sandbox/easybuild/easyblocks/h/hpl.py +++ b/test/framework/sandbox/easybuild/easyblocks/h/hpl.py @@ -29,5 +29,6 @@ """ from easybuild.framework.easyblock import EasyBlock + class EB_HPL(EasyBlock): pass diff --git a/test/framework/sandbox/easybuild/easyblocks/s/scalapack.py b/test/framework/sandbox/easybuild/easyblocks/s/scalapack.py index 1dcef0a54d..3cf433cb3a 100644 --- a/test/framework/sandbox/easybuild/easyblocks/s/scalapack.py +++ b/test/framework/sandbox/easybuild/easyblocks/s/scalapack.py @@ -29,5 +29,6 @@ """ from easybuild.framework.easyblock import EasyBlock + class EB_ScaLAPACK(EasyBlock): pass diff --git a/test/framework/sandbox/easybuild/easyblocks/t/toy_buggy.py b/test/framework/sandbox/easybuild/easyblocks/t/toy_buggy.py index 959ff5b92b..1df5746fdd 100644 --- a/test/framework/sandbox/easybuild/easyblocks/t/toy_buggy.py +++ b/test/framework/sandbox/easybuild/easyblocks/t/toy_buggy.py @@ -30,6 +30,7 @@ from easybuild.framework.easyblock import EasyBlock + class EB_toy_buggy(EasyBlock): """Support for building/installing toy.""" @@ -40,7 +41,7 @@ def configure_step(self): def build_step(self): """Build toy.""" # note: import is (purposely) missing, so this will go down hard - run_cmd('gcc toy.c -o toy') + run_cmd('gcc toy.c -o toy') # noqa def install_step(self): """Install toy.""" diff --git a/test/framework/sandbox/easybuild/easyblocks/t/toytoy.py b/test/framework/sandbox/easybuild/easyblocks/t/toytoy.py index 3ebbfe724b..ee700251a6 100644 --- a/test/framework/sandbox/easybuild/easyblocks/t/toytoy.py +++ b/test/framework/sandbox/easybuild/easyblocks/t/toytoy.py @@ -40,5 +40,5 @@ def extra_options(): """Custom easyconfig parameters for toytoy.""" extra_vars = { 'toytoy_extra1': [None, "first toytoy-specific easyconfig parameter", CUSTOM], - } + } return EB_toy.extra_options(extra_vars) diff --git a/test/framework/systemtools.py b/test/framework/systemtools.py index bda6813014..70e7515826 100644 --- a/test/framework/systemtools.py +++ b/test/framework/systemtools.py @@ -51,6 +51,7 @@ PROC_CPUINFO_TXT = None + PROC_CPUINFO_TXT_RASPI2 = """processor : 0 model name : ARMv7 Processor rev 5 (v7l) BogoMIPS : 57.60 @@ -71,6 +72,7 @@ CPU part : 0xc07 CPU revision : 5 """ + PROC_CPUINFO_TXT_ODROID_XU3 = """processor : 0 model name : ARMv7 Processor rev 3 (v7l) BogoMIPS : 84.00 @@ -91,6 +93,7 @@ CPU part : 0xc0f CPU revision : 3 """ + PROC_CPUINFO_TXT_XGENE2 = """processor : 0 cpu MHz : 2400.000 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 @@ -100,6 +103,7 @@ CPU part : 0x000 CPU revision : 0 """ + PROC_CPUINFO_TXT_THUNDERX = """processor : 0 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 CPU implementer : 0x43 @@ -108,6 +112,7 @@ CPU part : 0x0a1 CPU revision : 0 """ + PROC_CPUINFO_TXT_POWER = """processor : 0 cpu : POWER7 (architected), altivec supported clock : 3550.000000MHz @@ -123,6 +128,13 @@ model : IBM,8205-E6C machine : CHRP IBM,8205-E6C """ + +PROC_CPUINFO_TXT_AMD_FLAGS = ' '.join([ + "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall", + "nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni", + "monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs", + "skinit wdt hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall", +]) PROC_CPUINFO_TXT_AMD = """processor : 0 vendor_id : AuthenticAMD cpu family : 16 @@ -142,7 +154,7 @@ fpu_exception : yes cpuid level : 5 wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall +flags : %(flags)s bogomips : 4400.54 TLB size : 1024 4K pages clflush size : 64 @@ -169,14 +181,23 @@ fpu_exception : yes cpuid level : 5 wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nopl nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt hw_pstate npt lbrv svm_lock nrip_save pausefilter vmmcall +flags : %(flags)s bogomips : 4400.54 TLB size : 1024 4K pages clflush size : 64 cache_alignment : 64 address sizes : 48 bits physical, 48 bits virtual power management: ts ttp tm stc 100mhzsteps hwpstate -""" +""" % {'flags': PROC_CPUINFO_TXT_AMD_FLAGS} + +PROC_CPUINFO_TXT_INTEL_FLAGS = ' '.join([ + "fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss", + "ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc", + "aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2", + "x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat xsaveopt pln pts dts tpr_shadow vnmi", + "flexpriority ept vpid", +]) + PROC_CPUINFO_TXT_INTEL = """processor : 0 vendor_id : GenuineIntel cpu family : 6 @@ -196,7 +217,7 @@ fpu_exception : yes cpuid level : 13 wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid +flags : %(flags)s bogomips : 5200.15 clflush size : 64 cache_alignment : 64 @@ -222,13 +243,14 @@ fpu_exception : yes cpuid level : 13 wp : yes -flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm ida arat xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid +flags : %(flags)s bogomips : 5200.04 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual power management: -""" +""" % {'flags': PROC_CPUINFO_TXT_INTEL_FLAGS} + PROC_MEMINFO_TXT = """MemTotal: 66059108 kB MemFree: 2639988 kB Buffers: 236368 kB @@ -280,7 +302,7 @@ def mocked_read_file(fp): """Mocked version of read_file, with specified contents for known filenames.""" known_fps = { - MAX_FREQ_FP: '2850000', + MAX_FREQ_FP: '2850000', PROC_CPUINFO_FP: PROC_CPUINFO_TXT, PROC_MEMINFO_FP: PROC_MEMINFO_TXT, } @@ -305,7 +327,11 @@ def mocked_run_cmd(cmd, **kwargs): "sysctl -n hw.memsize": '8589934592', "sysctl -n machdep.cpu.brand_string": "Intel(R) Core(TM) i5-4258U CPU @ 2.40GHz", "sysctl -n machdep.cpu.extfeatures": "SYSCALL XD 1GBPAGE EM64T LAHF LZCNT RDTSCP TSCI", - "sysctl -n machdep.cpu.features": "FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C", + "sysctl -n machdep.cpu.features": ' '.join([ + "FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2", + "SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX EST TM2 SSSE3 FMA CX16 TPR PDCM SSE4.1 SSE4.2 x2APIC", + "MOVBE POPCNT AES PCID XSAVE OSXSAVE SEGLIM64 TSCTMR AVX1.0 RDRAND F16C", + ]), "sysctl -n machdep.cpu.leaf7_features": "SMEP ERMS RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 BMI2 INVPCID FPU_CSDS", "sysctl -n machdep.cpu.vendor": 'GenuineIntel', "ulimit -u": '40', diff --git a/test/framework/toolchain.py b/test/framework/toolchain.py index 68b6ca753e..89d7232e18 100644 --- a/test/framework/toolchain.py +++ b/test/framework/toolchain.py @@ -691,7 +691,7 @@ def test_compiler_dependent_optarch(self): test_cases = product(intel_options, gcc_options, gcccore_options, toolchains, enabled) - for intel_flags, gcc_flags, gcccore_flags, (toolchain, toolchain_ver), enable in test_cases: + for intel_flags, gcc_flags, gcccore_flags, (toolchain_name, toolchain_ver), enable in test_cases: intel_flags, intel_flags_exp = intel_flags gcc_flags, gcc_flags_exp = gcc_flags @@ -702,15 +702,15 @@ def test_compiler_dependent_optarch(self): optarch_var['GCC'] = gcc_flags optarch_var['GCCcore'] = gcccore_flags init_config(build_options={'optarch': optarch_var, 'silent': True}) - tc = self.get_toolchain(toolchain, version=toolchain_ver) + tc = self.get_toolchain(toolchain_name, version=toolchain_ver) tc.set_options({'optarch': enable}) tc.prepare() flags = None - if toolchain == 'iccifort': + if toolchain_name == 'iccifort': flags = intel_flags_exp - elif toolchain == 'GCC': + elif toolchain_name == 'GCC': flags = gcc_flags_exp - elif toolchain == 'GCCcore': + elif toolchain_name == 'GCCcore': flags = gcccore_flags_exp else: # PGI as an example of compiler not set # default optarch flag, should be the same as the one in @@ -1589,7 +1589,7 @@ def test_compiler_cache(self): ccache = which('ccache') if ccache is None: - msg = "ccache binary not found in \$PATH, required by --use-compiler-cache" + msg = r"ccache binary not found in \$PATH, required by --use-compiler-cache" self.assertErrorRegex(EasyBuildError, msg, self.eb_main, args, raise_error=True, do_build=True) # generate shell script to mock ccache/f90cache diff --git a/test/framework/toolchainvariables.py b/test/framework/toolchainvariables.py index 890417c354..7edbdde91c 100644 --- a/test/framework/toolchainvariables.py +++ b/test/framework/toolchainvariables.py @@ -125,11 +125,11 @@ class TCV(ToolchainVariables): # e.g. numpy and mkl blas # -Wl:-Bstatic,-Wl:--start-group,mkl_intel_lp64,mkl_intel_thread,mkl_core,-Wl:--end-group,-Wl:-Bdynamic,iomp5 kwargs = { - 'prefix': '', - 'prefix_begin_end': '-Wl:', - 'separator': ',', - 'separator_begin_end': ',', - } + 'prefix': '', + 'prefix_begin_end': '-Wl:', + 'separator': ',', + 'separator_begin_end': ',', + } copy_blas_2.try_function_on_element('change', kwargs=kwargs) copy_blas_2.SEPARATOR = ',' diff --git a/test/framework/toy_build.py b/test/framework/toy_build.py index 38542565cf..5bb575c8a3 100644 --- a/test/framework/toy_build.py +++ b/test/framework/toy_build.py @@ -257,8 +257,8 @@ def test_toy_tweaked(self): shutil.copy2(os.path.join(test_ecs_dir, 'test_ecs', 't', 'toy', 'toy-0.0.eb'), ec_file) modloadmsg = 'THANKS FOR LOADING ME\\nI AM %(name)s v%(version)s' - modloadmsg_regex_tcl = 'THANKS.*\n\s*I AM toy v0.0\n\s*"' - modloadmsg_regex_lua = '\[==\[THANKS.*\n\s*I AM toy v0.0\n\s*\]==\]' + modloadmsg_regex_tcl = r'THANKS.*\n\s*I AM toy v0.0\n\s*"' + modloadmsg_regex_lua = r'\[==\[THANKS.*\n\s*I AM toy v0.0\n\s*\]==\]' # tweak easyconfig by appending to it ec_extra = '\n'.join([ @@ -385,14 +385,14 @@ def test_toy_build_with_blocks(self): sys.path.append(tmpdir) args = [ - 'toy-0.0-multiple.eb', - '--sourcepath=%s' % self.test_sourcepath, - '--buildpath=%s' % self.test_buildpath, - '--installpath=%s' % self.test_installpath, - '--debug', - '--unittest-file=%s' % self.logfile, - '--force', - ] + 'toy-0.0-multiple.eb', + '--sourcepath=%s' % self.test_sourcepath, + '--buildpath=%s' % self.test_buildpath, + '--installpath=%s' % self.test_installpath, + '--debug', + '--unittest-file=%s' % self.logfile, + '--force', + ] outtxt = self.eb_main(args, logfile=self.dummylogfn, do_build=True, verbose=True) for toy_prefix, toy_version, toy_suffix in [ @@ -727,8 +727,8 @@ def test_toy_group_check(self): regex = re.compile(pattern, re.M) self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, toy_mod_txt)) else: - pattern = "Can't generate robust check in Lua modules for users belonging to group %s. " - pattern += "Lmod version not recent enough \(%s\), should be >= 6.0.8" % lmod_version + pattern = r"Can't generate robust check in Lua modules for users belonging to group %s. " + pattern += r"Lmod version not recent enough \(%s\), should be >= 6.0.8" % lmod_version regex = re.compile(pattern % group_name, re.M) self.assertTrue(regex.search(outtxt), "Pattern '%s' found in: %s" % (regex.pattern, outtxt)) else: @@ -835,7 +835,7 @@ def test_toy_hierarchical(self): modtxt = read_file(toy_module_path) modpath_extension = os.path.join(mod_prefix, 'MPI', 'GCC', '6.4.0-2.28', 'toy', '0.0') if get_module_syntax() == 'Tcl': - self.assertTrue(re.search('^module\s*use\s*"%s"' % modpath_extension, modtxt, re.M)) + self.assertTrue(re.search(r'^module\s*use\s*"%s"' % modpath_extension, modtxt, re.M)) elif get_module_syntax() == 'Lua': fullmodpath_extension = os.path.join(self.test_installpath, modpath_extension) regex = re.compile(r'^prepend_path\("MODULEPATH", "%s"\)' % fullmodpath_extension, re.M) @@ -850,7 +850,7 @@ def test_toy_hierarchical(self): modtxt = read_file(toy_module_path) modpath_extension = os.path.join(mod_prefix, 'MPI', 'GCC', '6.4.0-2.28', 'toy', '0.0') if get_module_syntax() == 'Tcl': - self.assertFalse(re.search('^module\s*use\s*"%s"' % modpath_extension, modtxt, re.M)) + self.assertFalse(re.search(r'^module\s*use\s*"%s"' % modpath_extension, modtxt, re.M)) elif get_module_syntax() == 'Lua': fullmodpath_extension = os.path.join(self.test_installpath, modpath_extension) regex = re.compile(r'^prepend_path\("MODULEPATH", "%s"\)' % fullmodpath_extension, re.M) @@ -1289,7 +1289,7 @@ def test_toy_module_fulltxt(self): modloadmsg_lua = [ r'io.stderr:write\(\[==\[THANKS FOR LOADING ME', r'I AM toy v0.0', - '\]==\]\)', + r'\]==\]\)', ] help_txt = '\n'.join([ diff --git a/test/framework/tweak.py b/test/framework/tweak.py index 942d6671c9..f5afd97e08 100644 --- a/test/framework/tweak.py +++ b/test/framework/tweak.py @@ -535,6 +535,7 @@ def test_list_deps_versionsuffixes(self): ec_spec = os.path.join(test_easyconfigs, 'g', 'gzip', 'gzip-1.4-GCC-4.6.3.eb') self.assertEqual(list_deps_versionsuffixes(ec_spec), ['-deps']) + def suite(): """ return all the tests in this file """ return TestLoaderFiltered().loadTestsFromTestCase(TweakTest, sys.argv[1:]) diff --git a/test/framework/type_checking.py b/test/framework/type_checking.py index b1247832c5..df75c49400 100644 --- a/test/framework/type_checking.py +++ b/test/framework/type_checking.py @@ -356,7 +356,7 @@ def test_to_dependency(self): # extra keys ruin it foo_dict.update({'extra_key': 'bogus'}) - self.assertErrorRegex(EasyBuildError, "Found unexpected \(key, value\) pair: .*", to_dependency, foo_dict) + self.assertErrorRegex(EasyBuildError, r"Found unexpected \(key, value\) pair: .*", to_dependency, foo_dict) # no name/version self.assertErrorRegex(EasyBuildError, "Can not parse dependency without name and version: .*",