Commits

Al...@bcc190cf-cafb-0310-a4f2-bffc1f526a37  committed be01a43

[1.2.X] Converted Kuwaiti localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit. Backport of [14947].

  • Participants
  • Parent commits 3709cdb
  • Branches releases/1.2.X

Comments (0)

Files changed (3)

File tests/regressiontests/forms/localflavor/kw.py

-# -*- coding: utf-8 -*-
-# Tests for the contrib/localflavor/ KW form fields.
+from django.contrib.localflavor.kw.forms import KWCivilIDNumberField
 
-tests = r"""
-# KWCivilIDNumberField ########################################################
+from utils import LocalFlavorTestCase
 
->>> from django.contrib.localflavor.kw.forms import KWCivilIDNumberField
->>> f = KWCivilIDNumberField()
->>> f.clean('282040701483')
-'282040701483'
->>> f.clean('289332013455')
-Traceback (most recent call last):
-...
-ValidationError: [u'Enter a valid Kuwaiti Civil ID number']
-"""
+
+class KWLocalFlavorTests(LocalFlavorTestCase):
+    def test_KWCivilIDNumberField(self):
+        error_invalid = [u'Enter a valid Kuwaiti Civil ID number']
+        valid = {
+            '282040701483': '282040701483',
+        }
+        invalid = {
+            '289332013455': error_invalid,
+        }
+        self.assertFieldOutput(KWCivilIDNumberField, valid, invalid)
+

File tests/regressiontests/forms/localflavortests.py

 # -*- coding: utf-8 -*-
 from localflavor.cz import tests as localflavor_cz_tests
-from localflavor.kw import tests as localflavor_kw_tests
 from localflavor.nl import tests as localflavor_nl_tests
 from localflavor.pl import tests as localflavor_pl_tests
 from localflavor.pt import tests as localflavor_pt_tests
 from localflavor.is_ import ISLocalFlavorTests
 from localflavor.it import ITLocalFlavorTests
 from localflavor.jp import JPLocalFlavorTests
+from localflavor.kw import KWLocalFlavorTests
 
 
 __test__ = {
     'localflavor_cz_tests': localflavor_cz_tests,
-    'localflavor_kw_tests': localflavor_kw_tests,
     'localflavor_nl_tests': localflavor_nl_tests,
     'localflavor_pl_tests': localflavor_pl_tests,
     'localflavor_pt_tests': localflavor_pt_tests,

File tests/regressiontests/forms/tests/__init__.py

     ISLocalFlavorTests,
     ITLocalFlavorTests,
     JPLocalFlavorTests,
+    KWLocalFlavorTests,
 )