Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_iban_allow_invalid(number):
iban = IBAN(number, allow_invalid=True)
with pytest.raises(ValueError):
iban.validate()
def test_parse_iban(number):
iban = IBAN(number)
assert iban.formatted == number
def test_iban_properties():
iban = IBAN("DE42430609677000534100")
assert iban.bank_code == "43060967"
assert iban.branch_code == ""
assert iban.account_code == "7000534100"
assert iban.country_code == "DE"
assert iban.bic == "GENODEM1GLS"
assert iban.formatted == "DE42 4306 0967 7000 5341 00"
assert iban.length == 22
assert iban.country == countries.get(alpha_2="DE")
def test_magic_methods():
iban = IBAN("DE42430609677000534100")
assert iban == "DE42430609677000534100"
assert iban == IBAN("DE42430609677000534100")
assert iban != IBAN("ES9121000418450200051332")
assert iban < IBAN("ES9121000418450200051332")
assert str(iban) == "DE42430609677000534100"
assert hash(iban) == hash("DE42430609677000534100")
assert repr(iban) == ""
def test_invalid_iban(number):
with pytest.raises(ValueError):
IBAN(number)
def test_magic_methods():
iban = IBAN("DE42430609677000534100")
assert iban == "DE42430609677000534100"
assert iban == IBAN("DE42430609677000534100")
assert iban != IBAN("ES9121000418450200051332")
assert iban < IBAN("ES9121000418450200051332")
assert str(iban) == "DE42430609677000534100"
assert hash(iban) == hash("DE42430609677000534100")
assert repr(iban) == ""
def test_magic_methods():
iban = IBAN("DE42430609677000534100")
assert iban == "DE42430609677000534100"
assert iban == IBAN("DE42430609677000534100")
assert iban != IBAN("ES9121000418450200051332")
assert iban < IBAN("ES9121000418450200051332")
assert str(iban) == "DE42430609677000534100"
assert hash(iban) == hash("DE42430609677000534100")
assert repr(iban) == ""
def test_magic_methods():
iban = IBAN("DE42430609677000534100")
assert iban == "DE42430609677000534100"
assert iban == IBAN("DE42430609677000534100")
assert iban != IBAN("ES9121000418450200051332")
assert iban < IBAN("ES9121000418450200051332")
assert str(iban) == "DE42430609677000534100"
assert hash(iban) == hash("DE42430609677000534100")
assert repr(iban) == ""
def __init__(self, ctx, label, start, end):
super(IBANResult, self).__init__(ctx, label, start, end)
try:
iban = IBAN(label)
self.key = self.label = iban.compact
self.countries = [iban.country_code]
except ValueError:
self.valid = False
def iban_parsed(self):
with suppress(ValueError):
if self.iban:
return IBAN(self.iban)
return None