(self,
easyocr_module,
test_data = "./data/EasyOcrUnitTestPackage.pickle",
image_data_dir = "../examples",
verbose = 0,
numeric_acceptance_error = 0.1)
| 14 | |
| 15 | class UnitTest: |
| 16 | def __init__(self, |
| 17 | easyocr_module, |
| 18 | test_data = "./data/EasyOcrUnitTestPackage.pickle", |
| 19 | image_data_dir = "../examples", |
| 20 | verbose = 0, |
| 21 | numeric_acceptance_error = 0.1): |
| 22 | |
| 23 | self.verbose = verbose |
| 24 | |
| 25 | easy_ocr_init = os.path.join(easyocr_module, "__init__.py") |
| 26 | if not os.path.isfile(easy_ocr_init): |
| 27 | raise FileNotFoundError("Invalid easyocr_module. The directory should contain __init__.py.") |
| 28 | |
| 29 | spec = importlib.util.spec_from_file_location("easyocr", easy_ocr_init) |
| 30 | easyocr = importlib.util.module_from_spec(spec) |
| 31 | sys.modules["easyocr"] = easyocr |
| 32 | spec.loader.exec_module(easyocr) |
| 33 | |
| 34 | self.easyocr = easyocr |
| 35 | if not hasattr(self.easyocr, 'utils'): |
| 36 | setattr(self.easyocr, 'utils', importlib.import_module('easyocr.utils')) |
| 37 | if not hasattr(self.easyocr, 'detection'): |
| 38 | setattr(self.easyocr, 'detection', importlib.import_module('easyocr.detection')) |
| 39 | if not hasattr(self.easyocr, 'recognition'): |
| 40 | setattr(self.easyocr, 'recognition', importlib.import_module('easyocr.recognition')) |
| 41 | |
| 42 | self.easyocr_dir = os.path.dirname(easyocr.__file__) |
| 43 | |
| 44 | print("Unit test is set for EasyOCR at {}".format(os.path.abspath(self.easyocr_dir))) |
| 45 | |
| 46 | self.image_data_dir = image_data_dir |
| 47 | |
| 48 | self.set_data(test_data) |
| 49 | self.set_easyocr() |
| 50 | self.numeric_acceptance_error = numeric_acceptance_error |
| 51 | |
| 52 | def set_data(self, test_data): |
| 53 |
nothing calls this directly
no test coverage detected