From 79ea397b5d19357a7b17c35b67e2009b92e6c6f3 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 18 Dec 2010 20:32:08 +0000 Subject: [PATCH] Converted Kuwaiti localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14947 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/localflavor/kw.py | 27 ++++++++++--------- .../regressiontests/forms/localflavortests.py | 3 +-- tests/regressiontests/forms/tests/__init__.py | 1 + 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/regressiontests/forms/localflavor/kw.py b/tests/regressiontests/forms/localflavor/kw.py index 265c1f00aeb..af998bd34b0 100644 --- a/tests/regressiontests/forms/localflavor/kw.py +++ b/tests/regressiontests/forms/localflavor/kw.py @@ -1,15 +1,16 @@ -# -*- 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 + + +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) ->>> 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'] -""" diff --git a/tests/regressiontests/forms/localflavortests.py b/tests/regressiontests/forms/localflavortests.py index d0e754de21e..56ea2d5d985 100644 --- a/tests/regressiontests/forms/localflavortests.py +++ b/tests/regressiontests/forms/localflavortests.py @@ -1,6 +1,5 @@ # -*- 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 @@ -31,12 +30,12 @@ from localflavor.il import ILLocalFlavorTests from localflavor.is_ import ISLocalFlavorTests from localflavor.it import ITLocalFlavorTests from localflavor.jp import JPLocalFlavorTests +from localflavor.kw import KWLocalFlavorTests from localflavor.tr import TRLocalFlavorTests __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, diff --git a/tests/regressiontests/forms/tests/__init__.py b/tests/regressiontests/forms/tests/__init__.py index c1e0e37df97..13b393f72ef 100644 --- a/tests/regressiontests/forms/tests/__init__.py +++ b/tests/regressiontests/forms/tests/__init__.py @@ -32,5 +32,6 @@ from regressiontests.forms.localflavortests import ( ISLocalFlavorTests, ITLocalFlavorTests, JPLocalFlavorTests, + KWLocalFlavorTests, TRLocalFlavorTests, )