From b04812b6f4e3f3859c4fd17b62ea9ed5d3bc035a Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 26 Jun 2014 10:01:18 +0300 Subject: [PATCH] ComponentTestBase: add check_files() method Change-Id: If23365cde15c2659aad039f19984a97968cd4545 Signed-off-by: Markus Lehtonen --- tests/component/__init__.py | 14 ++++++++++---- tests/component/rpm/test_import_orig_rpm.py | 8 -------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/tests/component/__init__.py b/tests/component/__init__.py index f029eb2..0c7e27f 100644 --- a/tests/component/__init__.py +++ b/tests/component/__init__.py @@ -125,6 +125,15 @@ class ComponentTestBase(object): self._capture_log(False) + @staticmethod + def check_files(reference, filelist): + """Compare two file lists""" + extra = set(filelist) - set(reference) + missing = set(reference) - set(filelist) + assert_msg = "Unexpected files: %s, Missing files: %s" % \ + (list(extra), list(missing)) + assert not extra and not missing, assert_msg + @classmethod def _check_repo_state(cls, repo, current_branch, branches, files=None): """Check that repository is clean and given branches exist""" @@ -148,10 +157,7 @@ class ComponentTestBase(object): for dirname in dirnames: local.add(os.path.relpath(os.path.join(dirpath, dirname), repo.path) + '/') - extra = local - set(files) - ok_(not extra, "Unexpected files in repo: %s" % list(extra)) - missing = set(files) - local - ok_(not missing, "Files missing from repo: %s" % list(missing)) + cls.check_files(files, local) def _capture_log(self, capture=True): """ Capture log""" diff --git a/tests/component/rpm/test_import_orig_rpm.py b/tests/component/rpm/test_import_orig_rpm.py index 465c5fa..935e995 100644 --- a/tests/component/rpm/test_import_orig_rpm.py +++ b/tests/component/rpm/test_import_orig_rpm.py @@ -96,14 +96,6 @@ class ImportOrigTestBase(ComponentTestBase): blobs = [obj[3] for obj in objs if obj[1] == 'blob'] return set(blobs) - @staticmethod - def check_files(reference, filelist): - """Compare two file lists""" - extra = set(filelist) - set(reference) - assert not extra, "Unexpected files: %s" % list(extra) - missing = set(reference) - set(filelist) - assert not missing, "Missing files: %s" % list(missing) - @classmethod def check_tree(cls, repo, treeish, filelist): """Check the contents (list of files) in a git treeish""" -- 2.7.4