Commits

Michael Manfre committed ff25aa4

Prevent exception when closing connection after destroying test database.

Comments (0)

Files changed (2)

source/sqlserver_ado/creation.py

             time.sleep(1) # To avoid "database is being accessed by other users" errors.
             self._disable_transactions()
             cursor.execute("DROP DATABASE %s" % self.connection.ops.quote_name(test_database_name))
+            self._reenable_transactions()
             self.connection.close()
         else:
             print "Skipping Test DB destruction"    

source/sqlserver_ado/operations.py

 
         # Turn off constraints.
         sql_list.extend(['ALTER TABLE %s NOCHECK CONSTRAINT %s;' % (
-            qn(fk[0]), qn(fk[1])) for fk in fks if fk[0] != None and fk[1] != None])
+            qn(fk[0]), qn(fk[1])) for fk in fks if fk[0] is not None and fk[1] is not None])
 
         # Delete data from tables.
         sql_list.extend(['%s %s %s;' % (
 
         # Turn constraints back on.
         sql_list.extend(['ALTER TABLE %s CHECK CONSTRAINT %s;' % (
-            qn(fk[0]), qn(fk[1])) for fk in fks if fk[0] != None and fk[1] != None])
+            qn(fk[0]), qn(fk[1])) for fk in fks if fk[0] is not None and fk[1] is not None])
 
         return sql_list