From 35af2f8dafeb57e1a948ea8c168301bb16d2b5be Mon Sep 17 00:00:00 2001 From: Daniel Kutik Date: Mon, 28 Nov 2022 11:36:01 +0100 Subject: [PATCH] Fixed wrapper related warnings in tests Multiple "Could not find reference" warnings in test_wrapper.py and test_git_command.py resolved. Test: tox Signed-off-by: Daniel Kutik Change-Id: Ic254c378bbdae6bc3f8f29682ababb37db76adfe Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353235 Reviewed-by: Mike Frysinger --- tests/test_git_command.py | 3 ++- tests/test_wrapper.py | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/test_git_command.py b/tests/test_git_command.py index ff0d395d..96408a23 100644 --- a/tests/test_git_command.py +++ b/tests/test_git_command.py @@ -117,7 +117,8 @@ class GitRequireTests(unittest.TestCase): """Test the git_require helper.""" def setUp(self): - ver = wrapper.GitVersion(1, 2, 3, 4) + self.wrapper = wrapper.Wrapper() + ver = self.wrapper.GitVersion(1, 2, 3, 4) mock.patch.object(git_command.git, 'version_tuple', return_value=ver).start() def tearDown(self): diff --git a/tests/test_wrapper.py b/tests/test_wrapper.py index f77ae1ef..372dfcf2 100644 --- a/tests/test_wrapper.py +++ b/tests/test_wrapper.py @@ -59,12 +59,12 @@ class RepoWrapperUnitTest(RepoWrapperTestCase): def test_python_constraints(self): """The launcher should never require newer than main.py.""" self.assertGreaterEqual(main.MIN_PYTHON_VERSION_HARD, - wrapper.MIN_PYTHON_VERSION_HARD) + self.wrapper.MIN_PYTHON_VERSION_HARD) self.assertGreaterEqual(main.MIN_PYTHON_VERSION_SOFT, - wrapper.MIN_PYTHON_VERSION_SOFT) + self.wrapper.MIN_PYTHON_VERSION_SOFT) # Make sure the versions are themselves in sync. - self.assertGreaterEqual(wrapper.MIN_PYTHON_VERSION_SOFT, - wrapper.MIN_PYTHON_VERSION_HARD) + self.assertGreaterEqual(self.wrapper.MIN_PYTHON_VERSION_SOFT, + self.wrapper.MIN_PYTHON_VERSION_HARD) def test_init_parser(self): """Make sure 'init' GetParser works.""" @@ -458,7 +458,7 @@ class ResolveRepoRev(GitCheckoutTestCase): self.assertEqual('refs/heads/stable', rrev) self.assertEqual(self.REV_LIST[1], lrev) - with self.assertRaises(wrapper.CloneFailure): + with self.assertRaises(self.wrapper.CloneFailure): self.wrapper.resolve_repo_rev(self.GIT_DIR, 'refs/heads/unknown') def test_explicit_tag(self): @@ -467,7 +467,7 @@ class ResolveRepoRev(GitCheckoutTestCase): self.assertEqual('refs/tags/v1.0', rrev) self.assertEqual(self.REV_LIST[1], lrev) - with self.assertRaises(wrapper.CloneFailure): + with self.assertRaises(self.wrapper.CloneFailure): self.wrapper.resolve_repo_rev(self.GIT_DIR, 'refs/tags/unknown') def test_branch_name(self): @@ -502,7 +502,7 @@ class ResolveRepoRev(GitCheckoutTestCase): def test_unknown(self): """Check unknown ref/commit argument.""" - with self.assertRaises(wrapper.CloneFailure): + with self.assertRaises(self.wrapper.CloneFailure): self.wrapper.resolve_repo_rev(self.GIT_DIR, 'boooooooya')