From 023329c3c1dd1d167f4b58773f417ae2edeaabfc Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 18 Dec 2010 20:33:04 +0000 Subject: [PATCH] Converted Slovak localflavor doctests into unitttests. We have always been at war with doctests. Thanks to Idan Gazit. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14952 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/localflavor/sk.py | 137 ++++++++++++++---- .../regressiontests/forms/localflavortests.py | 3 +- tests/regressiontests/forms/tests/__init__.py | 1 + 3 files changed, 113 insertions(+), 28 deletions(-) diff --git a/tests/regressiontests/forms/localflavor/sk.py b/tests/regressiontests/forms/localflavor/sk.py index 069a99b2d2..a5bed6fba6 100644 --- a/tests/regressiontests/forms/localflavor/sk.py +++ b/tests/regressiontests/forms/localflavor/sk.py @@ -1,31 +1,116 @@ -# -*- coding: utf-8 -*- -# Tests for the contrib/localflavor/ SK form fields. +from django.contrib.localflavor.sk.forms import (SKRegionSelect, + SKPostalCodeField, SKDistrictSelect) -tests = r""" -# SKPostalCodeField ######################################################### +from utils import LocalFlavorTestCase ->>> from django.contrib.localflavor.sk.forms import SKPostalCodeField ->>> f = SKPostalCodeField() ->>> f.clean('84545x') -Traceback (most recent call last): -... -ValidationError: [u'Enter a postal code in the format XXXXX or XXX XX.'] ->>> f.clean('91909') -u'91909' ->>> f.clean('917 01') -u'91701' -# SKRegionSelect ############################################################ +class SKLocalFlavorTests(LocalFlavorTestCase): + def test_SKRegionSelect(self): + f = SKRegionSelect() + out = u'''''' + self.assertEqual(f.render('regions', 'TT'), out) ->>> from django.contrib.localflavor.sk.forms import SKRegionSelect ->>> w = SKRegionSelect() ->>> w.render('regions', 'TT') -u'' + def test_SKDistrictSelect(self): + f = SKDistrictSelect() + out = u'''''' + self.assertEqual(f.render('Districts', 'RK'), out) -# SKDistrictSelect ########################################################## - ->>> from django.contrib.localflavor.sk.forms import SKDistrictSelect ->>> w = SKDistrictSelect() ->>> w.render('Districts', 'RK') -u'' -""" + def test_SKPostalCodeField(self): + error_format = [u'Enter a postal code in the format XXXXX or XXX XX.'] + valid = { + '91909': '91909', + '917 01': '91701', + } + invalid = { + '84545x': error_format, + } + self.assertFieldOutput(SKPostalCodeField, valid, invalid) diff --git a/tests/regressiontests/forms/localflavortests.py b/tests/regressiontests/forms/localflavortests.py index 9f2295fff0..b2583e5a72 100644 --- a/tests/regressiontests/forms/localflavortests.py +++ b/tests/regressiontests/forms/localflavortests.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from localflavor.cz import tests as localflavor_cz_tests from localflavor.se import tests as localflavor_se_tests -from localflavor.sk import tests as localflavor_sk_tests from localflavor.uk import tests as localflavor_uk_tests from localflavor.us import tests as localflavor_us_tests from localflavor.uy import tests as localflavor_uy_tests @@ -31,13 +30,13 @@ from localflavor.nl import NLLocalFlavorTests from localflavor.pl import PLLocalFlavorTests from localflavor.pt import PTLocalFlavorTests from localflavor.ro import ROLocalFlavorTests +from localflavor.sk import SKLocalFlavorTests from localflavor.tr import TRLocalFlavorTests __test__ = { 'localflavor_cz_tests': localflavor_cz_tests, 'localflavor_se_tests': localflavor_se_tests, - 'localflavor_sk_tests': localflavor_sk_tests, 'localflavor_uk_tests': localflavor_uk_tests, 'localflavor_us_tests': localflavor_us_tests, 'localflavor_uy_tests': localflavor_uy_tests, diff --git a/tests/regressiontests/forms/tests/__init__.py b/tests/regressiontests/forms/tests/__init__.py index 6019d85e2b..51b8882c9b 100644 --- a/tests/regressiontests/forms/tests/__init__.py +++ b/tests/regressiontests/forms/tests/__init__.py @@ -37,5 +37,6 @@ from regressiontests.forms.localflavortests import ( PLLocalFlavorTests, PTLocalFlavorTests, ROLocalFlavorTests, + SKLocalFlavorTests, TRLocalFlavorTests, )