mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
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.
This commit is contained in:
parent
f5b635086a
commit
b181aba7dd
7 changed files with 121 additions and 41 deletions
|
@ -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.',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue