diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2012-05-22 23:46:27 +0300 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2012-05-22 23:51:05 +0300 |
| commit | 0df4593f0edb8508eceff96ce5aebc59a073b506 (patch) | |
| tree | b0e9a6cd5e65c3ced3d146c81983b34d8e1b78f4 | |
| parent | 8ee1a664f9ef127bc488b03f478e8ba2f0dc7f19 (diff) | |
Fixed #18319 -- Added 'supports_sequence_reset' DB feature
Added a new feature to allow 3rd party backends to skip tests which
test sequence resetting.
Thanks to manfre for report and patch.
| -rw-r--r-- | django/db/backends/__init__.py | 3 | ||||
| -rw-r--r-- | django/db/backends/oracle/base.py | 1 | ||||
| -rw-r--r-- | tests/regressiontests/test_runner/tests.py | 11 |
3 files changed, 7 insertions, 8 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index bf622b9a0f..f26653f7b4 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -399,6 +399,9 @@ class BaseDatabaseFeatures(object): # in the SQL standard. supports_tablespaces = False + # Does the backend reset sequences between tests? + supports_sequence_reset = True + # Features that need to be confirmed at runtime # Cache whether the confirmation has been performed. _confirmed = False diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index 2f3a43d698..fe512dfee5 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -83,6 +83,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): ignores_nulls_in_unique_constraints = False has_bulk_insert = True supports_tablespaces = True + supports_sequence_reset = False class DatabaseOperations(BaseDatabaseOperations): compiler_module = "django.db.backends.oracle.compiler" diff --git a/tests/regressiontests/test_runner/tests.py b/tests/regressiontests/test_runner/tests.py index 3a8a4efe3d..05f99105aa 100644 --- a/tests/regressiontests/test_runner/tests.py +++ b/tests/regressiontests/test_runner/tests.py @@ -8,8 +8,7 @@ from optparse import make_option from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command from django import db -from django.db import connection -from django.test import simple, TransactionTestCase +from django.test import simple, TransactionTestCase, skipUnlessDBFeature from django.test.simple import DjangoTestSuiteRunner, get_tests from django.test.testcases import connections_support_transactions from django.utils import unittest @@ -291,16 +290,12 @@ class AutoIncrementResetTest(TransactionTestCase): and check that both times they get "1" as their PK value. That is, we test that AutoField values start from 1 for each transactional test case. """ - @unittest.skipIf(connection.vendor == 'oracle', - "Oracle's auto-increment fields are not reset between " - "tests") + @skipUnlessDBFeature('supports_sequence_reset') def test_autoincrement_reset1(self): p = Person.objects.create(first_name='Jack', last_name='Smith') self.assertEqual(p.pk, 1) - @unittest.skipIf(connection.vendor == 'oracle', - "Oracle's auto-increment fields are not reset between " - "tests") + @skipUnlessDBFeature('supports_sequence_reset') def test_autoincrement_reset2(self): p = Person.objects.create(first_name='Jack', last_name='Smith') self.assertEqual(p.pk, 1) |
