summaryrefslogtreecommitdiff
path: root/tests/invalid_models_tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-01-12 16:14:54 -0500
committerTim Graham <timograham@gmail.com>2019-01-14 16:16:30 -0500
commitb181aba7dd24c73ec9923c39e35393b0487a5f47 (patch)
treee5d82ea665a4b6eace3e07fb53d78808b936c624 /tests/invalid_models_tests
parentf5b635086a07c9df5897e69685ebdc3a04049ec6 (diff)
Refs #28478 -- Prevented database feature based skipping on tests disallowing queries.
Database features may require a connection to be established to determine whether or not they are enabled.
Diffstat (limited to 'tests/invalid_models_tests')
-rw-r--r--tests/invalid_models_tests/test_ordinary_fields.py4
-rw-r--r--tests/invalid_models_tests/test_relative_fields.py11
2 files changed, 9 insertions, 6 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py
index 3922c835b9..9c7cf7f88c 100644
--- a/tests/invalid_models_tests/test_ordinary_fields.py
+++ b/tests/invalid_models_tests/test_ordinary_fields.py
@@ -2,7 +2,7 @@ import unittest
from django.core.checks import Error, Warning as DjangoWarning
from django.db import connection, models
-from django.test import SimpleTestCase, skipIfDBFeature
+from django.test import SimpleTestCase, TestCase, skipIfDBFeature
from django.test.utils import isolate_apps, override_settings
from django.utils.functional import lazy
from django.utils.timezone import now
@@ -680,7 +680,7 @@ class TimeFieldTests(SimpleTestCase):
@isolate_apps('invalid_models_tests')
-class TextFieldTests(SimpleTestCase):
+class TextFieldTests(TestCase):
@skipIfDBFeature('supports_index_on_text_field')
def test_max_length_warning(self):
diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py
index cf1b3f737b..e68dd41c6f 100644
--- a/tests/invalid_models_tests/test_relative_fields.py
+++ b/tests/invalid_models_tests/test_relative_fields.py
@@ -1,7 +1,9 @@
+from unittest import mock
+
from django.core.checks import Error, Warning as DjangoWarning
-from django.db import models
+from django.db import connection, models
from django.db.models.fields.related import ForeignObject
-from django.test.testcases import SimpleTestCase, skipIfDBFeature
+from django.test.testcases import SimpleTestCase
from django.test.utils import isolate_apps, override_settings
@@ -501,13 +503,14 @@ class RelativeFieldTests(SimpleTestCase):
),
])
- @skipIfDBFeature('interprets_empty_strings_as_nulls')
def test_nullable_primary_key(self):
class Model(models.Model):
field = models.IntegerField(primary_key=True, null=True)
field = Model._meta.get_field('field')
- self.assertEqual(field.check(), [
+ with mock.patch.object(connection.features, 'interprets_empty_strings_as_nulls', False):
+ results = field.check()
+ self.assertEqual(results, [
Error(
'Primary keys must not have null=True.',
hint='Set null=False on the field, or remove primary_key=True argument.',