Skip to content

Commit

Permalink
Merge pull request #42 from OCR-D/fixing-tests
Browse files Browse the repository at this point in the history
fix tests: download when resolving
  • Loading branch information
kba authored Oct 16, 2023
2 parents 4b3cc79 + 6cef084 commit bdbe6fc
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,5 @@ ENV/
*.swp
.pytest_cache
tests/assets
repo
.pynative
_*.png
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "repo/assets"]
path = repo/assets
url = https://github.com/OCR-D/assets
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ test: tests/assets
# Assets
#

# Clone OCR-D/assets to ./repo/assets
repo/assets:
mkdir -p $(dir $@)
git clone --quiet https://github.com/OCR-D/assets "$@"
# Update OCR-D/assets submodule
.PHONY: repos always-update tests/assets
repo/assets: always-update
git submodule sync --recursive $@
if git submodule status --recursive $@ | grep -qv '^ '; then \
git submodule update --init --recursive $@ && \
touch $@; \
fi


# Setup test assets
Expand Down
1 change: 1 addition & 0 deletions repo/assets
Submodule assets added at 05568a
3 changes: 2 additions & 1 deletion tests/test_binarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def workspace(tmpdir):
shutil.rmtree(tmpdir)
workspace = Resolver().workspace_from_url(
assets.path_to('kant_aufklaerung_1784/data/mets.xml'),
dst_dir=tmpdir
dst_dir=tmpdir,
download=True
)
return workspace

Expand Down
2 changes: 1 addition & 1 deletion tests/test_recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_recognize(self):
resolver = Resolver()
# with pushd_popd('/tmp/kraken-test') as tempdir:
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir)
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True)
workspace.overwrite_mode = True
proc = KrakenRecognize(
workspace,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setUp(self):
def test_run_blla(self):
resolver = Resolver()
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir)
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True)
proc = KrakenSegment(
workspace,
input_file_grp="OCR-D-IMG-BIN",
Expand All @@ -31,7 +31,7 @@ def test_run_legacy(self):
resolver = Resolver()
# with pushd_popd('/tmp/kraken-test') as tempdir:
with pushd_popd(tempdir=True) as tempdir:
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir)
workspace = resolver.workspace_from_url(assets.path_to('communist_manifesto/data/mets.xml'), dst_dir=tempdir, download=True)
proc = KrakenSegment(
workspace,
input_file_grp="OCR-D-IMG-BIN",
Expand Down

0 comments on commit bdbe6fc

Please sign in to comment.