Exemple #1
0
    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)
Exemple #2
0
 def test_roundtrip(self):
     for i in range(1000):
         Luhn.strip(Luhn.protect(randint(0, 2 ** 32 - 1)))
Exemple #3
0
 def check(n, x):
     print (n, x)
     assert Luhn.protect(n) == x
Exemple #4
0
 def check(n, x):
     print (n, x)
     assert Luhn.strip(n) == x
Exemple #5
0
 def check(n, x):
     print (n, x)
     assert Luhn.verify(n) == x
Exemple #6
0
 def check(n, c):
     print (n, c)
     assert Luhn.checkdigit(n) == c