test_ar_cbu.doctest - more detailed doctests for the stdnum.ar.cbu module Copyright (C) 2016 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.ar.cbu module. It tries to validate a number of numbers that have been found online. >>> from stdnum.ar import cbu >>> from stdnum.exceptions import * These have been found online and should all be valid numbers. >>> numbers = ''' ... ... 0 0 7 0 9 9 9 0 2 0 0 0 0 0 6 5 7 0 6 0 8 0 ... 0 1 1 0 4 3 3 6 3 0 0 4 3 3 1 3 8 5 7 6 8 3 ... 0 1 4 0 3 3 9 6 0 1 6 3 0 2 0 1 3 8 1 2 7 6 ... 0 1400 236 – 01 5068 0262 5874 ... 0 4 4 0 0 6 4 – 6 – 4 0 0 0 0 1 4 2 9 4 1 0 9 – 2 ... 0 7 2 0 1 4 6 8 2 0 0 0 0 0 0 1 0 6 2 3 4 0 ... 0 7 2 0 1 6 8 0 2 0 0 0 0 0 0 1 1 8 3 2 3 6 ... 0 7 2 0 3 8 0 8 8 8 0 0 0 0 3 5 5 3 3 9 6 8 ... 0070034420000002310035 ... 0070085620000002598406 ... 0070089420000002991793 ... 0070090020000004146504 ... 0070109530004141775453 ... 0070114920000004100700 ... 0070274620000003448717 ... 0070999020000057705860 ... 0110097630009704213797 ... 0110102320010200444955 ... 0110106130010603111097 ... 0110106130010604601847 ... 0110125220012510923535 ... 0110130620013014594573 ... 0110175730017523189801 ... 0110204030020409626051 ... 0110216320021610025999 ... 0110230930023001323933 ... 0110230930023008918451 ... 0110283520028310814652 ... 0110363020036300101822 ... 0110377720037700120402 ... 0110385220038500036492 ... 0110409120040921180719 ... 0110424420042410570553 ... 0110454130045407688379 ... 0110477020047731297428 ... 0110508720050800019135 ... 0110521620052100223696 ... 0110551320055100112719 ... 0140313601697100515896 ... 0140313601697100557414 ... 0140339601630201381276 ... 0140351801684605023087 ... 0140352501684700733410 ... 0140352503684700819149 ... 0140369303631000285682 ... 0140391403672850026131 ... 0140410801680000361629 ... 0140417701630000088992 ... 0140444301650700088379 ... 0140476401626402048153 ... 01505016-02000120967405 ... 0168888-1-0000827441015-8 ... 0168888100000641080265 ... 0170074920000030293449 ... 01703342 – 200 000 3036 7766 ... 0200306901000040010097 ... 0200348901000000334779 ... 0200398411000030044362 ... 0200405501000000213951 ... 0200451211000030033962 ... 0200915901000000274233 ... 03400562 00560007577005 ... 0720000720000001681136 ... 0720079388000035942322 ... 0720297320000000081418 ... 0720402320000002633754 ... 0930301810100000992800 ... 0930301810100001043132 ... 0930310010100014278400 ... 0930324720100053299139 ... 0930324720100055211111 ... 0940099324001313220028 ... 1 5 0 0 0 0 6 0 0 0 0 0 5 6 6 0 4 4 7 2 0 0 ... 1 5 0 0 0 8 7 9 - 0 0 0 5 1 3 3 2 0 7 5 1 9 - 6 ... 1 9 1 0 1 1 9 6 5 5 0 1 1 9 0 1 0 8 4 6 4 6 ... 1910104255110401549353 ... 1910126455012600786400 ... 1910186855018601143246 ... 1910369755036901130632 ... 2850345330000000781858 ... 2850353830094127564171 ... 2850376730000059833142 ... 2850400530094105352671 ... 2850536730094125514871 ... 2850590940090418135201 ... 2850729540000001576069 ... 2850732530000002707016 ... 2850734940094696942458 ... 2850760830094054972021 ... 2850882330094054578991 ... 3110003611000000537014 ... 3110013511000600125046 ... 3300542115420000740012 ... 3300551315510001836040 ... 3860002703000000438381 ... 3860011901000020526675 ... 3860060703000013990500 ... 5729195067928761667584 ... 7362966507842824472644 ... 9498175528566296510521 ... ... ''' >>> [x for x in numbers.splitlines() if x and not cbu.is_valid(x)] [] More detailed tests: >>> cbu.validate('285059094009041') Traceback (most recent call last): ... InvalidLength: ... >>> cbu.validate('A850590940090418135201') Traceback (most recent call last): ... InvalidFormat: ... >>> cbu.validate('0940099324001313220028') '0940099324001313220028' >>> cbu.validate('1940099324001313220028') # error in first part Traceback (most recent call last): ... InvalidChecksum: ... >>> cbu.validate('0940099324001313220038') # error in second part Traceback (most recent call last): ... InvalidChecksum: ...