summaryrefslogtreecommitdiff
path: root/tests/choices
diff options
context:
space:
mode:
authorMatthias Kestenholz <mk@feinheit.ch>2019-03-23 17:04:39 +0100
committerTim Graham <timograham@gmail.com>2019-03-23 12:04:39 -0400
commitea60b7bc7464808e34e3cb0aac04455fdd8545eb (patch)
tree41bb2baed64e856d167d8fe7ce9ca38376e76b9b /tests/choices
parent2ee1e1a1744c4d0679058124eb7ceba78a0a5a84 (diff)
Removed redundant model field choices tests.
Diffstat (limited to 'tests/choices')
-rw-r--r--tests/choices/__init__.py0
-rw-r--r--tests/choices/models.py25
-rw-r--r--tests/choices/tests.py25
3 files changed, 0 insertions, 50 deletions
diff --git a/tests/choices/__init__.py b/tests/choices/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/choices/__init__.py
+++ /dev/null
diff --git a/tests/choices/models.py b/tests/choices/models.py
deleted file mode 100644
index 37ef8daf60..0000000000
--- a/tests/choices/models.py
+++ /dev/null
@@ -1,25 +0,0 @@
-"""
-Specifying 'choices' for a field
-
-Most fields take a ``choices`` parameter, which should be a tuple of tuples
-specifying which are the valid values for that field.
-
-For each field that has ``choices``, a model instance gets a
-``get_fieldname_display()`` method, where ``fieldname`` is the name of the
-field. This method returns the "human-readable" value of the field.
-"""
-
-from django.db import models
-from django.utils.translation import gettext_lazy as _
-
-
-class Person(models.Model):
- GENDER_CHOICES = (
- ('M', _('Male')),
- ('F', _('Female')),
- )
- name = models.CharField(max_length=20)
- gender = models.CharField(max_length=1, choices=GENDER_CHOICES)
-
- def __str__(self):
- return self.name
diff --git a/tests/choices/tests.py b/tests/choices/tests.py
deleted file mode 100644
index 88b8bf7fe2..0000000000
--- a/tests/choices/tests.py
+++ /dev/null
@@ -1,25 +0,0 @@
-from django.test import TestCase
-
-from .models import Person
-
-
-class ChoicesTests(TestCase):
- def test_display(self):
- a = Person.objects.create(name='Adrian', gender='M')
- s = Person.objects.create(name='Sara', gender='F')
- self.assertEqual(a.gender, 'M')
- self.assertEqual(s.gender, 'F')
-
- self.assertEqual(a.get_gender_display(), 'Male')
- self.assertEqual(s.get_gender_display(), 'Female')
-
- # If the value for the field doesn't correspond to a valid choice,
- # the value itself is provided as a display value.
- a.gender = ''
- self.assertEqual(a.get_gender_display(), '')
-
- a.gender = 'U'
- self.assertEqual(a.get_gender_display(), 'U')
-
- # _get_FIELD_display() coerces lazy strings.
- self.assertIsInstance(a.get_gender_display(), str)