Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.2.X] Converted Kuwaiti localflavor doctests to unittests. We have …

…always been at war with doctests. Thanks to Idan Gazit. Backport of [14947].

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14971 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 771ffbf0f6b728eabe1e887ffebe8f59478cbd5e 1 parent 5c3ede2
Alex Gaynor authored December 18, 2010
31  tests/regressiontests/forms/localflavor/kw.py
... ...
@@ -1,15 +1,16 @@
1  
-# -*- coding: utf-8 -*-
2  
-# Tests for the contrib/localflavor/ KW form fields.
3  
-
4  
-tests = r"""
5  
-# KWCivilIDNumberField ########################################################
6  
-
7  
->>> from django.contrib.localflavor.kw.forms import KWCivilIDNumberField
8  
->>> f = KWCivilIDNumberField()
9  
->>> f.clean('282040701483')
10  
-'282040701483'
11  
->>> f.clean('289332013455')
12  
-Traceback (most recent call last):
13  
-...
14  
-ValidationError: [u'Enter a valid Kuwaiti Civil ID number']
15  
-"""
  1
+from django.contrib.localflavor.kw.forms import KWCivilIDNumberField
  2
+
  3
+from utils import LocalFlavorTestCase
  4
+
  5
+
  6
+class KWLocalFlavorTests(LocalFlavorTestCase):
  7
+    def test_KWCivilIDNumberField(self):
  8
+        error_invalid = [u'Enter a valid Kuwaiti Civil ID number']
  9
+        valid = {
  10
+            '282040701483': '282040701483',
  11
+        }
  12
+        invalid = {
  13
+            '289332013455': error_invalid,
  14
+        }
  15
+        self.assertFieldOutput(KWCivilIDNumberField, valid, invalid)
  16
+
3  tests/regressiontests/forms/localflavortests.py
... ...
@@ -1,6 +1,5 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 from localflavor.cz import tests as localflavor_cz_tests
3  
-from localflavor.kw import tests as localflavor_kw_tests
4 3
 from localflavor.nl import tests as localflavor_nl_tests
5 4
 from localflavor.pl import tests as localflavor_pl_tests
6 5
 from localflavor.pt import tests as localflavor_pt_tests
@@ -30,11 +29,11 @@
30 29
 from localflavor.is_ import ISLocalFlavorTests
31 30
 from localflavor.it import ITLocalFlavorTests
32 31
 from localflavor.jp import JPLocalFlavorTests
  32
+from localflavor.kw import KWLocalFlavorTests
33 33
 
34 34
 
35 35
 __test__ = {
36 36
     'localflavor_cz_tests': localflavor_cz_tests,
37  
-    'localflavor_kw_tests': localflavor_kw_tests,
38 37
     'localflavor_nl_tests': localflavor_nl_tests,
39 38
     'localflavor_pl_tests': localflavor_pl_tests,
40 39
     'localflavor_pt_tests': localflavor_pt_tests,
1  tests/regressiontests/forms/tests/__init__.py
@@ -30,4 +30,5 @@
30 30
     ISLocalFlavorTests,
31 31
     ITLocalFlavorTests,
32 32
     JPLocalFlavorTests,
  33
+    KWLocalFlavorTests,
33 34
 )

0 notes on commit 771ffbf

Please sign in to comment.
Something went wrong with that request. Please try again.