Skip to content

Commit

Permalink
Add one more line of coverage...
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch committed Jan 16, 2024
1 parent 0088db2 commit 996eb4b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
18 changes: 15 additions & 3 deletions opine/tests/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

class FunctionalTest(unittest.TestCase):
def _run_and_get_output(
self, args: List[str], extra_files: Optional[Dict[str, str]] = None
self, args: List[str], extra_files: Optional[Dict[str, Optional[str]]] = None
) -> Tuple[Result, Dict[str, str]]:
with tempfile.TemporaryDirectory() as d:
td_path = Path(d)
self.files: Dict[str, str] = {}
self.files: Dict[str, Optional[str]] = {}
self.files.update(SAMPLE_ENV)
if extra_files:
self.files.update(extra_files)

for filename, contents in self.files.items():
(td_path / filename).write_text(contents)
if contents is not None:
(td_path / filename).write_text(contents)

runner = CliRunner()
result = runner.invoke(main, args + [d])
Expand Down Expand Up @@ -70,6 +71,12 @@ def test_smoke_exception_verbose(self) -> None:
self.assertIn("ParserSyntaxError: Syntax Error", result.output)
self.assertIn("Traceback (most recent call last)", result.output)

def test_smoke_skip(self) -> None:
result, files = self._run_and_get_output(["-v"], {"setup.py": "pass"})
self.assertEqual(2, result.exit_code)
self.assertEqual(self.files, files)
self.assertIn("Could not find setup() call in setup.py", result.output)

def test_smoke_write(self) -> None:
result, files = self._run_and_get_output(["-a"])
self.assertEqual(0, result.exit_code)
Expand Down Expand Up @@ -100,3 +107,8 @@ def test_smoke_write(self) -> None:
""",
files["setup.cfg"],
)

def test_smoke_noop(self) -> None:
result, files = self._run_and_get_output(
["-a"], extra_files={"coverage.ini": None}
)
21 changes: 17 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ install_requires =
imperfect>=0.2.0
moreorless>=0.3.0
tomlkit>=0.5.0
setuptools >= 38.3.0

[options.entry_points]
console_scripts =
Expand Down Expand Up @@ -54,22 +55,34 @@ use_parentheses = True
ignore_missing_imports = True

[tox:tox]
envlist = py38-minimal, py38, py39, py310, py311, py312
envlist = py38-minimal, py38, py39, py310, py311, py312, coverage

[testenv]
deps = -rrequirements-dev.txt
whitelist_externals = make
deps =
-rrequirements-dev.txt
allowlist_externals = make
commands =
make test
setenv =
py3*: COVERAGE_FILE={envdir}/.coverage
py{38,39,310,311,312}: COVERAGE_FILE={toxworkdir}/.coverage.{envname}
usedevelop = True
depends =
coverage: py{38,39,310,311,312}

[testenv:py38-minimal]
deps =
changedir = /
commands =
python -m opine.tests

[testenv:coverage]
setenv = COVERAGE_FILE={toxworkdir}/.coverage
skip_install = True
deps = coverage
commands =
coverage combine
coverage report -m

[flake8]
ignore = E203, E231, E266, E302, E501, W503
max-line-length = 88

0 comments on commit 996eb4b

Please sign in to comment.