Skip to content

Commit

Permalink
cov4 test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanKepner committed Jan 5, 2020
1 parent ce1397b commit c10465f
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ matrix:
name: "Python 3.8 core tests"
env: TOXENV=py38

# specific checks for coverage v4 support, coverage v5 is used by default elsewhere
- python: "3.8"
name: "Python 3.8 coverage v4 tests"
env: TOXENV=cov4

# run pre-commit hooks checks
# TODO: Python 3.8, pyenv global system 3.8 doesn't appear to work
- python: "3.7"
Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ addopts = -ra -v --cov=mutatest

markers =
slow: slow tests, usually because pytest is running sub-trials on mutated temp caches.
coverage: tests that create mock coverage files for running Coverage v4 vs. v5 tests.
8 changes: 2 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,18 @@ def write_cov_file(line_data: Dict[str, List[int]], fname: str) -> None:
Returns:
None
Raises:
EnvironmentError: if Coverage version is not 4 or 5
"""
if coverage.version_info[0] == 4:
covdata = coverage.CoverageData()
covdata.add_lines(line_data)
covdata.write_file(fname)

if coverage.version_info[0] == 5:
else:
# assume coverage v 5
covdata = coverage.CoverageData(basename=fname)
covdata.add_lines(line_data)
covdata.write()

raise EnvironmentError(f"Coverage version is not supported: {coverage.version_info}")


####################################################################################################
# FILTERS: MOCK COVERAGE FILE FIXTURES
Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_mutate_ValueError_target(binop_file, mock_LocIdx):
_ = genome.mutate(target_idx=mock_LocIdx, mutation_op=ast.Div, write_cache=False)


@pytest.mark.skipif(coverage.version_info[0] > 4, reason="Coverage version > 4.x")
@pytest.mark.coverage
@pytest.mark.parametrize("filter_codes", [set(), ("bn",)], ids=["Filter Empty Set", "Filter BinOp"])
def test_covered_targets(filter_codes, binop_file, mock_binop_coverage_file):
"""Mock coverage file sets lines 6 and 10 (not 15) to be covered."""
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_GenomeGroup_add_folder_with_exclusions(tmp_path):
assert list(ggrp.keys())[0].name == expected


@pytest.mark.skipif(coverage.version_info[0] > 4, reason="Coverage version > 4.x")
@pytest.mark.coverage
@pytest.mark.parametrize("filter_codes", [set(), ("bn",)], ids=["Filter Empty Set", "Filter BinOp"])
def test_GenomeGroup_covered_targets(filter_codes, binop_file, mock_binop_coverage_file):
"""Mock coverage file sets lines 6 and 10 (not 15) to be covered."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_unset_coverage_file(fn):
_ = ccf.coverage_data


@pytest.mark.coverage
@pytest.mark.parametrize(
"invert, expected",
[(False, [1, 2, 4]), (True, [3, 5])],
Expand Down
13 changes: 8 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[tox]
minversion = 3.7
envlist = py37, py38, lint, typing, pypi-description, manifest, help, docs
envlist = py37, py38, lint, cov4, typing, pypi-description, manifest, help, docs


[testenv]
# Baseline test environment for both Py 3.7 and 3.8
setenv =
VIRTUALENV_NO_DOWNLOAD=1
extras = dev
Expand All @@ -12,30 +13,33 @@ commands =
python -m pytest --cov=mutatest {posargs}

[testenv:help]
# Ensure no errors are raised from the help text display
install_command = pip install --no-compile {opts} {packages}
setenv =
PYTHONWARNINGS=d
commands = mutatest --help

[testenv:cov4]
# Test with coverage v4 specifically
commands =
pip install 'coverage<5.0'
pytest -m coverage

[testenv:lint]
skip_install = true
deps = pre-commit
commands = pre-commit run --all-files --verbose


[testenv:typing]
skip_install = true
deps = mypy
commands = mypy --strict mutatest


[testenv:docs]
deps = docs
changedir = docs
commands = sphinx-build -W -b html . _build


[testenv:pypi-description]
skip_install = true
deps =
Expand All @@ -47,7 +51,6 @@ commands =
pip wheel -w {envtmpdir}/build --no-deps .
twine check {envtmpdir}/build/*


[testenv:manifest]
deps = check-manifest
skip_install = true
Expand Down

0 comments on commit c10465f

Please sign in to comment.