def test_general(self): """Test things that apply both to ISBN10 and ISBN13.""" # getIsbn self.assertIsInstance(getIsbn('097522980x'), ISBN10) self.assertIsInstance(getIsbn('9783161484100'), ISBN13) self.assertRaisesRegex( IsbnExc, 'ISBN-13: The ISBN 097522 is not 13 digits ' 'long. / ISBN-10: The ISBN 097522 is not 10 ' 'digits long.', getIsbn, '097522') # hyphenateIsbnNumbers self.assertEqual(hyphenateIsbnNumbers('ISBN 097522980x'), 'ISBN 0-9752298-0-X') self.assertEqual(hyphenateIsbnNumbers('ISBN 0975229801'), 'ISBN 0975229801') # Invalid ISBN - no changes # convertIsbn10toIsbn13 self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-X'), 'ISBN 978-0-9752298-0-4') self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-1'), 'ISBN 0-9752298-0-1') # Invalid ISBN - no changes # Errors isbn = ISBN10('9492098059') self.assertRaisesRegex(IsbnExc, 'ISBN 9492098059: group number unknown.', isbn.format) isbn = ISBN10('9095012042') self.assertRaisesRegex(IsbnExc, 'ISBN 9095012042: publisher number unknown.', isbn.format)
def test_general(self): """Test things that apply both to ISBN10 and ISBN13.""" # getIsbn self.assertIsInstance(getIsbn('097522980x'), ISBN10) self.assertIsInstance(getIsbn('9783161484100'), ISBN13) self.assertRaisesRegex(IsbnExc, 'ISBN-13: The ISBN 097522 is not 13 digits ' 'long. / ISBN-10: The ISBN 097522 is not 10 ' 'digits long.', getIsbn, '097522') # hyphenateIsbnNumbers self.assertEqual(hyphenateIsbnNumbers('ISBN 097522980x'), 'ISBN 0-9752298-0-X') self.assertEqual(hyphenateIsbnNumbers('ISBN 0975229801'), 'ISBN 0975229801') # Invalid ISBN - no changes # convertIsbn10toIsbn13 self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-X'), 'ISBN 978-0-9752298-0-4') self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-1'), 'ISBN 0-9752298-0-1') # Invalid ISBN - no changes # Errors isbn = ISBN10('9492098059') self.assertRaisesRegex(IsbnExc, 'ISBN 9492098059: group number unknown.', isbn.format) isbn = ISBN10('9095012042') self.assertRaisesRegex(IsbnExc, 'ISBN 9095012042: publisher number unknown.', isbn.format)
def test_general(self): """Test things that apply both to ISBN10 and ISBN13.""" # getIsbn self.assertIsInstance(getIsbn("097522980x"), ISBN10) self.assertIsInstance(getIsbn("9783161484100"), ISBN13) self.assertRaisesRegex( IsbnExc, "ISBN-13: The ISBN 097522 is not 13 digits " "long. / ISBN-10: The ISBN 097522 is not 10 " "digits long.", getIsbn, "097522", ) # hyphenateIsbnNumbers self.assertEqual(hyphenateIsbnNumbers("ISBN 097522980x"), "ISBN 0-9752298-0-X") self.assertEqual(hyphenateIsbnNumbers("ISBN 0975229801"), "ISBN 0975229801") # Invalid ISBN - no changes # convertIsbn10toIsbn13 self.assertEqual(convertIsbn10toIsbn13("ISBN 0-9752298-0-X"), "ISBN 978-0-9752298-0-4") self.assertEqual(convertIsbn10toIsbn13("ISBN 0-9752298-0-1"), "ISBN 0-9752298-0-1") # Invalid ISBN - no changes # Errors isbn = ISBN10("9492098059") self.assertRaisesRegex(IsbnExc, "ISBN 9492098059: group number unknown.", isbn.format) isbn = ISBN10("9095012042") self.assertRaisesRegex(IsbnExc, "ISBN 9095012042: publisher number unknown.", isbn.format)
def test_general(self): """Test things that apply both to ISBN10 and ISBN13.""" # hyphenateIsbnNumbers self.assertEqual(hyphenateIsbnNumbers('ISBN 097522980x'), 'ISBN 0-9752298-0-X') self.assertEqual(hyphenateIsbnNumbers('ISBN 0975229801'), 'ISBN 0975229801') # Invalid ISBN - no changes # convertIsbn10toIsbn13 self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-X'), 'ISBN 978-0-9752298-0-4') self.assertEqual(convertIsbn10toIsbn13('ISBN 0-9752298-0-1'), 'ISBN 0-9752298-0-1') # Invalid ISBN - no changes # Should not fail for ISBN13 self.assertEqual(convertIsbn10toIsbn13('ISBN 978-0-7869-3669-4'), 'ISBN 978-0-7869-3669-4')
def test_general_failing(self): """Test things that apply both to ISBN10 and ISBN13. This test fails due to outdated libraries. """ # hyphenateIsbnNumbers self.assertEqual(hyphenateIsbnNumbers('ISBN 9791091447089'), 'ISBN 979-10-91447-08-9') # convertIsbn10toIsbn13 self.assertEqual(convertIsbn10toIsbn13('ISBN 10-91447-08-X'), 'ISBN 979-10-91447-08-9')