Skip to content

Commit fe9d88d

Browse files
authored
Fix test_init_full box.train file_type (#388)
FAILED tests/test_api.py::TestTessBaseApi::test_init_full - AssertionError: '.bl' != '.tif' And don't assume box.train is available in tessdata.
1 parent d2cb5c3 commit fe9d88d

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include LICENSE
33
include tesserocr/*.pyx
44
include tesserocr/*.pxd
55
include tesserocr/*.pyi
6-
include tests/*.py tests/*.png
6+
include tests/*.py tests/*.png tests/*.train
77
exclude tesserocr/*.cpp
88
exclude tesserocr/*.so
99
exclude *.so

tests/box.train

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
disable_character_fragments T
2+
file_type .bl
3+
textord_fast_pitch_test T
4+
tessedit_zero_rejection T
5+
tessedit_minimal_rejection F
6+
tessedit_write_rep_codes F
7+
edges_children_fix F
8+
edges_childarea 0.65
9+
edges_boxarea 0.9
10+
tessedit_resegment_from_boxes T
11+
tessedit_train_from_boxes T
12+
textord_no_rejects T

tests/test_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def version_to_int(version):
4848
class TestTessBaseApi(unittest.TestCase):
4949

5050
_test_dir = os.path.abspath(os.path.dirname(__file__))
51+
_config_file = os.path.join(_test_dir, "box.train")
5152
_image_file = os.path.join(_test_dir, "eurotext.png")
5253

5354
def setUp(self):
@@ -77,13 +78,13 @@ def test_init_full(self):
7778
self.assertEqual(self._api.GetVariableAsString("file_type"), ".tif")
7879
self.assertEqual(self._api.GetVariableAsString("edges_childarea"), "0.5")
7980
# use box.train config variables
80-
configs = ["box.train"]
81+
configs = [self._config_file]
8182
# change edges_childarea
8283
vars_ = {"edges_childarea": "0.7"}
8384
self._api.End()
8485
self._api.InitFull(configs=configs, variables=vars_)
8586
# assert file_type from box.train and custom edges_childarea
86-
self.assertEqual(self._api.GetVariableAsString("file_type"), ".tif")
87+
self.assertEqual(self._api.GetVariableAsString("file_type"), ".bl")
8788
self.assertEqual(self._api.GetVariableAsString("edges_childarea"), "0.7")
8889
# reset back to default
8990
self._api.End()

0 commit comments

Comments
 (0)