Commits

shaib committed a7c424c

Make some test more Sql-Server friendly

  • Participants
  • Parent commits e4000c4

Comments (0)

Files changed (1)

File south/tests/logic.py

 import unittest
 
 import datetime
+import sys
 
 from south import exceptions
 from south.migration import migrate_app
     
     def test_alter_column_null(self):
         
-        def null_ok():
+        def null_ok(eat_exception=True):
             from django.db import connection, transaction
             # the DBAPI introspection module fails on postgres NULLs.
             cursor = connection.cursor()
             # SQLite has weird now()
             if db.backend_name == "sqlite3":
                 now_func = "DATETIME('NOW')"
+            # So does SQLServer... should we be using a backend attribute?
+            elif db.backend_name == "pyodbc":
+                now_func = "GETDATE()"
             else:
                 now_func = "NOW()"
             
             try:
                 cursor.execute("INSERT INTO southtest_spam (id, weight, expires, name) VALUES (100, 10.1, %s, NULL);" % now_func)
             except:
-                transaction.rollback()
-                return False
+                if eat_exception:
+                    transaction.rollback()
+                    return False
+                else:
+                    raise
             else:
                 cursor.execute("DELETE FROM southtest_spam")
                 transaction.commit()
         
         # after 0003, it should be NULL
         migrate_app(migrations, target_name="0003", fake=False)
-        self.assert_(null_ok())
+        self.assert_(null_ok(False))
         self.assertListEqual(
             ((u"fakeapp", u"0001_spam"),
              (u"fakeapp", u"0002_eggs"),