From e6eb188e25be974982c1b265de0aec311b80516e Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 5 Jul 2022 18:27:57 +0200 Subject: [PATCH 1/5] .gitignore bytecode files Signed-off-by: Yann Dirson --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eeb8a6e..f53e4af 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/__pycache__ +*.pyc From 5d1685f851a48a9397b27cbf5970187a60ba1dd3 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 5 Jul 2022 18:29:55 +0200 Subject: [PATCH 2/5] ci: ensure pathlib is installed While not necessary for the OS image in use for the test, it helps in documenting the need for a non-default lib. Signed-off-by: Yann Dirson --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fffa84b..3c932e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install mock pytest pyfakefs + pip install pathlib mock pytest pyfakefs if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: pytest run: | From 7b5a2bb01b8ca06b67e7b4410888689a714fcde1 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 5 Jul 2022 18:31:24 +0200 Subject: [PATCH 3/5] ci: call pytest from project topdir Calling from toplevel provides more streamlined workflow (eg. when locally running for coverage) Signed-off-by: Yann Dirson --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c932e1..96520d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,5 +16,4 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: pytest run: | - cd tests - pytest + pytest tests From 47d3deed3a2982db4d4be0543ca9588f839cb1c3 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 5 Jul 2022 18:36:16 +0200 Subject: [PATCH 4/5] configuration for python-coverage Signed-off-by: Yann Dirson --- .coveragerc | 24 ++++++++++++++++++++++++ .gitignore | 2 ++ 2 files changed, 26 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..b411f9d --- /dev/null +++ b/.coveragerc @@ -0,0 +1,24 @@ +[run] +source = + SOURCES/ + tests/ + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # Have to re-enable the standard pragma + pragma: no cover + + # Don't complain if tests don't hit defensive assertion code: + raise AssertionError + raise NotImplementedError + \.* + + # Don't complain if non-runnable code isn't run: + if 0: + if __name__ == .__main__.: + +precision = 1 +include = + SOURCES/* + tests/* diff --git a/.gitignore b/.gitignore index f53e4af..0b837b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ **/__pycache__ *.pyc +/.coverage +/coverage.xml From 8312bb637337a7dd73b704aa5306a1270ac0448b Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 6 Jul 2022 09:38:47 +0200 Subject: [PATCH 5/5] ci: generate coverage We don't do anything with it yet, aside from displaying the report Signed-off-by: Yann Dirson --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96520d9..8a1ef1a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,8 +12,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pathlib mock pytest pyfakefs + pip install pathlib mock pytest pytest-cov pyfakefs if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: pytest run: | - pytest tests + pytest --cov --cov-report=xml --cov-report=term tests