ComponentTestBase: add check_files() method
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 26 Jun 2014 07:01:18 +0000 (10:01 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 14 Nov 2014 12:21:38 +0000 (14:21 +0200)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests/component/__init__.py

index 34b70ad..6eb74fc 100644 (file)
@@ -128,6 +128,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"""
@@ -151,10 +160,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"""