mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-06-09 20:29:55 +02:00
more code formatting
This commit is contained in:
parent
713b90e084
commit
1a95bca22d
24 changed files with 1408 additions and 1319 deletions
|
@ -10,12 +10,14 @@ from unittest import TestCase as VanillaTestCase, skip, main as unittests_main
|
|||
import pytest
|
||||
from ocrd_utils import disableLogging, initLogging
|
||||
|
||||
|
||||
def main(fn=None):
|
||||
if fn:
|
||||
sys.exit(pytest.main([fn]))
|
||||
else:
|
||||
unittests_main()
|
||||
|
||||
|
||||
class TestCase(VanillaTestCase):
|
||||
|
||||
@classmethod
|
||||
|
@ -26,6 +28,7 @@ class TestCase(VanillaTestCase):
|
|||
disableLogging()
|
||||
initLogging()
|
||||
|
||||
|
||||
class CapturingTestCase(TestCase):
|
||||
"""
|
||||
A TestCase that needs to capture stderr/stdout and invoke click CLI.
|
||||
|
@ -42,7 +45,7 @@ class CapturingTestCase(TestCase):
|
|||
"""
|
||||
self.capture_out_err() # XXX snapshot just before executing the CLI
|
||||
code = 0
|
||||
sys.argv[1:] = args # XXX necessary because sys.argv reflects pytest args not cli args
|
||||
sys.argv[1:] = args # XXX necessary because sys.argv reflects pytest args not cli args
|
||||
try:
|
||||
cli.main(args=args)
|
||||
except SystemExit as e:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from tests.base import main
|
||||
from eynollah.eynollah.utils.counter import EynollahIdCounter
|
||||
|
||||
|
||||
def test_counter_string():
|
||||
c = EynollahIdCounter()
|
||||
assert c.next_region_id == 'region_0001'
|
||||
|
@ -11,6 +12,7 @@ def test_counter_string():
|
|||
assert c.region_id(999) == 'region_0999'
|
||||
assert c.line_id(999, 888) == 'region_0999_line_0888'
|
||||
|
||||
|
||||
def test_counter_init():
|
||||
c = EynollahIdCounter(region_idx=2)
|
||||
assert c.get('region') == 2
|
||||
|
@ -19,6 +21,7 @@ def test_counter_init():
|
|||
c.reset()
|
||||
assert c.get('region') == 2
|
||||
|
||||
|
||||
def test_counter_methods():
|
||||
c = EynollahIdCounter()
|
||||
assert c.get('region') == 0
|
||||
|
@ -29,5 +32,6 @@ def test_counter_methods():
|
|||
c.inc('region', -9)
|
||||
assert c.get('region') == 1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(__file__)
|
||||
|
|
|
@ -3,9 +3,11 @@ from pathlib import Path
|
|||
from eynollah.eynollah.utils.pil_cv2 import check_dpi
|
||||
from tests.base import main
|
||||
|
||||
|
||||
def test_dpi():
|
||||
fpath = str(Path(__file__).parent.joinpath('resources', 'kant_aufklaerung_1784_0020.tif'))
|
||||
assert 230 == check_dpi(cv2.imread(fpath))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(__file__)
|
||||
|
|
|
@ -8,6 +8,7 @@ testdir = Path(__file__).parent.resolve()
|
|||
|
||||
EYNOLLAH_MODELS = environ.get('EYNOLLAH_MODELS', str(testdir.joinpath('..', 'models_eynollah').resolve()))
|
||||
|
||||
|
||||
class TestEynollahRun(TestCase):
|
||||
|
||||
def test_full_run(self):
|
||||
|
@ -20,5 +21,6 @@ class TestEynollahRun(TestCase):
|
|||
print(code, out, err)
|
||||
assert not code
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(__file__)
|
||||
|
|
|
@ -4,11 +4,13 @@ from ocrd_models.ocrd_page import to_xml
|
|||
|
||||
PAGE_2019 = 'http://schema.primaresearch.org/PAGE/gts/pagecontent/2019-07-15'
|
||||
|
||||
|
||||
def test_create_xml():
|
||||
pcgts = create_page_xml('/path/to/img.tif', 100, 100)
|
||||
xmlstr = to_xml(pcgts)
|
||||
assert 'xmlns:pc="%s"' % PAGE_2019 in xmlstr
|
||||
assert 'Metadata' in xmlstr
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main([__file__])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue