mirror of https://github.com/django/django.git
Moved test_field_ordering to the model_fields package.
This commit is contained in:
parent
92c5eeac33
commit
adb791fdcb
|
@ -5,7 +5,6 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
|
||||||
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections
|
from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections
|
||||||
from django.db.models.fields import Field
|
|
||||||
from django.db.models.manager import BaseManager
|
from django.db.models.manager import BaseManager
|
||||||
from django.db.models.query import EmptyQuerySet, QuerySet
|
from django.db.models.query import EmptyQuerySet, QuerySet
|
||||||
from django.test import (
|
from django.test import (
|
||||||
|
@ -268,22 +267,6 @@ class ModelTest(TestCase):
|
||||||
s = {a10, a11, a12}
|
s = {a10, a11, a12}
|
||||||
self.assertIn(Article.objects.get(headline='Article 11'), s)
|
self.assertIn(Article.objects.get(headline='Article 11'), s)
|
||||||
|
|
||||||
def test_field_ordering(self):
|
|
||||||
"""
|
|
||||||
Field instances have a `__lt__` comparison function to define an
|
|
||||||
ordering based on their creation. Prior to #17851 this ordering
|
|
||||||
comparison relied on the now unsupported `__cmp__` and was assuming
|
|
||||||
compared objects were both Field instances raising `AttributeError`
|
|
||||||
when it should have returned `NotImplemented`.
|
|
||||||
"""
|
|
||||||
f1 = Field()
|
|
||||||
f2 = Field(auto_created=True)
|
|
||||||
f3 = Field()
|
|
||||||
self.assertLess(f2, f1)
|
|
||||||
self.assertGreater(f3, f1)
|
|
||||||
self.assertIsNotNone(f1)
|
|
||||||
self.assertNotIn(f2, (None, 1, ''))
|
|
||||||
|
|
||||||
def test_extra_method_select_argument_with_dashes_and_values(self):
|
def test_extra_method_select_argument_with_dashes_and_values(self):
|
||||||
# The 'select' argument to extra() supports names with dashes in
|
# The 'select' argument to extra() supports names with dashes in
|
||||||
# them, as long as you use values().
|
# them, as long as you use values().
|
||||||
|
|
|
@ -59,6 +59,16 @@ class BasicFieldTests(TestCase):
|
||||||
f = Foo._meta.get_field('a')
|
f = Foo._meta.get_field('a')
|
||||||
self.assertEqual(force_str(f), 'model_fields.Foo.a')
|
self.assertEqual(force_str(f), 'model_fields.Foo.a')
|
||||||
|
|
||||||
|
def test_field_ordering(self):
|
||||||
|
"""Fields are ordered based on their creation."""
|
||||||
|
f1 = models.Field()
|
||||||
|
f2 = models.Field(auto_created=True)
|
||||||
|
f3 = models.Field()
|
||||||
|
self.assertLess(f2, f1)
|
||||||
|
self.assertGreater(f3, f1)
|
||||||
|
self.assertIsNotNone(f1)
|
||||||
|
self.assertNotIn(f2, (None, 1, ''))
|
||||||
|
|
||||||
|
|
||||||
class ChoicesTests(SimpleTestCase):
|
class ChoicesTests(SimpleTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue