Commits

Anonymous committed a84b930

Tests refactoring #4.

Comments (0)

Files changed (2)

                 if subindex.name == name:
                     return subindex
 
+        def __eq__(x, y):
+            assert isinstance(y, x.__class__)
+
+            if x.absolute != y.absolute: return False
+            if x.relative != y.relative: return False
+            if len(x.subindices) != len(y.subindices): return False
+
+            for xsub, ysub in zip(sorted(x.subindices), sorted(y.subindices)):
+                if xsub.value != ysub.value: return False
+                if xsub.details != ysub.details: return False
+
+            return True
+
     class SubIndex(object):
         def __init__(self, name, value, details):
             self.name = name

tests/test_store.py

         assert ('Durus', '3.4.1') in store_two.score
         durus_score_two = store_two.score[('Durus', '3.4.1')]
 
-        def check_indices(x, y):
-            assert x.absolute == y.absolute
-            assert x.relative == y.relative
-            assert len(x.subindices) == len(y.subindices)
-
-            x.subindices.sort()
-            y.subindices.sort()
-
-            for num in xrange(len(x.subindices)):
-                assert x.subindices[num].value == y.subindices[num].value
-                assert x.subindices[num].details == y.subindices[num].details
-
-        check_indices(durus_score_one.installability, durus_score_two.installability)
-        check_indices(durus_score_one.documentation, durus_score_two.documentation)
-        check_indices(durus_score_one.code_kwalitee, durus_score_two.code_kwalitee)
+        assert durus_score_one.installability == durus_score_two.installability
+        assert durus_score_one.documentation == durus_score_two.documentation
+        assert durus_score_one.code_kwalitee == durus_score_two.code_kwalitee
 
 class ReplaceReleaseScoreTest(TestCaseWithTestDatbase):
     def test_replace_release_score(self):