~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to tests/modeltests/choices/tests.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2010-10-12 11:34:35 UTC
  • mfrom: (4.4.9 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: james.westby@ubuntu.com-20101012113435-5rk3p18nyanuhj6g
* SECURITY UPDATE: XSS in CSRF protections. New upstream release
  - CVE-2010-3082
* debian/patches/01_disable_url_verify_regression_tests.diff:
  - updated to disable another test that fails without internet connection
  - patch based on work by Kai Kasurinen and Krzysztof Klimonda
* debian/control: don't Build-Depends on locales-all, which doesn't exist
  in maverick

Show diffs side-by-side

added added

removed removed

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