test_robustness.doctest - test is_valid() functions to not break Copyright (C) 2011, 2012 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 some tests for modules in the stdnum package to check whether all provided is_valid() functions can handle clearly invalid junk. >>> testvalues = ( None, '*&^%$', '', 0, False, object(), 'Q', 'QQ', '3') >>> from stdnum import grid, iban, imei, imsi, isan, isbn, isil, ismn, issn, ean >>> from stdnum import luhn, meid, verhoeff >>> from stdnum.at import uid >>> from stdnum.be import vat as be_vat >>> from stdnum.br import cpf >>> from stdnum.cy import vat as cy_vat >>> from stdnum.cz import dic, rc >>> from stdnum.de import vat as de_vat >>> from stdnum.dk import cvr >>> from stdnum.ee import kmkr >>> from stdnum.es import cif, dni, nie, nif as es_nif >>> from stdnum.fi import hetu, alv >>> from stdnum.fr import siren >>> from stdnum.gr import vat as gr_vat >>> from stdnum.hu import anum >>> from stdnum.ie import vat as ie_vat >>> from stdnum.iso7064 import mod_11_10, mod_11_2, mod_37_2, mod_37_36, mod_97_10 >>> from stdnum.it import iva >>> from stdnum.lu import tva >>> from stdnum.lv import pvn >>> from stdnum.nl import bsn, onderwijsnummer, btw >>> from stdnum.pt import nif as pt_nif >>> from stdnum.ro import cf, cnp >>> from stdnum.sk import dph >>> from stdnum.us import ssn Go over each imported module and try every value. >>> for mod in locals().values(): ... if hasattr(mod, 'is_valid'): ... results = [ x for x in testvalues if mod.is_valid(x) ] ... if results: ... print mod.__name__, results