diff --git a/easybuild/tools/filetools.py b/easybuild/tools/filetools.py index 86ba0f796c..886f20b41d 100644 --- a/easybuild/tools/filetools.py +++ b/easybuild/tools/filetools.py @@ -1535,9 +1535,8 @@ def create_patch_info(patch_spec): def validate_patch_spec(patch_spec): allowed_patch_exts = ['.patch' + x for x in ('',) + ZIPPED_PATCH_EXTS] if not any(patch_spec.endswith(x) for x in allowed_patch_exts): - msg = "Use of patch file with filename that doesn't end with correct extension: %s " % patch_spec - msg += "(should be any of: %s)" % (', '.join(allowed_patch_exts)) - _log.deprecated(msg, '5.0') + raise EasyBuildError("Wrong patch spec (%s), extension type should be any of %s." % + (patch_spec, ', '.join(allowed_patch_exts))) def apply_patch(patch_file, dest, fn=None, copy=False, level=None, use_git_am=False, use_git=False): diff --git a/test/framework/filetools.py b/test/framework/filetools.py index 5b50296e4c..e10ca4b96d 100644 --- a/test/framework/filetools.py +++ b/test/framework/filetools.py @@ -1646,25 +1646,15 @@ def test_create_patch_info(self): self.assertEqual(ft.create_patch_info({'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'}), {'name': 'foo.txt', 'copy': 'subdir', 'alt_location': 'alt'}) - self.allow_deprecated_behaviour() - self.mock_stderr(True) - self.assertEqual(ft.create_patch_info('foo.txt'), {'name': 'foo.txt'}) - stderr = self.get_stderr() - self.mock_stderr(False) - self.disallow_deprecated_behaviour() - expected_warning = "Use of patch file with filename that doesn't end with correct extension: foo.txt " - expected_warning += "(should be any of: .patch, .patch.bz2, .patch.gz, .patch.xz)" - fail_msg = "Warning '%s' should appear in stderr output: %s" % (expected_warning, stderr) - self.assertIn(expected_warning, stderr, fail_msg) - - # deprecation warning is treated as an error in context of unit test suite - expected_error = expected_warning.replace('(', '\\(').replace(')', '\\)') + expected_error = r"Wrong patch spec \(foo.txt\), extension type should be any of .patch, .patch.bz2, " + expected_error += ".patch.gz, .patch.xz." self.assertErrorRegex(EasyBuildError, expected_error, ft.create_patch_info, 'foo.txt') # faulty input error_msg = "Wrong patch spec" self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, None) self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'copy': 'subdir'}) + self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt'}) self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt', 'random': 'key'}) self.assertErrorRegex(EasyBuildError, error_msg, ft.create_patch_info, {'name': 'foo.txt', 'copy': 'subdir', 'sourcepath': 'subdir'})