Skip to content

Commit

Permalink
allow disabling in-memory sqlite with env var, improve testing coverage
Browse files Browse the repository at this point in the history
Change in coverage:
	71% -> 94%	sort_modules/stardict.py
	75% -> 93%	sort_modules/headword.py
	75% -> 93%	sort_modules/headword_lower.py
	61% -> 87%	sort_modules/ebook.py
	80% -> 90%	sort_modules/ebook_length3.py
  • Loading branch information
ilius committed Dec 19, 2024
1 parent df8eb76 commit 9e47245
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyglossary/glossary_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ def _resolveSortParams(
self._switchToSQLite(
inputFilename=args.inputFilename,
)
else:
elif not os.getenv("NO_SQLITE"):
self._data = self._newInMemorySqEntryList()

self._data.setSortKey(
Expand Down
6 changes: 6 additions & 0 deletions tests/g_stardict_sort_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import unittest

from g_stardict_test import TestGlossaryStarDictBase
Expand Down Expand Up @@ -82,6 +83,11 @@ def test_convert_txt_stardict_enfa_4(self):
", and using sortKey function from Stardict plugin",
)

def test_convert_txt_stardict_enfa_5(self):
os.environ["NO_SQLITE"] = "1"
self.convert_txt_stardict_enfa("100-en-fa", sqlite=False)
del os.environ["NO_SQLITE"]


if __name__ == "__main__":
unittest.main()
4 changes: 4 additions & 0 deletions tests/glossary_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ def convert_txt_txt_sort(self, *args, **convertArgs):
for sqlite in (None, True, False):
self.convert_txt_txt(*args, sort=True, sqlite=sqlite, **convertArgs)

os.environ["NO_SQLITE"] = "1"
self.convert_txt_txt(*args, sort=True, sqlite=False, **convertArgs)
del os.environ["NO_SQLITE"]


class TestGlossary(TestGlossaryBase):
def __init__(self, *args, **kwargs):
Expand Down

0 comments on commit 9e47245

Please sign in to comment.