tests: Work with older unittest2
RHEL has an older version of the library which does not backport all the assertions that we used. In order for the tests to pass there we need to use names that exist everywhere. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
6f21576921
commit
f21e3a2d6d
@ -102,7 +102,7 @@ class CheckDependenciesTestCase(unittest.TestCase):
|
||||
exists.side_effect = self.dont_find(['/usr/bin/isohybrid'])
|
||||
result = checks.check(conf)
|
||||
|
||||
self.assertRegex(out.getvalue(), r'^Not checking.*Expect failures.*$')
|
||||
self.assertRegexpMatches(out.getvalue(), r'^Not checking.*Expect failures.*$')
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_isohybrid_not_needed_in_runroot(self):
|
||||
@ -227,7 +227,7 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks.make_schema')
|
||||
@ -275,7 +275,7 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks.make_schema')
|
||||
@ -299,9 +299,9 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
config = self._load_conf_from_string(string)
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 1)
|
||||
self.assertRegex(errors[0], r"^ERROR: Config option 'product_name' is an alias of 'release_name', only one can be used.*")
|
||||
self.assertRegexpMatches(errors[0], r"^ERROR: Config option 'product_name' is an alias of 'release_name', only one can be used.*")
|
||||
self.assertEqual(len(warnings), 1)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'product_name' is deprecated and now an alias to 'release_name'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
|
||||
@mock.patch('pungi.checks.make_schema')
|
||||
@ -340,8 +340,8 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 2)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertRegex(warnings[1], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Config option '.+' is deprecated and now an alias to '.+'.*")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
self.assertEqual(config.get("foophase", {}).get("repo", None), "http://www.exampe.com/os")
|
||||
|
||||
@ -380,8 +380,8 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 2)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegex(warnings[1], r"^WARNING: Value from config option 'repo_from' is now appended to option 'repo'")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Value from config option 'repo_from' is now appended to option 'repo'")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
self.assertEqual(config.get("repo", None), ["http://url/to/repo", "Server"])
|
||||
|
||||
@ -419,8 +419,8 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 2)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegex(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified,")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified,")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
self.assertEqual(config.get("repo", None), ["http://url/to/repo", "Server"])
|
||||
|
||||
@ -462,10 +462,10 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 4)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegex(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified,")
|
||||
self.assertRegex(warnings[2], r"^WARNING: Config option 'source_repo_from' is deprecated, its value will be appended to option 'repo'")
|
||||
self.assertRegex(warnings[3], r"^WARNING: Value from config option 'source_repo_from' is now appended to option 'repo'.")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified,")
|
||||
self.assertRegexpMatches(warnings[2], r"^WARNING: Config option 'source_repo_from' is deprecated, its value will be appended to option 'repo'")
|
||||
self.assertRegexpMatches(warnings[3], r"^WARNING: Value from config option 'source_repo_from' is now appended to option 'repo'.")
|
||||
self.assertEqual(config.get("release_name", None), "dummy product")
|
||||
self.assertEqual(config.get("repo", None), ["http://url/to/repo", "Server", "Client"])
|
||||
|
||||
@ -515,8 +515,8 @@ class TestSchemaValidator(unittest.TestCase):
|
||||
errors, warnings = checks.validate(config)
|
||||
self.assertEqual(len(errors), 0)
|
||||
self.assertEqual(len(warnings), 2)
|
||||
self.assertRegex(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegex(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified, value from 'repo_from' is now added as 'repo'.*")
|
||||
self.assertRegexpMatches(warnings[0], r"^WARNING: Config option 'repo_from' is deprecated, its value will be appended to option 'repo'.*")
|
||||
self.assertRegexpMatches(warnings[1], r"^WARNING: Config option 'repo' is not found, but 'repo_from' is specified, value from 'repo_from' is now added as 'repo'.*")
|
||||
self.assertEqual(config.get("live_images")[0][1]['armhfp']['repo'], 'Everything')
|
||||
|
||||
|
||||
|
@ -801,8 +801,9 @@ class TestGetProductIds(PungiTestCase):
|
||||
get_productids_from_scm(self.compose)
|
||||
|
||||
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, ANY)])
|
||||
self.assertRegex(str(ctx.exception),
|
||||
r'No product certificate found \(arch: amd64, variant: (Everything|Client)\)')
|
||||
self.assertRegexpMatches(
|
||||
str(ctx.exception),
|
||||
r'No product certificate found \(arch: amd64, variant: (Everything|Client)\)')
|
||||
|
||||
@mock.patch('pungi.phases.createrepo.get_dir_from_scm')
|
||||
def test_multiple_matching(self, get_dir_from_scm):
|
||||
@ -823,8 +824,9 @@ class TestGetProductIds(PungiTestCase):
|
||||
get_productids_from_scm(self.compose)
|
||||
|
||||
self.assertEqual(get_dir_from_scm.call_args_list, [mock.call(cfg, ANY)])
|
||||
self.assertRegex(str(ctx.exception),
|
||||
'Multiple product certificates found.+')
|
||||
self.assertRegexpMatches(
|
||||
str(ctx.exception),
|
||||
'Multiple product certificates found.+')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -159,7 +159,7 @@ class TestCopyFiles(helpers.PungiTestCase):
|
||||
extra_files.copy_extra_files(
|
||||
compose, [cfg], 'x86_64', compose.variants['Server'], package_sets)
|
||||
|
||||
self.assertRegex(str(ctx.exception), 'No.*package.*matching bad-server\*.*')
|
||||
self.assertRegexpMatches(str(ctx.exception), 'No.*package.*matching bad-server\*.*')
|
||||
|
||||
self.assertEqual(len(get_file_from_scm.call_args_list), 0)
|
||||
self.assertEqual(get_dir_from_scm.call_args_list, [])
|
||||
|
@ -443,7 +443,7 @@ class OSBSThreadTest(helpers.PungiTestCase):
|
||||
with self.assertRaises(RuntimeError) as ctx:
|
||||
self.t.process((self.compose, self.compose.variants['Server'], cfg), 1)
|
||||
|
||||
self.assertRegex(str(ctx.exception), r"task 12345 failed: see .+ for details")
|
||||
self.assertRegexpMatches(str(ctx.exception), r"task 12345 failed: see .+ for details")
|
||||
|
||||
@mock.patch('pungi.util.resolve_git_url')
|
||||
@mock.patch('pungi.phases.osbs.kojiwrapper.KojiWrapper')
|
||||
|
@ -259,8 +259,9 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
|
||||
self.koji_wrapper.koji_proxy.mock_calls,
|
||||
[mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)])
|
||||
|
||||
self.assertRegex(str(ctx.exception),
|
||||
r'^RPM\(s\) not found for sigs: .+Check log for details.+')
|
||||
self.assertRegexpMatches(
|
||||
str(ctx.exception),
|
||||
r'^RPM\(s\) not found for sigs: .+Check log for details.+')
|
||||
|
||||
def test_can_not_find_any_package(self):
|
||||
pkgset = pkgsets.KojiPackageSet(self.koji_wrapper, ['cafebabe', None], arches=['x86_64'])
|
||||
@ -272,8 +273,9 @@ class TestKojiPkgset(PkgsetCompareMixin, helpers.PungiTestCase):
|
||||
self.koji_wrapper.koji_proxy.mock_calls,
|
||||
[mock.call.listTaggedRPMS('f25', event=None, inherit=True, latest=True)])
|
||||
|
||||
self.assertRegex(str(ctx.exception),
|
||||
r'^RPM\(s\) not found for sigs: .+Check log for details.+')
|
||||
self.assertRegexpMatches(
|
||||
str(ctx.exception),
|
||||
r'^RPM\(s\) not found for sigs: .+Check log for details.+')
|
||||
|
||||
def test_packages_attribute(self):
|
||||
self._touch_files([
|
||||
|
@ -213,7 +213,7 @@ class GitSCMTestCase(SCMBaseTest):
|
||||
self.destdir)
|
||||
self.assertStructure(retval, ['some_file.txt'])
|
||||
self.assertEqual(1, len(commands))
|
||||
self.assertRegex(
|
||||
self.assertRegexpMatches(
|
||||
commands[0],
|
||||
r'/usr/bin/git clone --depth 1 --branch=master https://example.com/git/repo.git /tmp/.+')
|
||||
|
||||
@ -308,7 +308,7 @@ class GitSCMTestCase(SCMBaseTest):
|
||||
self.destdir)
|
||||
self.assertStructure(retval, ['first', 'second'])
|
||||
|
||||
self.assertRegex(
|
||||
self.assertRegexpMatches(
|
||||
commands[0],
|
||||
r'/usr/bin/git clone --depth 1 --branch=master https://example.com/git/repo.git /tmp/.+')
|
||||
self.assertEqual(commands[1:], ['make'])
|
||||
|
@ -26,14 +26,14 @@ class TestUnifiedIsos(PungiTestCase):
|
||||
compose_path = os.path.join(self.topdir, COMPOSE_ID, 'compose')
|
||||
isos = unified_isos.UnifiedISO(compose_path)
|
||||
self.assertEqual(isos.compose_path, compose_path)
|
||||
self.assertRegex(isos.temp_dir,
|
||||
'^%s/' % os.path.join(self.topdir, COMPOSE_ID, 'work'))
|
||||
self.assertRegexpMatches(
|
||||
isos.temp_dir, '^%s/' % os.path.join(self.topdir, COMPOSE_ID, 'work'))
|
||||
|
||||
def test_can_find_compose_subdir(self):
|
||||
isos = unified_isos.UnifiedISO(os.path.join(self.topdir, COMPOSE_ID))
|
||||
self.assertEqual(isos.compose_path, os.path.join(self.topdir, COMPOSE_ID, 'compose'))
|
||||
self.assertRegex(isos.temp_dir,
|
||||
'^%s/' % os.path.join(self.topdir, COMPOSE_ID, 'work'))
|
||||
self.assertRegexpMatches(isos.temp_dir,
|
||||
'^%s/' % os.path.join(self.topdir, COMPOSE_ID, 'work'))
|
||||
|
||||
@mock.patch('os.rename')
|
||||
def test_dump_manifest(self, rename):
|
||||
|
Loading…
Reference in New Issue
Block a user