blob: 32b67ea34bfe76e3ecb355c95384fcd62f0dc5d0 (
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
|
test_doctest - more detailed doctests for the stdnum.iso6346 package
Copyright (C) 2014 Openlabs Technologies & Consulting (P) Limited
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.iso7064 package. It
tries to test more corner cases and detailed functionality that is not
really useful as module documentation.
>>> from stdnum import iso6346
Test with valid numbers:
>>> iso6346.validate('CSQU3054383')
'CSQU3054383'
>>> iso6346.is_valid('CSQU3054383')
True
>>> iso6346.validate('csqu3054383')
'CSQU3054383'
>>> iso6346.is_valid('csQU3054383')
True
>>> iso6346.validate('tcnu7200794')
'TCNU7200794'
>>> iso6346.validate('tolu4734787')
'TOLU4734787'
Test with invalid numbers:
>>> iso6346.validate('CSQU3054384')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> iso6346.validate('CSQU305438')
Traceback (most recent call last):
...
InvalidLength: ...
>>> iso6346.is_valid('CSQU3054384')
False
>>> iso6346.validate('CSQU3054Z83')
Traceback (most recent call last):
...
InvalidFormat: ...
|