~ubuntu-branches/debian/sid/python-django/sid

« back to all changes in this revision

Viewing changes to tests/choices/tests.py

  • Committer: Package Import Robot
  • Author(s): Luke Faraone
  • Date: 2013-11-07 15:33:49 UTC
  • mfrom: (1.3.12)
  • Revision ID: package-import@ubuntu.com-20131107153349-e31sc149l2szs3jb
Tags: 1.6-1
* New upstream version. Closes: #557474, #724637.
* python-django now also suggests the installation of ipython,
  bpython, python-django-doc, and libgdal1.
  Closes: #636511, #686333, #704203
* Set package maintainer to Debian Python Modules Team.
* Bump standards version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import absolute_import
 
2
 
 
3
from django.test import TestCase
 
4
 
 
5
from .models import Person
 
6
 
 
7
 
 
8
class ChoicesTests(TestCase):
 
9
    def test_display(self):
 
10
        a = Person.objects.create(name='Adrian', gender='M')
 
11
        s = Person.objects.create(name='Sara', gender='F')
 
12
        self.assertEqual(a.gender, 'M')
 
13
        self.assertEqual(s.gender, 'F')
 
14
 
 
15
        self.assertEqual(a.get_gender_display(), 'Male')
 
16
        self.assertEqual(s.get_gender_display(), 'Female')
 
17
 
 
18
        # If the value for the field doesn't correspond to a valid choice,
 
19
        # the value itself is provided as a display value.
 
20
        a.gender = ''
 
21
        self.assertEqual(a.get_gender_display(), '')
 
22
 
 
23
        a.gender = 'U'
 
24
        self.assertEqual(a.get_gender_display(), 'U')
 
25