def __new__(cls, x): if not Luhn.verify(x): raise ValueError('Luhn checksum failed') if x < 10000000: raise ValueError('Number too short') if x > 9999999999999999999: raise ValueError('Number too long') return super(iso7812, cls).__new__(cls, x)
def test_roundtrip(self): for i in range(1000): Luhn.strip(Luhn.protect(randint(0, 2 ** 32 - 1)))
def check(n, x): print (n, x) assert Luhn.protect(n) == x
def check(n, x): print (n, x) assert Luhn.strip(n) == x
def check(n, x): print (n, x) assert Luhn.verify(n) == x
def check(n, c): print (n, c) assert Luhn.checkdigit(n) == c