Exemplo n.º 1
0
def test__isbn_cleanse_reflect_type(isbn):
    expect(type(_isbn_cleanse(isbn))) == type(isbn)
Exemplo n.º 2
0
def test__isbn_cleanse_invalid_type():
    with expect.raises(TypeError, "ISBN must be a string, received 2"):
        _isbn_cleanse(2)
Exemplo n.º 3
0
def test__isbn_cleanse_isbn(isbn):
    expect(_isbn_cleanse(isbn)) == isbn.replace('-', '')
    expect(_isbn_cleanse(isbn[:-1], False)) == isbn.replace('-', '')[:-1]
Exemplo n.º 4
0
def test__isbn_cleanse_unicode_dash(isbn):
    expect(_isbn_cleanse(isbn)) == "".join(filter(lambda s: s.isdigit(), isbn))
Exemplo n.º 5
0
def test_issue_16_bookland(isbn):
    with raises(IsbnError, match='Bookland'):
        _isbn_cleanse(isbn)
Exemplo n.º 6
0
def test__isbn_cleanse_sbn(isbn):
    if isbn.startswith('0'):
        expect(_isbn_cleanse(isbn[1:])) == isbn.replace('-', '')
        expect(_isbn_cleanse(isbn[1:-1], False)) == isbn.replace('-', '')[:-1]
Exemplo n.º 7
0
def test_issue_7_unistr(isbn):
    expect(_isbn_cleanse(isbn)) == "".join(filter(lambda s: s.isdigit(), isbn))
Exemplo n.º 8
0
def test__isbn_cleanse_isbn(isbn):
    assert _isbn_cleanse(isbn) == isbn
    assert _isbn_cleanse(isbn[:-1], False) == isbn[:-1]
Exemplo n.º 9
0
def test__isbn_cleanse_invalid(isbn, message):
    with raises(IsbnError, match=message):
        _isbn_cleanse(isbn)
Exemplo n.º 10
0
def test__isbn_cleanse_invalid_no_checksum(isbn, message):
    with raises(IsbnError, match=message):
        _isbn_cleanse(isbn, False)
Exemplo n.º 11
0
def test__isbn_cleanse_invalid_type():
    with raises(TypeError, match='ISBN must be a string, received 2'):
        _isbn_cleanse(2)
Exemplo n.º 12
0
def test__isbn_cleanse_reflect_type(isbn):
    assert type(_isbn_cleanse(isbn)) == type(isbn)
Exemplo n.º 13
0
def test__isbn_cleanse_unicode_dash(isbn):
    assert _isbn_cleanse(isbn) == ''.join(filter(lambda s: s.isdigit(), isbn))
Exemplo n.º 14
0
def test__isbn_cleanse_invalid_length(checksum, message):
    with expect.raises(IsbnError, message):
        _isbn_cleanse('0-123', checksum=checksum)
Exemplo n.º 15
0
def test_issue_7_unistr(isbn):
    assert _isbn_cleanse(isbn) == ''.join(filter(lambda s: s.isdigit(), isbn))
Exemplo n.º 16
0
def test__isbn_cleanse_invalid(isbn, message):
    with expect.raises(IsbnError, message):
        _isbn_cleanse(isbn)
Exemplo n.º 17
0
def test__isbn_cleanse_sbn(isbn):
    if isbn.startswith('0'):
        assert _isbn_cleanse(isbn[1:]) == isbn
        assert _isbn_cleanse(isbn[1:-1], False) == isbn[:-1]