_destroy_test_db exposes the production database to possibly destructive actions from the unit tests
|Reported by:||ovidiu||Owned by:||nobody|
|Cc:||Adrian Holovaty, anssi.kaariainen@…||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Latest SVN trunk, file django.db.backends.creation.py
414 cursor = self.connection.cursor() 415 self.set_autocommit() 416 time.sleep(1) # To avoid "database is being accessed by other users" errors. 417 cursor.execute("DROP DATABASE %s" % self.connection.ops.quote_name(test_database_name)) 418 self.connection.close()
At line 414 django is connected to the production database (the rationale for this is explained in the comment above this code fragment). The connection is closed one second later. If the unit tests involve threads which for some reason become active before the connection is closed then those threads can potentially mess up the production database.