diff options
| author | Tim Graham <timograham@gmail.com> | 2014-06-09 14:14:58 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-06-09 14:14:58 -0400 |
| commit | 6b97ae352170d7be47176787056239cfbacb4803 (patch) | |
| tree | bf72caf30703796153480a0427e58b8aa7e1cee0 | |
| parent | f146e70cb1cfe34a9993a9a1d95faf2bb8b15ab1 (diff) | |
Added rollback emulation to spatialite backend; refs #22487.
| -rw-r--r-- | django/contrib/gis/db/backends/spatialite/creation.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/contrib/gis/db/backends/spatialite/creation.py b/django/contrib/gis/db/backends/spatialite/creation.py index 205e601ba3..ebed0cad5c 100644 --- a/django/contrib/gis/db/backends/spatialite/creation.py +++ b/django/contrib/gis/db/backends/spatialite/creation.py @@ -7,7 +7,7 @@ from django.db.backends.sqlite3.creation import DatabaseCreation class SpatiaLiteCreation(DatabaseCreation): - def create_test_db(self, verbosity=1, autoclobber=False, keepdb=False): + def create_test_db(self, verbosity=1, autoclobber=False, serialize=True, keepdb=False): """ Creates a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created. @@ -47,6 +47,13 @@ class SpatiaLiteCreation(DatabaseCreation): database=self.connection.alias, load_initial_data=False) + # We then serialize the current state of the database into a string + # and store it on the connection. This slightly horrific process is so people + # who are testing on databases without transactions or who are using + # a TransactionTestCase still get a clean database on every test run. + if serialize: + self.connection._test_serialized_contents = self.serialize_db_to_string() + # We need to then do a flush to ensure that any data installed by # custom SQL has been removed. The only test data should come from # test fixtures, or autogenerated from post_migrate triggers. |
