def test_isbn13(self): """Test ISBN13.""" # Test general features isbn = ISBN13('9783161484100') isbn.format() self.assertEqual(isbn.code, '978-3-16-148410-0') self.assertEqual(isbn.digits(), [9, 7, 8, 3, 1, 6, 1, 4, 8, 4, 1, 0, 0]) isbn = ISBN13('978809027341', checksumMissing=True) self.assertEqual(isbn.code, '9788090273412') # Errors self.assertRaises(IsbnExc, ISBN13, '9783161484LOL') # Invalid chars self.assertRaises(IsbnExc, ISBN13, '9783161484105') # Invalid checksum self.assertRaises(IsbnExc, ISBN13, '9783161484') # Invalid length
def test_isbn13_979(self): """Test ISBN13 with prefix 979.""" isbn = ISBN13('9791091447089') isbn.format() self.assertEqual(isbn.code, '979-10-91447-08-9') self.assertEqual(isbn.digits(), [9, 7, 9, 1, 0, 9, 1, 4, 4, 7, 0, 8, 9])