new: test: match doctest output

This commit is contained in:
rachmadaniHaryono 2021-01-21 07:14:15 +08:00
parent be99101c73
commit ddb99cd1f7

16
buku
View File

@ -1499,6 +1499,7 @@ class BukuDb:
>>> import buku >>> import buku
>>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # single record database >>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # single record database
>>> sdb.add_rec('https://example.com') >>> sdb.add_rec('https://example.com')
1
>>> sdb.delete_rec(1) >>> sdb.delete_rec(1)
Index 1 deleted Index 1 deleted
True True
@ -1507,7 +1508,8 @@ class BukuDb:
>>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) >>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name)
>>> sdb.add_rec('https://example.com') >>> sdb.add_rec('https://example.com')
>>> sdb.delete_rec(is_range=True) 1
>>> sdb.delete_rec(is_range=True) # doctest: +SKIP
Remove ALL bookmarks? (y/n): y Remove ALL bookmarks? (y/n): y
All bookmarks deleted All bookmarks deleted
True True
@ -1516,7 +1518,10 @@ class BukuDb:
>>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) >>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name)
>>> sdb.add_rec('https://example.com') >>> sdb.add_rec('https://example.com')
1
>>> sdb.delete_rec() >>> sdb.delete_rec()
Traceback (most recent call last):
...
TypeError: index, low, or high variable is not integer TypeError: index, low, or high variable is not integer
Negative number on `high` and `low` paramaters when is_range is True Negative number on `high` and `low` paramaters when is_range is True
@ -1524,13 +1529,12 @@ class BukuDb:
>>> edb = buku.BukuDb(dbfile=NamedTemporaryFile().name) >>> edb = buku.BukuDb(dbfile=NamedTemporaryFile().name)
>>> edb.delete_rec(low=-1, high=-1, is_range=True) >>> edb.delete_rec(low=-1, high=-1, is_range=True)
Negative range boundary
False False
Remove the table Remove the table
>>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) >>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name)
>>> sdb.delete_rec(0) >>> sdb.delete_rec(0) # doctest: +SKIP
Remove ALL bookmarks? (y/n): y Remove ALL bookmarks? (y/n): y
All bookmarks deleted All bookmarks deleted
True True
@ -1734,31 +1738,29 @@ class BukuDb:
>>> from tempfile import NamedTemporaryFile >>> from tempfile import NamedTemporaryFile
>>> edb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # empty database >>> edb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # empty database
>>> edb.print_rec() >>> edb.print_rec()
0 records
True True
Print negative index on empty database will log error and return False Print negative index on empty database will log error and return False
>>> edb.print_rec(-3) >>> edb.print_rec(-3)
Empty database
False False
print non empty database with default argument. print non empty database with default argument.
>>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # single record database >>> sdb = buku.BukuDb(dbfile=NamedTemporaryFile().name) # single record database
>>> sdb.add_rec('https://example.com') >>> sdb.add_rec('https://example.com')
1
>>> assert sdb.print_rec() >>> assert sdb.print_rec()
1. Example Domain 1. Example Domain
> https://example.com > https://example.com
<BLANKLINE>
Negative number on `high` and `low` paramaters when is_range is True Negative number on `high` and `low` paramaters when is_range is True
will log error and return False will log error and return False
>>> sdb.print_rec(low=-1, high=-1, is_range=True) >>> sdb.print_rec(low=-1, high=-1, is_range=True)
Negative range boundary
False False
>>> edb.print_rec(low=-1, high=-1, is_range=True) >>> edb.print_rec(low=-1, high=-1, is_range=True)
Negative range boundary
False False
""" """
if not is_range and index < 0: if not is_range and index < 0: