Beispiel #1
0
 def test_missing(self) -> None:
     """Determines missing digit in ISBN 10."""
     assert isbn.missing("15688?111X") == "1"
     assert isbn.missing("812071988?") == "3"
     assert isbn.missing("020161586?") == "X"
     assert isbn.missing("?131103628") == "0"
     assert isbn.missing("?86046324X") == "1"
     assert isbn.missing("1?68811306") == "5"
     assert isbn.missing("951?451570") == "4"
     assert isbn.missing("0393020?31") == "2"
     assert isbn.missing("01367440?5") == "9"
Beispiel #2
0
 def test_missing(self) -> None:
     """Determines missing digit."""
     assert isbn.missing("978186197876?") == "9"
     assert isbn.missing("9781?61978769") == "8"
     assert isbn.missing("01234567891?8") == "2"
     assert isbn.missing("0?23456789128") == "1"
     assert isbn.missing("978-074?595823") == "7"
     assert isbn.missing("978-074759582?") == "3"
     assert isbn.missing("023456789128") == "Invalid"
Beispiel #3
0
test(isbn.calculate13("012345678912"), "8")
test(isbn.calculate13("978-1-86197-876"), "9")

test(isbn.calculate13("501234567890", "upc"), "0")
test(isbn.calculate13("03600029145", "upc"), "2")
test(isbn.calculate13("89268500100", "upc"), "3")

# Validate ISBN-13
test(isbn.validate13("0123456789128"))
test(isbn.validate13("9781861978769"))
test(isbn.validate13("9-501101-530003"))
test(isbn.validate13("978-1-56619-909-4"))

# ISBN-10 Missing Digit
# Must be string due to ? and/or X
test(isbn.missing("15688?111X"), "1")
test(isbn.missing("812071988?"), "3")
test(isbn.missing("020161586?"), "X")
test(isbn.missing("?131103628"), "0")
test(isbn.missing("?86046324X"), "1")
test(isbn.missing("1?68811306"), "5")
test(isbn.missing("951?451570"), "4")
test(isbn.missing("0393020?31"), "2")
test(isbn.missing("01367440?5"), "9")

# ISBN-13 Missing Digit
test(isbn.missing("978186197876?"), "9")
test(isbn.missing("9781?61978769"), "8")
test(isbn.missing("01234567891?8"), "2")
test(isbn.missing("0?23456789128"), "1")
test(isbn.missing("978-074?595823"), "7")