Skip to content

Commit c63ba11

Browse files
committed
Fixed #153: testing that exc in getIndexData dont crash interpreter
1 parent 12b7e57 commit c63ba11

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Changed
1111

1212
- Using libzim 8.1.0
13+
- Exceptions in getIndexData dont crash interpreter (#153)
1314

1415
## [2.0.0] - 2022-09-06
1516

tests/test_libzim_creator.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,20 @@ def test_indexdata_interface():
697697
assert default_id.get_geoposition() is None
698698

699699

700+
def test_exc_in_indexdata(fpath, lipsum):
701+
item = StaticItem(path=HOME_PATH + "custom", content=lipsum, mimetype="text/html")
702+
703+
class CustomIndexData(IndexData):
704+
def has_indexdata(self):
705+
raise IndexError
706+
707+
item.get_indexdata = CustomIndexData
708+
709+
with pytest.raises(RuntimeError, match="IndexError"):
710+
with Creator(fpath).config_indexing(True, "eng") as c:
711+
c.add_item(item)
712+
713+
700714
def test_reimpfeed(fpath):
701715
class AContentProvider:
702716
def __init__(self):

0 commit comments

Comments
 (0)