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 Icelandic localflavor doctests to unittests. We hav…

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

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14968 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit edcb47538101b793027bf93a32a209d1fa34577c 1 parent 56f5043
Alex Gaynor authored December 18, 2010
294  tests/regressiontests/forms/localflavor/is_.py
... ...
@@ -1,103 +1,199 @@
1  
-# -*- coding: utf-8 -*-
2  
-# Tests for the contrib/localflavor/ IS form fields.
  1
+from django.contrib.localflavor.is_.forms import (ISIdNumberField,
  2
+    ISPhoneNumberField, ISPostalCodeSelect)
3 3
 
4  
-tests = r"""
5  
-## ISIdNumberField #############################################################
  4
+from utils import LocalFlavorTestCase
6 5
 
7  
->>> from django.contrib.localflavor.is_.forms import *
8  
->>> f = ISIdNumberField()
9  
->>> f.clean('2308803449')
10  
-u'230880-3449'
11  
->>> f.clean('230880-3449')
12  
-u'230880-3449'
13  
->>> f.clean('230880 3449')
14  
-u'230880-3449'
15  
->>> f.clean('230880343')
16  
-Traceback (most recent call last):
17  
-...
18  
-ValidationError: [u'Ensure this value has at least 10 characters (it has 9).', u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
19  
->>> f.clean('230880343234')
20  
-Traceback (most recent call last):
21  
-...
22  
-ValidationError: [u'Ensure this value has at most 11 characters (it has 12).', u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
23  
->>> f.clean('abcdefghijk')
24  
-Traceback (most recent call last):
25  
-...
26  
-ValidationError: [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
27  
->>> f.clean('')
28  
-Traceback (most recent call last):
29  
-...
30  
-ValidationError: [u'This field is required.']
31  
->>> f.clean(None)
32  
-Traceback (most recent call last):
33  
-...
34  
-ValidationError: [u'This field is required.']
35  
->>> f.clean('2308803439')
36  
-Traceback (most recent call last):
37  
-...
38  
-ValidationError: [u'The Icelandic identification number is not valid.']
39  
->>> f.clean('2308803440')
40  
-u'230880-3440'
41  
->>> f = ISIdNumberField(required=False)
42  
->>> f.clean(None)
43  
-u''
44  
->>> f.clean('')
45  
-u''
46 6
 
47  
-## ISPhoneNumberField #############################################################
48  
-
49  
->>> from django.contrib.localflavor.is_.forms import *
50  
->>> f = ISPhoneNumberField()
51  
->>> f.clean('1234567')
52  
-u'1234567'
53  
->>> f.clean('123 4567')
54  
-u'1234567'
55  
->>> f.clean('123-4567')
56  
-u'1234567'
57  
->>> f.clean('123-456')
58  
-Traceback (most recent call last):
59  
-...
60  
-ValidationError: [u'Enter a valid value.']
61  
->>> f.clean('123456')
62  
-Traceback (most recent call last):
63  
-...
64  
-ValidationError: [u'Ensure this value has at least 7 characters (it has 6).', u'Enter a valid value.']
65  
->>> f.clean('123456555')
66  
-Traceback (most recent call last):
67  
-...
68  
-ValidationError: [u'Ensure this value has at most 8 characters (it has 9).', u'Enter a valid value.']
69  
->>> f.clean('abcdefg')
70  
-Traceback (most recent call last):
71  
-ValidationError: [u'Enter a valid value.']
72  
->>> f.clean(' 1234567 ')
73  
-Traceback (most recent call last):
74  
-...
75  
-ValidationError: [u'Ensure this value has at most 8 characters (it has 9).', u'Enter a valid value.']
76  
->>> f.clean(' 12367  ')
77  
-Traceback (most recent call last):
78  
-...
79  
-ValidationError: [u'Enter a valid value.']
80  
-
81  
->>> f.clean('')
82  
-Traceback (most recent call last):
83  
-...
84  
-ValidationError: [u'This field is required.']
85  
->>> f.clean(None)
86  
-Traceback (most recent call last):
87  
-...
88  
-ValidationError: [u'This field is required.']
89  
->>> f = ISPhoneNumberField(required=False)
90  
->>> f.clean(None)
91  
-u''
92  
->>> f.clean('')
93  
-u''
94  
-
95  
-## ISPostalCodeSelect #############################################################
96  
-
97  
->>> from django.contrib.localflavor.is_.forms import *
98  
->>> f = ISPostalCodeSelect()
99  
-
100  
->>> f.render('foo', 'bar')
101  
-u'<select name="foo">\n<option value="101">101 Reykjav\xedk</option>\n<option value="103">103 Reykjav\xedk</option>\n<option value="104">104 Reykjav\xedk</option>\n<option value="105">105 Reykjav\xedk</option>\n<option value="107">107 Reykjav\xedk</option>\n<option value="108">108 Reykjav\xedk</option>\n<option value="109">109 Reykjav\xedk</option>\n<option value="110">110 Reykjav\xedk</option>\n<option value="111">111 Reykjav\xedk</option>\n<option value="112">112 Reykjav\xedk</option>\n<option value="113">113 Reykjav\xedk</option>\n<option value="116">116 Kjalarnes</option>\n<option value="121">121 Reykjav\xedk</option>\n<option value="123">123 Reykjav\xedk</option>\n<option value="124">124 Reykjav\xedk</option>\n<option value="125">125 Reykjav\xedk</option>\n<option value="127">127 Reykjav\xedk</option>\n<option value="128">128 Reykjav\xedk</option>\n<option value="129">129 Reykjav\xedk</option>\n<option value="130">130 Reykjav\xedk</option>\n<option value="132">132 Reykjav\xedk</option>\n<option value="150">150 Reykjav\xedk</option>\n<option value="155">155 Reykjav\xedk</option>\n<option value="170">170 Seltjarnarnes</option>\n<option value="172">172 Seltjarnarnes</option>\n<option value="190">190 Vogar</option>\n<option value="200">200 K\xf3pavogur</option>\n<option value="201">201 K\xf3pavogur</option>\n<option value="202">202 K\xf3pavogur</option>\n<option value="203">203 K\xf3pavogur</option>\n<option value="210">210 Gar\xf0ab\xe6r</option>\n<option value="212">212 Gar\xf0ab\xe6r</option>\n<option value="220">220 Hafnarfj\xf6r\xf0ur</option>\n<option value="221">221 Hafnarfj\xf6r\xf0ur</option>\n<option value="222">222 Hafnarfj\xf6r\xf0ur</option>\n<option value="225">225 \xc1lftanes</option>\n<option value="230">230 Reykjanesb\xe6r</option>\n<option value="232">232 Reykjanesb\xe6r</option>\n<option value="233">233 Reykjanesb\xe6r</option>\n<option value="235">235 Keflav\xedkurflugv\xf6llur</option>\n<option value="240">240 Grindav\xedk</option>\n<option value="245">245 Sandger\xf0i</option>\n<option value="250">250 Gar\xf0ur</option>\n<option value="260">260 Reykjanesb\xe6r</option>\n<option value="270">270 Mosfellsb\xe6r</option>\n<option value="300">300 Akranes</option>\n<option value="301">301 Akranes</option>\n<option value="302">302 Akranes</option>\n<option value="310">310 Borgarnes</option>\n<option value="311">311 Borgarnes</option>\n<option value="320">320 Reykholt \xed Borgarfir\xf0i</option>\n<option value="340">340 Stykkish\xf3lmur</option>\n<option value="345">345 Flatey \xe1 Brei\xf0afir\xf0i</option>\n<option value="350">350 Grundarfj\xf6r\xf0ur</option>\n<option value="355">355 \xd3lafsv\xedk</option>\n<option value="356">356 Sn\xe6fellsb\xe6r</option>\n<option value="360">360 Hellissandur</option>\n<option value="370">370 B\xfa\xf0ardalur</option>\n<option value="371">371 B\xfa\xf0ardalur</option>\n<option value="380">380 Reykh\xf3lahreppur</option>\n<option value="400">400 \xcdsafj\xf6r\xf0ur</option>\n<option value="401">401 \xcdsafj\xf6r\xf0ur</option>\n<option value="410">410 Hn\xedfsdalur</option>\n<option value="415">415 Bolungarv\xedk</option>\n<option value="420">420 S\xfa\xf0av\xedk</option>\n<option value="425">425 Flateyri</option>\n<option value="430">430 Su\xf0ureyri</option>\n<option value="450">450 Patreksfj\xf6r\xf0ur</option>\n<option value="451">451 Patreksfj\xf6r\xf0ur</option>\n<option value="460">460 T\xe1lknafj\xf6r\xf0ur</option>\n<option value="465">465 B\xedldudalur</option>\n<option value="470">470 \xdeingeyri</option>\n<option value="471">471 \xdeingeyri</option>\n<option value="500">500 Sta\xf0ur</option>\n<option value="510">510 H\xf3lmav\xedk</option>\n<option value="512">512 H\xf3lmav\xedk</option>\n<option value="520">520 Drangsnes</option>\n<option value="522">522 Kj\xf6rvogur</option>\n<option value="523">523 B\xe6r</option>\n<option value="524">524 Nor\xf0urfj\xf6r\xf0ur</option>\n<option value="530">530 Hvammstangi</option>\n<option value="531">531 Hvammstangi</option>\n<option value="540">540 Bl\xf6ndu\xf3s</option>\n<option value="541">541 Bl\xf6ndu\xf3s</option>\n<option value="545">545 Skagastr\xf6nd</option>\n<option value="550">550 Sau\xf0\xe1rkr\xf3kur</option>\n<option value="551">551 Sau\xf0\xe1rkr\xf3kur</option>\n<option value="560">560 Varmahl\xed\xf0</option>\n<option value="565">565 Hofs\xf3s</option>\n<option value="566">566 Hofs\xf3s</option>\n<option value="570">570 Flj\xf3t</option>\n<option value="580">580 Siglufj\xf6r\xf0ur</option>\n<option value="600">600 Akureyri</option>\n<option value="601">601 Akureyri</option>\n<option value="602">602 Akureyri</option>\n<option value="603">603 Akureyri</option>\n<option value="610">610 Greniv\xedk</option>\n<option value="611">611 Gr\xedmsey</option>\n<option value="620">620 Dalv\xedk</option>\n<option value="621">621 Dalv\xedk</option>\n<option value="625">625 \xd3lafsfj\xf6r\xf0ur</option>\n<option value="630">630 Hr\xedsey</option>\n<option value="640">640 H\xfasav\xedk</option>\n<option value="641">641 H\xfasav\xedk</option>\n<option value="645">645 Fossh\xf3ll</option>\n<option value="650">650 Laugar</option>\n<option value="660">660 M\xfdvatn</option>\n<option value="670">670 K\xf3pasker</option>\n<option value="671">671 K\xf3pasker</option>\n<option value="675">675 Raufarh\xf6fn</option>\n<option value="680">680 \xde\xf3rsh\xf6fn</option>\n<option value="681">681 \xde\xf3rsh\xf6fn</option>\n<option value="685">685 Bakkafj\xf6r\xf0ur</option>\n<option value="690">690 Vopnafj\xf6r\xf0ur</option>\n<option value="700">700 Egilssta\xf0ir</option>\n<option value="701">701 Egilssta\xf0ir</option>\n<option value="710">710 Sey\xf0isfj\xf6r\xf0ur</option>\n<option value="715">715 Mj\xf3ifj\xf6r\xf0ur</option>\n<option value="720">720 Borgarfj\xf6r\xf0ur eystri</option>\n<option value="730">730 Rey\xf0arfj\xf6r\xf0ur</option>\n<option value="735">735 Eskifj\xf6r\xf0ur</option>\n<option value="740">740 Neskaupsta\xf0ur</option>\n<option value="750">750 F\xe1skr\xfa\xf0sfj\xf6r\xf0ur</option>\n<option value="755">755 St\xf6\xf0varfj\xf6r\xf0ur</option>\n<option value="760">760 Brei\xf0dalsv\xedk</option>\n<option value="765">765 Dj\xfapivogur</option>\n<option value="780">780 H\xf6fn \xed Hornafir\xf0i</option>\n<option value="781">781 H\xf6fn \xed Hornafir\xf0i</option>\n<option value="785">785 \xd6r\xe6fi</option>\n<option value="800">800 Selfoss</option>\n<option value="801">801 Selfoss</option>\n<option value="802">802 Selfoss</option>\n<option value="810">810 Hverager\xf0i</option>\n<option value="815">815 \xdeorl\xe1ksh\xf6fn</option>\n<option value="820">820 Eyrarbakki</option>\n<option value="825">825 Stokkseyri</option>\n<option value="840">840 Laugarvatn</option>\n<option value="845">845 Fl\xfa\xf0ir</option>\n<option value="850">850 Hella</option>\n<option value="851">851 Hella</option>\n<option value="860">860 Hvolsv\xf6llur</option>\n<option value="861">861 Hvolsv\xf6llur</option>\n<option value="870">870 V\xedk</option>\n<option value="871">871 V\xedk</option>\n<option value="880">880 Kirkjub\xe6jarklaustur</option>\n<option value="900">900 Vestmannaeyjar</option>\n<option value="902">902 Vestmannaeyjar</option>\n</select>'
102  
-"""
  7
+class ISLocalFlavorTests(LocalFlavorTestCase):
  8
+    def test_ISPostalCodeSelect(self):
  9
+        f = ISPostalCodeSelect()
  10
+        out = u'''<select name="foo">
  11
+<option value="101">101 Reykjav\xedk</option>
  12
+<option value="103">103 Reykjav\xedk</option>
  13
+<option value="104">104 Reykjav\xedk</option>
  14
+<option value="105">105 Reykjav\xedk</option>
  15
+<option value="107">107 Reykjav\xedk</option>
  16
+<option value="108">108 Reykjav\xedk</option>
  17
+<option value="109">109 Reykjav\xedk</option>
  18
+<option value="110">110 Reykjav\xedk</option>
  19
+<option value="111">111 Reykjav\xedk</option>
  20
+<option value="112">112 Reykjav\xedk</option>
  21
+<option value="113">113 Reykjav\xedk</option>
  22
+<option value="116">116 Kjalarnes</option>
  23
+<option value="121">121 Reykjav\xedk</option>
  24
+<option value="123">123 Reykjav\xedk</option>
  25
+<option value="124">124 Reykjav\xedk</option>
  26
+<option value="125">125 Reykjav\xedk</option>
  27
+<option value="127">127 Reykjav\xedk</option>
  28
+<option value="128">128 Reykjav\xedk</option>
  29
+<option value="129">129 Reykjav\xedk</option>
  30
+<option value="130">130 Reykjav\xedk</option>
  31
+<option value="132">132 Reykjav\xedk</option>
  32
+<option value="150">150 Reykjav\xedk</option>
  33
+<option value="155">155 Reykjav\xedk</option>
  34
+<option value="170">170 Seltjarnarnes</option>
  35
+<option value="172">172 Seltjarnarnes</option>
  36
+<option value="190">190 Vogar</option>
  37
+<option value="200">200 K\xf3pavogur</option>
  38
+<option value="201">201 K\xf3pavogur</option>
  39
+<option value="202">202 K\xf3pavogur</option>
  40
+<option value="203">203 K\xf3pavogur</option>
  41
+<option value="210">210 Gar\xf0ab\xe6r</option>
  42
+<option value="212">212 Gar\xf0ab\xe6r</option>
  43
+<option value="220">220 Hafnarfj\xf6r\xf0ur</option>
  44
+<option value="221">221 Hafnarfj\xf6r\xf0ur</option>
  45
+<option value="222">222 Hafnarfj\xf6r\xf0ur</option>
  46
+<option value="225">225 \xc1lftanes</option>
  47
+<option value="230">230 Reykjanesb\xe6r</option>
  48
+<option value="232">232 Reykjanesb\xe6r</option>
  49
+<option value="233">233 Reykjanesb\xe6r</option>
  50
+<option value="235">235 Keflav\xedkurflugv\xf6llur</option>
  51
+<option value="240">240 Grindav\xedk</option>
  52
+<option value="245">245 Sandger\xf0i</option>
  53
+<option value="250">250 Gar\xf0ur</option>
  54
+<option value="260">260 Reykjanesb\xe6r</option>
  55
+<option value="270">270 Mosfellsb\xe6r</option>
  56
+<option value="300">300 Akranes</option>
  57
+<option value="301">301 Akranes</option>
  58
+<option value="302">302 Akranes</option>
  59
+<option value="310">310 Borgarnes</option>
  60
+<option value="311">311 Borgarnes</option>
  61
+<option value="320">320 Reykholt \xed Borgarfir\xf0i</option>
  62
+<option value="340">340 Stykkish\xf3lmur</option>
  63
+<option value="345">345 Flatey \xe1 Brei\xf0afir\xf0i</option>
  64
+<option value="350">350 Grundarfj\xf6r\xf0ur</option>
  65
+<option value="355">355 \xd3lafsv\xedk</option>
  66
+<option value="356">356 Sn\xe6fellsb\xe6r</option>
  67
+<option value="360">360 Hellissandur</option>
  68
+<option value="370">370 B\xfa\xf0ardalur</option>
  69
+<option value="371">371 B\xfa\xf0ardalur</option>
  70
+<option value="380">380 Reykh\xf3lahreppur</option>
  71
+<option value="400">400 \xcdsafj\xf6r\xf0ur</option>
  72
+<option value="401">401 \xcdsafj\xf6r\xf0ur</option>
  73
+<option value="410">410 Hn\xedfsdalur</option>
  74
+<option value="415">415 Bolungarv\xedk</option>
  75
+<option value="420">420 S\xfa\xf0av\xedk</option>
  76
+<option value="425">425 Flateyri</option>
  77
+<option value="430">430 Su\xf0ureyri</option>
  78
+<option value="450">450 Patreksfj\xf6r\xf0ur</option>
  79
+<option value="451">451 Patreksfj\xf6r\xf0ur</option>
  80
+<option value="460">460 T\xe1lknafj\xf6r\xf0ur</option>
  81
+<option value="465">465 B\xedldudalur</option>
  82
+<option value="470">470 \xdeingeyri</option>
  83
+<option value="471">471 \xdeingeyri</option>
  84
+<option value="500">500 Sta\xf0ur</option>
  85
+<option value="510">510 H\xf3lmav\xedk</option>
  86
+<option value="512">512 H\xf3lmav\xedk</option>
  87
+<option value="520">520 Drangsnes</option>
  88
+<option value="522">522 Kj\xf6rvogur</option>
  89
+<option value="523">523 B\xe6r</option>
  90
+<option value="524">524 Nor\xf0urfj\xf6r\xf0ur</option>
  91
+<option value="530">530 Hvammstangi</option>
  92
+<option value="531">531 Hvammstangi</option>
  93
+<option value="540">540 Bl\xf6ndu\xf3s</option>
  94
+<option value="541">541 Bl\xf6ndu\xf3s</option>
  95
+<option value="545">545 Skagastr\xf6nd</option>
  96
+<option value="550">550 Sau\xf0\xe1rkr\xf3kur</option>
  97
+<option value="551">551 Sau\xf0\xe1rkr\xf3kur</option>
  98
+<option value="560">560 Varmahl\xed\xf0</option>
  99
+<option value="565">565 Hofs\xf3s</option>
  100
+<option value="566">566 Hofs\xf3s</option>
  101
+<option value="570">570 Flj\xf3t</option>
  102
+<option value="580">580 Siglufj\xf6r\xf0ur</option>
  103
+<option value="600">600 Akureyri</option>
  104
+<option value="601">601 Akureyri</option>
  105
+<option value="602">602 Akureyri</option>
  106
+<option value="603">603 Akureyri</option>
  107
+<option value="610">610 Greniv\xedk</option>
  108
+<option value="611">611 Gr\xedmsey</option>
  109
+<option value="620">620 Dalv\xedk</option>
  110
+<option value="621">621 Dalv\xedk</option>
  111
+<option value="625">625 \xd3lafsfj\xf6r\xf0ur</option>
  112
+<option value="630">630 Hr\xedsey</option>
  113
+<option value="640">640 H\xfasav\xedk</option>
  114
+<option value="641">641 H\xfasav\xedk</option>
  115
+<option value="645">645 Fossh\xf3ll</option>
  116
+<option value="650">650 Laugar</option>
  117
+<option value="660">660 M\xfdvatn</option>
  118
+<option value="670">670 K\xf3pasker</option>
  119
+<option value="671">671 K\xf3pasker</option>
  120
+<option value="675">675 Raufarh\xf6fn</option>
  121
+<option value="680">680 \xde\xf3rsh\xf6fn</option>
  122
+<option value="681">681 \xde\xf3rsh\xf6fn</option>
  123
+<option value="685">685 Bakkafj\xf6r\xf0ur</option>
  124
+<option value="690">690 Vopnafj\xf6r\xf0ur</option>
  125
+<option value="700">700 Egilssta\xf0ir</option>
  126
+<option value="701">701 Egilssta\xf0ir</option>
  127
+<option value="710">710 Sey\xf0isfj\xf6r\xf0ur</option>
  128
+<option value="715">715 Mj\xf3ifj\xf6r\xf0ur</option>
  129
+<option value="720">720 Borgarfj\xf6r\xf0ur eystri</option>
  130
+<option value="730">730 Rey\xf0arfj\xf6r\xf0ur</option>
  131
+<option value="735">735 Eskifj\xf6r\xf0ur</option>
  132
+<option value="740">740 Neskaupsta\xf0ur</option>
  133
+<option value="750">750 F\xe1skr\xfa\xf0sfj\xf6r\xf0ur</option>
  134
+<option value="755">755 St\xf6\xf0varfj\xf6r\xf0ur</option>
  135
+<option value="760">760 Brei\xf0dalsv\xedk</option>
  136
+<option value="765">765 Dj\xfapivogur</option>
  137
+<option value="780">780 H\xf6fn \xed Hornafir\xf0i</option>
  138
+<option value="781">781 H\xf6fn \xed Hornafir\xf0i</option>
  139
+<option value="785">785 \xd6r\xe6fi</option>
  140
+<option value="800">800 Selfoss</option>
  141
+<option value="801">801 Selfoss</option>
  142
+<option value="802">802 Selfoss</option>
  143
+<option value="810">810 Hverager\xf0i</option>
  144
+<option value="815">815 \xdeorl\xe1ksh\xf6fn</option>
  145
+<option value="820">820 Eyrarbakki</option>
  146
+<option value="825">825 Stokkseyri</option>
  147
+<option value="840">840 Laugarvatn</option>
  148
+<option value="845">845 Fl\xfa\xf0ir</option>
  149
+<option value="850">850 Hella</option>
  150
+<option value="851">851 Hella</option>
  151
+<option value="860">860 Hvolsv\xf6llur</option>
  152
+<option value="861">861 Hvolsv\xf6llur</option>
  153
+<option value="870">870 V\xedk</option>
  154
+<option value="871">871 V\xedk</option>
  155
+<option value="880">880 Kirkjub\xe6jarklaustur</option>
  156
+<option value="900">900 Vestmannaeyjar</option>
  157
+<option value="902">902 Vestmannaeyjar</option>
  158
+</select>'''
  159
+        self.assertEqual(f.render('foo', 'bar'), out)
  160
+    
  161
+    def test_ISIdNumberField(self):
  162
+        error_atleast = [u'Ensure this value has at least 10 characters (it has 9).']
  163
+        error_invalid = [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
  164
+        error_atmost = [u'Ensure this value has at most 11 characters (it has 12).']
  165
+        error_notvalid = [u'The Icelandic identification number is not valid.']
  166
+        valid = {
  167
+            '2308803449': '230880-3449',
  168
+            '230880-3449': '230880-3449',
  169
+            '230880 3449': '230880-3449',
  170
+            '2308803440': '230880-3440',
  171
+        }
  172
+        invalid = {
  173
+            '230880343': error_atleast + error_invalid,
  174
+            '230880343234': error_atmost + error_invalid,
  175
+            'abcdefghijk': error_invalid,
  176
+            '2308803439': error_notvalid,
  177
+        
  178
+        }
  179
+        self.assertFieldOutput(ISIdNumberField, valid, invalid)
  180
+    
  181
+    def test_ISPhoneNumberField(self):
  182
+        error_invalid = [u'Enter a valid value.']
  183
+        error_atleast = [u'Ensure this value has at least 7 characters (it has 6).']
  184
+        error_atmost = [u'Ensure this value has at most 8 characters (it has 9).']
  185
+        valid = {
  186
+            '1234567': '1234567',
  187
+            '123 4567': '1234567',
  188
+            '123-4567': '1234567',
  189
+        }
  190
+        invalid = {
  191
+            '123-456': error_invalid,
  192
+            '123456': error_atleast + error_invalid,
  193
+            '123456555': error_atmost + error_invalid,
  194
+            'abcdefg': error_invalid,
  195
+            ' 1234567 ': error_atmost + error_invalid,
  196
+            ' 12367  ': error_invalid
  197
+        }
  198
+        self.assertFieldOutput(ISPhoneNumberField, valid, invalid)
103 199
 
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.is_ import tests as localflavor_is_tests
4 3
 from localflavor.it import tests as localflavor_it_tests
5 4
 from localflavor.jp import tests as localflavor_jp_tests
6 5
 from localflavor.kw import tests as localflavor_kw_tests
@@ -30,11 +29,11 @@
30 29
 from localflavor.generic import GenericLocalFlavorTests
31 30
 from localflavor.id import IDLocalFlavorTests
32 31
 from localflavor.ie import IELocalFlavorTests
  32
+from localflavor.is_ import ISLocalFlavorTests
33 33
 
34 34
 
35 35
 __test__ = {
36 36
     'localflavor_cz_tests': localflavor_cz_tests,
37  
-    'localflavor_is_tests': localflavor_is_tests,
38 37
     'localflavor_it_tests': localflavor_it_tests,
39 38
     'localflavor_jp_tests': localflavor_jp_tests,
40 39
     'localflavor_kw_tests': localflavor_kw_tests,
1  tests/regressiontests/forms/tests/__init__.py
@@ -27,4 +27,5 @@
27 27
     GenericLocalFlavorTests,
28 28
     IDLocalFlavorTests,
29 29
     IELocalFlavorTests,
  30
+    ISLocalFlavorTests,
30 31
 )

0 notes on commit edcb475

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