blob: 9fdcfaab8709dcadf89a9eac78e10451b53ad1d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
test_iban.doctest - more detailed doctests for the stdnum.iban module
Copyright (C) 2011-2015 Arthur de Jong
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
This file contains more detailed doctests for the stdnum.iban module. It
tries to test more corner cases and detailed functionality that is not
really useful as module documentation.
>>> from stdnum import iban
These should all be valid numbers and are from the IBAN REGISTRY as sample
numbers:
>>> numbers = '''
... AD12 0001 2030 2003 5910 0100
... AD1200012030200359100100
... AE070331234567890123456
... AL47 2121 1009 0000 0002 3569 8741
... AL47212110090000000235698741
... AT61 1904 3002 3457 3201
... AT611904300234573201
... AZ21NABZ00000000137010001944
... BA39 1290 0794 0102 8494
... BA391290079401028494
... BG80 BNBG 9661 1020 3456 78
... BG80BNBG96611020345678
... BH67BMAG00001299123456
... BR1800000000141455123924100C2
... BR9700360305000010009795493P1
... CH93 0076 2011 6238 5295 7
... CH9300762011623852957
... CY17 0020 0128 0000 0012 0052 7600
... CY17002001280000001200527600
... CZ65 0800 0000 1920 0014 5399
... CZ6508000000192000145399
... CZ94 5500 0000 0010 1103 8930
... CZ9455000000001011038930
... DE89 3704 0044 0532 0130 00
... DE89370400440532013000
... DK50 0040 0440 1162 43
... DK5000400440116243
... DO28BAGR00000001212453611324
... EE38 2200 2210 2014 5685
... EE382200221020145685
... ES 58 0049 0290 3424 1352 8341
... ES04 0075 0078 0605 0005 0355
... ES0521053014113400002160
... ES10 0075 0080 11 0600658108
... ES15-0049-1806-9121-1186-9374
... ES2030810089311100269222
... ES24 2090 3191 1400 4012 1040
... ES27 3183 1500 9600 0121 0562
... ES28 2104 0485 5390 6968 2983
... ES29 2100 2815 9822 0059 9427
... ES37 2038 8700 7861 0000 9781
... ES39 0081 0294 66 0001238624
... ES58 1465 0100 9719 0014 4593
... ES59 0049 5030 1129 1601 1246
... ES62 2100 4288 5922 0010 4465
... ES72 2013-0692-81-0201150993
... ES72 2048 1075 8334 0000 2171
... ES81 0081 5515 2900 0157 5763
... ES8521005731710200031769
... ES86 2013 0095 1102 0142 6812
... ES86 30580157682720001384
... ES88 2095 0497 9191 0708 8631
... ES91 2100 0418 4502 0005 1332
... ES9121000418450200051332
... ES98 0049 5442 2227 1606 6973
... FI21 1234 5600 0007 85
... FI2112345600000785
... FI5542345670000081
... FO62 6460 0001 6316 34
... FO6264600001631634
... FR14 2004 1010 0505 0001 3M02 606
... FR1420041010050500013M02606
... GB29 NWBK 6016 1331 9268 19
... GB29NWBK60161331926819
... GE29 NB00 0000 0101 9049 17
... GE29NB0000000101904917
... GI75 NWBK 0000 0000 7099 453
... GI75NWBK000000007099453
... GL89 6471 0001 0002 06
... GL8964710001000206
... GR16 0110 1250 0000 0001 2300 695
... GR1601101250000000012300695
... GT82TRAJ01020000001210029690
... HR12 1001 0051 8630 0016 0
... HR1210010051863000160
... HU42 1177 3016 1111 1018 0000 0000
... HU42117730161111101800000000
... IE29 AIBK 9311 5212 3456 78
... IE29AIBK93115212345678
... IL62 0108 0000 0009 9999 999
... IL620108000000099999999
... IS14 0159 2600 7654 5510 7303 39
... IS140159260076545510730339
... IT60 X054 2811 1010 0000 0123 456
... IT60X0542811101000000123456
... JO94CBJO0010000000000131000302
... KZ86125KZT5004100100
... LB62 0999 0000 0001 0019 0122 9114
... LB62099900000001001901229114
... LI21 0881 0000 2324 013A A
... LI21088100002324013AA
... LT12 1000 0111 0100 1000
... LT121000011101001000
... LU28 0019 4006 4475 0000
... LU280019400644750000
... LV80 BANK 0000 4351 9500 1
... LV80BANK0000435195001
... MC11 1273 9000 7000 1111 1000 h79
... MC1112739000700011111000h79
... MD24AG000225100013104168
... ME 25 5403 0000 2379 9201 09
... ME 2551 0000 0000 0623 4133
... ME 25510260797324001246
... ME 25525007010044076639
... ME 25535005130000020047
... ME 25540000007300246820
... ME 25550005080000004970
... ME25 5050 0001 2345 6789 51
... ME25505000012345678951
... MK072 5012 0000 0589 84
... MK07250120000058984
... MR13 0002 0001 0100 0012 3456 753
... MR1300020001010000123456753
... MT84 MALT 0110 0001 2345 MTLC AST0 01S
... MT84MALT011000012345MTLCAST001S
... MU17 BOMM 0101 1010 3030 0200 000M UR
... MU17 BOMM0101101030300200000MUR
... NL91 ABNA 0417 1643 00
... NL91ABNA0417164300
... NO93 8601 1117 947
... NO9386011117947
... PK36SCBL0000001123456702
... PL61 1090 1014 0000 0712 1981 2874
... PL61109010140000071219812874
... PS92PALS000000000400123456702
... PT50 0002 0123 1234 5678 9015 4
... PT50000201231234567890154
... QA58DOHB00001234567890ABCDEFG
... RO49 AAAA 1B31 0075 9384 0000
... RO49AAAA1B31007593840000
... RS35 2600 0560 1001 6113 79
... RS35260005601001611379
... SA03 8000 0000 6080 1016 7519
... SA0380000000608010167519
... SE45 5000 0000 0583 9825 7466
... SE4550000000058398257466
... SI56 1910 0000 0123 438
... SI56191000000123438
... SK31 1200 0000 1987 4263 7541
... SK3112000000198742637541
... SM86 U032 2509 8000 0000 0270 100
... SM86U0322509800000000270100
... TL 38 008 00123456789101 57
... TN59 1000 6035 1835 9847 8831
... TN5910006035183598478831
... TR33 0006 1005 1978 6457 8413 26
... TR330006100519786457841326
... VG96VPVG0000012345678901
... XK051212012345678906
... '''
>>> [ x for x in numbers.splitlines() if x and not iban.is_valid(x) ]
[]
These all have broken checksums or are mangled:
>>> numbers = '''
... AL48212110090000000235698741
... AD1210012030200359100100
... AT611804300234573201
... BE68530907547034
... BA391290709401028494
... BG80BNBG99611020345678
... HR1210010052863000160
... CY17002001281000001200527600
... CZ6508000000129000145399
... CZ9455000000000101038930
... DK5000400440116342
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]
These are the wrong length but otherwise have valid checksums:
>>> numbers = '''
... AD48 0001 2030 2003 5910 01
... AT93 1904 3002 3457 3201 99
... BE36 5390 0754 7034 1234
... BA30 1290 0794 0102 84
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]
These are mostly valid except that they have alphabetic characters where
they are not allowed or numbers where alphabetic characters are expected
or have an unknown country code:
>>> numbers = '''
... BG93 BNBG 9661 1A20 3456 78
... GI22 NW3K 0000 0000 7099 453
... NL56 3003 0A17 1643 00
... QQ93 1234 5678
... '''
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]
These are mostly for the normal IBAN check but they are not correct according
to the country-specific validation.
>>> numbers = '''
... ES2121000418450200051331
... ES89 3183 1500 9500 0121 0562
... '''
>>> [ x for x in numbers.splitlines() if x and not iban.is_valid(x, check_country=False) ]
[]
>>> [ x for x in numbers.splitlines() if x and iban.is_valid(x) ]
[]
|