mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Moved tests for model Field.get_choices().
This commit is contained in:
parent
11b8c30b9e
commit
e35004966b
2 changed files with 14 additions and 12 deletions
|
@ -3,7 +3,6 @@ from unittest import skipIf
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.db import connection, models
|
||||
from django.test import SimpleTestCase, TestCase
|
||||
from django.utils.functional import lazy
|
||||
|
||||
from .models import Post
|
||||
|
||||
|
@ -50,17 +49,6 @@ class ValidationTests(SimpleTestCase):
|
|||
with self.assertRaises(ValidationError):
|
||||
f.clean('not a', None)
|
||||
|
||||
def test_charfield_get_choices_with_blank_defined(self):
|
||||
f = models.CharField(choices=[('', '<><>'), ('a', 'A')])
|
||||
self.assertEqual(f.get_choices(True), [('', '<><>'), ('a', 'A')])
|
||||
|
||||
def test_charfield_get_choices_doesnt_evaluate_lazy_strings(self):
|
||||
# Regression test for #23098
|
||||
# Will raise ZeroDivisionError if lazy is evaluated
|
||||
lazy_func = lazy(lambda x: 0 / 0, int)
|
||||
f = models.CharField(choices=[(lazy_func('group'), (('a', 'A'), ('b', 'B')))])
|
||||
self.assertEqual(f.get_choices(True)[0], ('', '---------'))
|
||||
|
||||
def test_charfield_raises_error_on_empty_input(self):
|
||||
f = models.CharField(null=False)
|
||||
with self.assertRaises(ValidationError):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue