Skip to content

Commit

Permalink
Keep sugar for local use, but use instafail on CI
Browse files Browse the repository at this point in the history
There are two benefits of the pytest-sugar plugin:

1. Pretty output.
2. Show details on each failure immediately instead of at the end.

The first benefit is effectively local-only, because extra newlines
are appearing when it runs on CI, both with and without -v.

The second benefit applies both locally and on CI.

So this adds the pytest-instafail plugin and uses it on CI to get
the second benefit. It is not set up to run automatically, and
pytest-sugar still is (though no longer forced), so local testing
retains no benefit and we don't have a clash.

The name "instafail" refers only to instantly *seeing* failures:
it does not cause the pytest runner to stop earlier than otherwise.
  • Loading branch information
EliahKagan committed Sep 25, 2023
1 parent 680d795 commit 75cf540
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cygwin-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ jobs:
- name: Test with pytest
run: |
set +x
/usr/bin/python -m pytest -v
/usr/bin/python -m pytest -p no:sugar -v --instafail
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:

- name: Test with pytest
run: |
pytest -v
pytest -v -p no:sugar --instafail
continue-on-error: false

- name: Documentation
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
python_files = 'test_*.py'
testpaths = 'test' # space separated list of paths from root e.g test tests doc/testing
addopts = '--cov=git --cov-report=term --force-sugar --disable-warnings'
addopts = '--cov=git --cov-report=term --disable-warnings'
filterwarnings = 'ignore::DeprecationWarning'
# --cov coverage
# --cov-report term # send report to terminal term-missing -> terminal with line numbers html xml
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ mypy
pre-commit
pytest
pytest-cov
pytest-instafail
pytest-sugar

0 comments on commit 75cf540

Please sign in to comment.