Commits

shaib committed 22fe8cd Draft

Improvements in tests/logic.py
Use 'set' to compare lists (instead of sorting the lists)
Put migration history deletion into setUp where it is relevant preparation

  • Participants
  • Parent commits dc4114b

Comments (0)

Files changed (1)

File south/tests/logic.py

 
 import datetime
 import sys
+try:
+    set # builtin, python >=2.6
+except NameError:
+    from sets import Set as set # in stdlib, python >=2.3
 
 from south import exceptions
 from south.migration import migrate_app
     
     installed_apps = ["fakeapp", "otherfakeapp"]
 
+    def setUp(self):
+        super(TestMigrationLogic, self).setUp()
+        MigrationHistory.objects.all().delete()
+        
     def assertListEqual(self, list1, list2, msg=None):
-        list1 = list(list1)
-        list2 = list(list2)
-        try:
-            list1.sort()
-            list2.sort()
-        except TypeError:
-            # emulate Python 2 behavior in Python 3
-            list1 = sorted(list1, key=id)
-            list2 = sorted(list2, key=id)
+        list1 = set(list1)
+        list2 = set(list2)
         return self.assert_(list1 == list2, "%s is not equal to %s" % (list1, list2))
 
     def test_find_ghost_migrations(self):
         pass
     
     def test_apply_migrations(self):
-        MigrationHistory.objects.all().delete()
         migrations = Migrations("fakeapp")
         
         # We should start with no migrations
     
     
     def test_migration_merge_forwards(self):
-        MigrationHistory.objects.all().delete()
         migrations = Migrations("fakeapp")
         
         # We should start with no migrations