Skip to content

Commit

Permalink
Changed end2end tests to contribute coverage to unit tests
Browse files Browse the repository at this point in the history
Details:

* Used --cov-append option of pytest to have pytest runs contribute
  to the same coverage file .coverage instead of recreating it.
  The unit test and end2end test runs now use the same .coverage
  file.

* Added the .coveragec file to the dependents of the test end
  end2end test targets.

* Had to increase the minimum version of the 'coverage' package
  from 5.0 to 5.5 to address an internal error that surfaced when
  using --cov-append.

* Also had to increase the minimum versions of pytest and pytest-cov
  and pluggy.

Signed-off-by: Andreas Maier <[email protected]>
  • Loading branch information
andy-maier committed Sep 11, 2023
1 parent b27e072 commit bcbc687
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 48 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ omit =

# Controls whether lines without coverage are shown in the report.
show_missing = True

[html]

directory = htmlcov
26 changes: 0 additions & 26 deletions .coveragerc.end2end

This file was deleted.

12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,8 @@ else
pytest_opts := $(TESTOPTS)
endif

pytest_cov_opts := --cov $(package_name) --cov-config .coveragerc --cov-report=html
pytest_cov_opts := --cov $(package_name) --cov-config .coveragerc --cov-append --cov-report=html
pytest_cov_files := .coveragerc
pytest_e2e_cov_opts := --cov $(package_name) --cov-config .coveragerc.end2end --cov-report=html
pytest_e2e_cov_files := .coveragerc.end2end

# Files the distribution archive depends upon.
# This is also used for 'include' statements in MANIFEST.in.
Expand All @@ -219,13 +217,13 @@ help:
@echo ' check - Run Flake8 on sources'
@echo ' pylint - Run PyLint on sources'
@echo ' safety - Run safety on sources'
@echo ' test - Run function tests (and test coverage)'
@echo ' test - Run function tests (adds to coverage results)'
@echo ' Does not include install but depends on it, so make sure install is current.'
@echo ' Env.var TESTCASES can be used to specify a py.test expression for its -k option'
@echo ' build - Build the distribution files in $(dist_dir): $(dist_files)'
@echo ' builddoc - Build documentation in: $(doc_build_dir)'
@echo ' all - Do all of the above'
@echo " end2end - Run end2end tests (and test coverage)"
@echo " end2end - Run end2end tests (adds to coverage results)"
@echo " end2end_show - Show HMCs defined for end2end tests"
@echo ' uninstall - Uninstall package from active Python environment'
@echo ' upload - Upload the distribution files to PyPI (includes uninstall+build)'
Expand Down Expand Up @@ -499,9 +497,9 @@ test: Makefile $(package_py_files) $(test_function_py_files) $(pytest_cov_files)
@echo "Makefile: $@ done."

.PHONY: end2end
end2end: Makefile develop_$(pymn)_$(PACKAGE_LEVEL).done $(package_py_files) $(test_end2end_py_files) $(pytest_e2e_cov_files)
end2end: Makefile develop_$(pymn)_$(PACKAGE_LEVEL).done $(package_py_files) $(test_end2end_py_files) $(pytest_cov_files)
-$(call RMDIR_R_FUNC,htmlcov.end2end)
bash -c "TESTEND2END_LOAD=true py.test --color=yes $(pytest_no_log_opt) -v -s $(test_dir)/end2end $(pytest_e2e_cov_opts) $(pytest_opts)"
bash -c "TESTEND2END_LOAD=true py.test --color=yes $(pytest_no_log_opt) -v -s $(test_dir)/end2end $(pytest_cov_opts) $(pytest_opts)"
@echo "Makefile: $@ done."

.PHONY: end2end_show
Expand Down
13 changes: 5 additions & 8 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ dparse>=0.6.2; python_version >= '3.6'
# Unit test:
# pytest 5.0.0 has removed support for Python < 3.5
# pytest 4.3.1 solves an issue on Python 3 with minimum package levels
pytest>=4.3.1,<5.0.0; python_version == '2.7'
pytest>=4.3.1; python_version >= '3.5' and python_version <= '3.6'
pytest>=4.4.0; python_version >= '3.7' and python_version <= '3.9'
pytest>=4.6.11,<5.0.0; python_version == '2.7'
pytest>=4.6.11; python_version >= '3.5' and python_version <= '3.9'
pytest>=6.2.5; python_version >= '3.10'
# flake8 up to 6.0.0 has not yet adjusted to the removed interfaces of importlib-metadata 5.0
importlib-metadata>=0.22,<4.3; python_version <= '3.6'
Expand All @@ -53,8 +52,8 @@ colorama>=0.3.9; python_version == '2.7'
colorama>=0.4.5; python_version >= '3.5'

# Coverage reporting (no imports, invoked via coveralls script):
coverage>=5.0
pytest-cov>=2.7.0
coverage>=5.5
pytest-cov>=2.12.1
# coveralls 2.0 has removed support for Python 2.7
git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7'
coveralls>=3.3.0; python_version >= '3.5'
Expand Down Expand Up @@ -156,9 +155,7 @@ readme-renderer>=25.0; python_version >= '3.5'

# Unit test (indirect dependencies):
# Pluggy 0.12.0 has a bug causing pytest plugins to fail loading on py38
pluggy>=0.7.1; python_version == '2.7'
pluggy>=0.7.1; python_version >= '3.5' and python_version <= '3.6'
pluggy>=0.13.0; python_version >= '3.7'
pluggy>=0.13.1

# Package dependency management tools (not used by any make rules)
pipdeptree>=2.2.0
Expand Down
3 changes: 3 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Released: not yet

**Enhancements:**

* Test: Changed end2end tests to contribute coverage results to same data as
unit/function tests.

**Cleanup:**

* Dev: Increased minimum versins of some development packages and fixed
Expand Down
11 changes: 4 additions & 7 deletions minimum-constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ dparse==0.6.2; python_version >= '3.6'
# Unit test (imports into testcases):
# pytest 5.0.0 has removed support for Python < 3.5
# pytest 4.3.1 solves an issue on Python 3 with minimum package levels
pytest==4.3.1; python_version <= '3.6'
pytest==4.4.0; python_version >= '3.7' and python_version <= '3.9'
pytest==4.6.11; python_version <= '3.6' and python_version <= '3.9'
pytest==6.2.5; python_version >= '3.10'
importlib-metadata==0.22; python_version <= '3.6'
importlib-metadata==1.1.0; python_version >= '3.7'
Expand All @@ -187,8 +186,8 @@ packaging==20.5; python_version <= '3.5'
packaging==21.0; python_version >= '3.6'

# Coverage reporting (no imports, invoked via coveralls script):
coverage==5.0
pytest-cov==2.7.0
coverage==5.5
pytest-cov==2.12.1
# handled by dev-requirements.txt: git+https://github.com/andy-maier/coveralls-python.git@andy/add-py27#egg=coveralls; python_version == '2.7'
coveralls==3.3.0; python_version >= '3.5'

Expand Down Expand Up @@ -248,9 +247,7 @@ readme-renderer==25.0; python_version >= '3.5'
# Unit test (indirect dependencies):
# pluggy (used by pytest)
# Pluggy 0.12.0 has a bug causing pytest plugins to fail loading on py38
pluggy==0.7.1; python_version == '2.7'
pluggy==0.7.1; python_version >= '3.5' and python_version <= '3.6'
pluggy==0.13.0; python_version >= '3.7'
pluggy==0.13.1

# Package dependency management tools (not used by any make rules)
pipdeptree==2.2.0
Expand Down

0 comments on commit bcbc687

Please sign in to comment.