Skip to content

Commit 7570eef

Browse files
committed
Improved get_random_entry test
1 parent 4b1f18a commit 7570eef

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/test_libzim_reader.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,12 +601,17 @@ def filename(self):
601601
assert zim != Sub2(fpath1)
602602

603603

604-
@skip_if_offline
605604
def test_reader_get_random_entry(all_zims):
606-
fpath1 = Archive(all_zims / "zimfile.zim")
607-
fpath2 = Archive(all_zims / "example.zim")
605+
zim_1 = Archive(all_zims / "zimfile.zim")
608606

609-
assert isinstance(fpath1.get_random_entry(), Entry)
607+
entry_1 = zim_1.get_random_entry()
608+
entry_2 = zim_1.get_random_entry()
609+
assert isinstance(entry_1, Entry)
610+
assert isinstance(entry_2, Entry)
611+
# this may occasionaly fail (1 chance over 129)
612+
assert entry_1 != entry_2
610613

614+
# example.zim has no FRONT_ARTICLE (article_count=0): random cannot yield any result
615+
zim_2 = Archive(all_zims / "example.zim")
611616
with pytest.raises(KeyError):
612-
fpath2.get_random_entry()
617+
zim_2.get_random_entry()

0 commit comments

Comments
 (0)