From 5270737c1f8405665f4c25ca9037ac79d2313719 Mon Sep 17 00:00:00 2001 From: Benjamin Rosemann Date: Wed, 28 Oct 2020 14:48:38 +0100 Subject: [PATCH 1/5] Skip test on windows because it is unix specific. --- qurator/dinglehopper/tests/test_integ_ocrd_cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qurator/dinglehopper/tests/test_integ_ocrd_cli.py b/qurator/dinglehopper/tests/test_integ_ocrd_cli.py index 5cf6a41..54bd748 100644 --- a/qurator/dinglehopper/tests/test_integ_ocrd_cli.py +++ b/qurator/dinglehopper/tests/test_integ_ocrd_cli.py @@ -4,6 +4,7 @@ import json import sys from pathlib import Path +import pytest from click.testing import CliRunner from .util import working_directory @@ -13,6 +14,7 @@ from ..ocrd_cli import ocrd_dinglehopper data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") +@pytest.mark.skipif(sys.platform == 'win32', reason="only on unix") def test_ocrd_cli(tmp_path): """Test OCR-D interface""" From ce752e19127409a59bd8bd3a01e3b0e072932066 Mon Sep 17 00:00:00 2001 From: Benjamin Rosemann Date: Tue, 10 Nov 2020 12:45:13 +0100 Subject: [PATCH 2/5] Remove .idea folder and modify .gitignore Sharing even parts of the .idea folder in worldwide setting is bound to generate more problems than solutions. Therefore it should be removed and consequently ignore in .gitignore. Also adds some Python specific stuff to the .gitignore file. --- .gitignore | 33 ++++++++++--------- .idea/codeStyles/codeStyleConfig.xml | 5 --- .idea/dinglehopper.iml | 11 ------- .../inspectionProfiles/profiles_settings.xml | 6 ---- .idea/misc.xml | 4 --- .idea/modules.xml | 8 ----- .idea/vcs.xml | 6 ---- qurator/dinglehopper/.gitignore | 6 ---- qurator/dinglehopper/.idea/dinglehopper.iml | 12 ------- qurator/dinglehopper/.idea/misc.xml | 7 ---- qurator/dinglehopper/.idea/modules.xml | 8 ----- 11 files changed, 17 insertions(+), 89 deletions(-) delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/dinglehopper.iml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 qurator/dinglehopper/.gitignore delete mode 100644 qurator/dinglehopper/.idea/dinglehopper.iml delete mode 100644 qurator/dinglehopper/.idea/misc.xml delete mode 100644 qurator/dinglehopper/.idea/modules.xml diff --git a/.gitignore b/.gitignore index 3d3a74a..756850f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,26 @@ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] +*$py.class # Distribution / packaging *.egg-info/ -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf +# Unit test / coverage reports +htmlcov/ +.coverage +.coverage.* + +# Environments +.env +.venv +env/ +venv/ -# Generated files -.idea/**/contentModel.xml +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json -# Sensitive or high-churn files -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/dbnavigator.xml +# User-specific stuff +.idea diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/dinglehopper.iml b/.idea/dinglehopper.iml deleted file mode 100644 index 0f3d9e5..0000000 --- a/.idea/dinglehopper.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 88565d3..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 6035afb..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/qurator/dinglehopper/.gitignore b/qurator/dinglehopper/.gitignore deleted file mode 100644 index e70d1f9..0000000 --- a/qurator/dinglehopper/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# User-specific stuff -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/**/usage.statistics.xml -.idea/**/dictionaries -.idea/**/shelf diff --git a/qurator/dinglehopper/.idea/dinglehopper.iml b/qurator/dinglehopper/.idea/dinglehopper.iml deleted file mode 100644 index e273926..0000000 --- a/qurator/dinglehopper/.idea/dinglehopper.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/qurator/dinglehopper/.idea/misc.xml b/qurator/dinglehopper/.idea/misc.xml deleted file mode 100644 index ba209a1..0000000 --- a/qurator/dinglehopper/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/qurator/dinglehopper/.idea/modules.xml b/qurator/dinglehopper/.idea/modules.xml deleted file mode 100644 index 6035afb..0000000 --- a/qurator/dinglehopper/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file From 5cbd4f3d95455f789209dad83ac11a1b85c1ef27 Mon Sep 17 00:00:00 2001 From: Benjamin Rosemann Date: Tue, 10 Nov 2020 12:55:31 +0100 Subject: [PATCH 3/5] Preparation for black code formatter --- .editorconfig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index d9a5689..ea42d71 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,7 +7,7 @@ indent_size = 4 indent_style = space insert_final_newline = true trim_trailing_whitespace = true -max_line_length = 90 +max_line_length = 88 tab_width = 4 [{*.cfg, *.ini, *.html, *.yaml, *.yml}] @@ -20,3 +20,10 @@ insert_final_newline = false # trailing spaces in markdown indicate word wrap [*.md] trim_trailing_whitespace = false + +[*.py] +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True From 03ad413f4a7effc93c3d4603cdc3fda9d392d611 Mon Sep 17 00:00:00 2001 From: Benjamin Rosemann Date: Tue, 10 Nov 2020 12:56:08 +0100 Subject: [PATCH 4/5] Added some helpful tools and configurations --- .coveragerc | 2 ++ README-DEV.md | 37 ++++++++++++++++++++++++++++++++----- requirements-dev.txt | 4 ++++ setup.cfg | 12 +++++++++++- setup.py | 4 ++++ 5 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 .coveragerc create mode 100644 requirements-dev.txt diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..5398e23 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +omit = qurator/dinglehopper/tests/* diff --git a/README-DEV.md b/README-DEV.md index ba35796..2f16df7 100644 --- a/README-DEV.md +++ b/README-DEV.md @@ -1,10 +1,37 @@ -Testing -------- +# Testing + Use `pytest` to run the tests in [the tests directory](qurator/dinglehopper/tests): -~~~ +```bash virtualenv -p /usr/bin/python3 venv . venv/bin/activate pip install -r requirements.txt -pip install pytest +pip install -r requirements-dev.txt pytest -~~~ +``` + +### Test running examples +### Only unit tests +```bash +pytest -m "not integration" +``` + +### Only integration tests +```bash +pytest -m integration +``` + +### All tests +```bash +pytest +``` + +### All tests with code coverage +```bash +pytest --cov=qurator --cov-report=html +``` + +### Static code analysis +```bash +pytest -k "not test" --flake8 +pytest -k "not test" --mypy +``` diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..05d682e --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,4 @@ +pytest +pytest-flake8 +pytest-cov +pytest-mypy diff --git a/setup.cfg b/setup.cfg index 43d7a3a..aeec880 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,12 @@ [flake8] -max-line-length = 90 +max-line-length = 88 +extend-ignore = E203, W503 + +[pylint] +max-line-length = 88 + +[pylint.messages_control] +disable = C0330, C0326 + +[mypy] +ignore_missing_imports = True diff --git a/setup.py b/setup.py index 56ae184..1551c2d 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,9 @@ from setuptools import find_packages, setup with open("requirements.txt") as fp: install_requires = fp.read() +with open('requirements-dev.txt') as fp: + tests_require = fp.read() + setup( name="dinglehopper", author="Mike Gerber, The QURATOR SPK Team", @@ -16,6 +19,7 @@ setup( namespace_packages=["qurator"], packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), install_requires=install_requires, + tests_require=tests_require, package_data={ "": ["*.json", "templates/*"], }, From cb1ac9d2602ca4520f8440ff85f9d4615d95b921 Mon Sep 17 00:00:00 2001 From: Benjamin Rosemann Date: Tue, 10 Nov 2020 13:09:06 +0100 Subject: [PATCH 5/5] Add black to developer requirements. --- requirements-dev.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 05d682e..9403f15 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,3 +2,4 @@ pytest pytest-flake8 pytest-cov pytest-mypy +black