All notable changes to this project will be documented in this file.
- Fix #173: An issue with pytest-reportlog thanks to a suggestion from MV Seotlo
- also the resulting code is a bit cleaner of a solution for the pseudo-traceback code.
- Added
--check-max-tb-line=<int>to control one-line traceback output for additional failures. - Traceback output now supports two tiers:
- full pseudo-tracebacks for early failures (
--check-max-tb) - one-line traceback output for later failures (
--check-max-tb-line)
- full pseudo-tracebacks for early failures (
- Improved one-line traceback output for context-manager checks:
- points to the failing line inside
with check:blocks - includes exception type and message when available
- points to the failing line inside
- If you already use
--check-max-tb, behavior is unchanged unless you also set--check-max-tb-line. - To keep output compact while preserving useful location info, consider:
--check-max-tb=1 --check-max-tb-line=10
- added type testing with ty
- now testing with both mypy and ty, may reduce that to just ty in the future
--check-max-tb-line=<int>option to enable one-line traceback formatting for additional check failures.
- traceback reporting can now be split by threshold:
- failures up to
--check-max-tbuse full pseudo-tracebacks. - failures above that and up to
--check-max-tb-lineuse one-line tracebacks.
- failures up to
- Support Request #122: Feature proposal: Capability to mark checks as xfail
- Allow check helper functions, including
raises(), to accept anxfailreason. A failing check can now produce an xfailed test result, while a passing check does not produce xpass unless the test is already marked with@pytest.mark.xfail. - (docs) Document
xfailsupport for check helper functions in the README.
- Allow CheckContextManager to catch any exception, not just AssertionError (#198). Non-assertion exceptions (IndexError, KeyError, AttributeError, etc.) are now properly caught and reported as check failures.
- (typing) Set comparison function types such that None is not allowed
- Passing
Noneto comparison functions likegreater(),less(), etc. used to raise an exception, which caused a test failure and stopped the test. - That's unexpected with a check function.
- So now the check fails with a meaningful error message and continues with the rest of the test.
- (typing) Allow numpy floats with comparison functions to pass mypy.
- (typing) Allow mixed
int/floatarguments in strict mypy for comparison helpers by addingfloatnumeric overloads forgreater(),greater_equal(),less(), andless_equal()incheck_functions.py.
- Add
__init__.pyistub file for IDE intellisense (e.g. VSCode) and static type checkers. - Add PEP 561
py.typedmarker so the package is recognized as typed. - (examples) Add
test_example_mypy.pyto validateimport pytest_check as checkwith mypy.
- Ignore dist-packages in pseudo stack trace - Fixes #196 - Thanks @siferati
- (typing) Resolve remaining mypy errors for
import pytest_check as checkusage; internal adjustments incheck_functions.py.
- (ci) Rename "quality" job to "static-analysis"; split into separate jobs for static-analysis, pytest_earliest, and coverage; use Python 3.14 for quality jobs.
- (tox) Add mypy env coverage for import-as style in examples.
- #184: Fix issues with mypy. The example in this issue now passes mypy. Also mypy is now being tested as part of tox.
- (typing) Allow dynamic helper access on
CheckContextManagerfor static analysis, so patterns likecheck.equal(...)type-check in fixture-annotated tests.
- (typing) Update internal
_Comparable*protocol comparison signatures to satisfy strict mypy checks. - (tox) Enable and expand
mypyenv checks to includeexamples/. - (tox) Install
httpxin themypyenv so example type checking works without import ignores. - (examples) Switch decorator usage in
test_example_check_func_decorator.pyto importcheck_funcdirectly for static type checking. - (examples) Add
test_example_context_manager_type.pyto document and validate context-manager fixture typing behavior. - (ci) Add a GitHub Actions quality job to run
tox -e lint,mypy,pytest_earliest,coverage.
- (docs) Document custom message support (
msg) incheck.raises(). - (tests) Add tests for custom messages in
check.raises(). - (docs) Document that built-in check methods return
boolvalues. - (docs) Update pseudo-traceback examples to reflect the default single pseudo-traceback and show how to increase it with
--check-max-tb=5. - (docs) Add
check.call_on_fail()section with usage guidance. - (examples) Add runnable logging example in
examples/logging_to_a_file/.
- (tests) Make
test_raises_custom_msgcompatible with pytest < 7.3 short-summary output.
- Support for
raisesparameter in@pytest.mark.xfailwhen using check context managers - Fixes #145 - Thanks @shairoth12
- Fix #190: pyright errors
- Fix #145: Is the 'raises' parameter in xfail ignored? - not anymore
- Internal: Add fixture run_example_test in tests - Thanks @even-even
- Update all to include 'check' in pytest_check module - Fixes #190 - Thanks @taylermulligan
- Greater/less_equal support numpy scalars #189 - Thanks @dpinol
- (internal) Updated publish pipeline: repository_url -> repository-url
raisesreturns the exception value, so the expected error message can be verified. - Thanks @shairoth12
- raises & any_failures exported from top init.py module so that mypy does not complain that they are not explicitly exported. - Thanks @dpinol
- Make _Comparable* protocols compatible with builtins - Thanks @SebastianGrans
- Turn on testing for Python 3.14 in CI
- Relative paths in tracebacks
- PR #179, thanks @dpinol
- Add testing of Python 3.14
- Fixes a weird corner case where an internal error could be generated by (1) having a session scope fixture fail in teardown and (2) having the last test in the session be skipped. Thanks @asyash26 for reporting and creating reproduction steps. Resolves #170
- Set a minimum pluggy version during type checking. Resolves #176, thanks @d-ryzhykau
- Add type hints, remove support for Python 3.8, resolves #163, thanks @mfulgo
- Fixes #171, check doesn't respect runxfail option, thanks @taylermulligan
- Add testing for Python 3.13 to GH actions
- Add testing for Python 3.13 and 3.14 to tox.ini
- Switch packaging from flit to hatchling
is_nan()is_not_nan()
- Drop Python 3.7
- Add testing for Python 3.12
- Add tox-uv to tox.ini and main.yml
- Documentation Update, README.md
- Turn help function list into a table with param lists
- Show an alternative method of creating a helper function using
check.fail()
between_equal(b, a, c)- as a shortcut for
between(b, a, c, ge=True, le=True)
- as a shortcut for
fail(msg)- indicate test failure, but don't stop testing
- Fix 155
- Summaries from 2.2.3 are cool, but don't work with xdist
- Turn off summaries while xdist is running
- I hope I'm not seeing a pattern here
- Fix 153
- Summaries from 2.2.3 are cool, but don't work for pytest < 7.3
- Remove them for earlier pytest
- Add tox test run for pytest 7.0.0
- Change dependencies to require 7.0.0 pytest
- Check failure info now shows up in summaries.
- Fix 133 - thanks hirotoKirimaru
- Fix 137
- Increase Python range to include 3.7.0. Thanks EliahKagan
- Pseudo traceback additions
-lor--showlocalsshows locals__tracebackhide__ = Trueis honored.- if
assertor other exception is involved,- the exception is included as part of the traceback.
- pseudo traceback changes
- The red color is used more selectively.
- this is intended to help readability
- Other minor formatting changes.
- Please let me know if you have any issues with the changes
- Include tests and examples in sdist - PR 121
- Publish-to-pypi.yml workflow
- README.md - clean up documentation for
--check-max-tb. Thanks alblasco. - Minor internal cleanup - removed some debug code.
check.call_on_fail(func)- Experimental- Experimental feature - may change with any release, even a minor release
- Name changed from
check.set_failure_callback(func). - Also, I warned you I could change that at any time.
- No tomatoes thrown, please.
- It's better, right? Thanks to Hynek for the suggestion.
check.set_failure_callback(func)- Experimental- Experimental feature - may change with any release, even a minor release
- Function to allow a callback function to be registered.
- This "func" function will be called for each failed check, and needs to accept a string parameter.
- Examples:
print:check.set_failure_callback(print)- allows stdout printing while test is running (provided
-sis used).
- allows stdout printing while test is running (provided
logging.error:check.set_failure_callback(logging.error)- failure reports to logging
- See
examples/test_example_logging.pyfor runnable examples
- With the following change, the default is now pretty darn fast, and most people will not need to modify any settings to get most of the speed improvements.
--check-max-tb=<int>- sets the max number of pseudo-traceback reports per test function.- Default is 1.
- After this, error is still reported
- The error reports continue, they just won't have a traceback.
- If you set
--check-max-report, then the reports stop at that number, with or without tracebacks.a
check.set_max_tb(int)- overrides--check-max-tbfor the test function it's called from. Value is reset after one test function.
check.set_no_tband--set-no-tbwill be removed in a future release. (probably soon)check.set_no_tbis deprecated.- For now, it internally calls
set_max_tb(0). See discussion below.
- For now, it internally calls
--check-no-tbis deprecated.- It's also short lived.
- Since
--check-max-tbis more useful, the default for--check-max-tbis 1, which is already pretty fast. And--check-max-tb=0has the same effect as--check-no-tb.
- PR 109. Update README.md with conda install instructions. Thanks Abel Aoun.
The default behavior has changed. Since --check-max-tb=1 is the default, the default behavior is now:
- Show traceback for the first failure per test. (controlled by
--check-max-tb, default is 1) - Show error report for the remaining failures in a test. (controlled by
--check-max-report, default is None)
Old default behavior was the same except all tracebacks would be reported.
My logic here:
- The actual error message, like
check 1 == 3, is more useful than the traceback. - The first traceback is still useful to point you to the test file, line number, of first failure.
- Other failures are probably close by.
If this logic doesn't hold for you, you can always set --check-max-tb=1000 or some other large number.
- Most changes are related to speedup improvements.
- use
--check-no-tb --check-max-report=10to get super zippy.
- use
check.between()added just for fun
- Rewrote
check.equal()and other helper functions to not use assert. - Check functions report things like
FAILURE: check 1 < 2now.- It used to say
FAILURE: assert 1 < 2, but that's not really true anymore.
- It used to say
--check-no-tb- turn off tracebacks--check-max-report- limit reported failures per test function--check-max-fail- limit failures per test functioncheck.set_no_tb()- turn off tracebacks for one test functioncheck.set_max_report()- limit reports for one test functioncheck.set_max_fail()- limit failures for one test functioncheck.between(b, a, c)- check that a < b < c
-
Remove colorama as a dependency, and simplify how we do "red".
-
Change the formatting of context manager checks such that if a msg is included, we see both the message and the assert failure. Previously, the message would replace the assert failure.
- Add
any_failures(). Thank you @alblasco
- While using the
checkfixture, allowcheck.checkas a context manager.- this is unnecessary, the
checkfixture now works as a context manager. - but apparently some people have been using
with check.check: - so this fix makes that work.
- this is unnecessary, the
- Allow
raisesfromcheckobject.- Now
with check.raises(Exception):works.
- Now
- README update
- Red output in pseudo-traceback
- Refactored code into more modules
- All functionality now possible through
checkfixture orfrom pytest_check import check.- The
checkobject from either of these methods can be used as either a context manager or to access the check helper functions.
- The
- Lots of rewrite in README
- API change.
- Access to check helper functions via
import pytest_check as checkis deprecated. - It still works, but will be removed in a future version.
- However, there is no deprecation warning for this.
- Access to check helper functions via
- issue 80 --tb=no should remove tracebacks from xml output
- issue 55 a problem with multiple drive letters.
- Support check failures not blowing up if called outside of a test.
- changelog.md format. :)
- tox.ini cleanup
- refactoring tests to use examples directory instead of embedding example tests in test code.
- this is easier to understand and debug issues.
- also provides extra documentation through examples directory
- Handle cases when context is None
- Update pyproject.toml to use newer flit
- Changed plugin name from pytest_check to pytest-check.
- Add
raises
- Require Python >= 3.6
- Remove old Manifest.in file.
- Fix #64, modifications to maxfail behavior.
- Add
excinfoto call object inpytest_runtest_makereport().- Intended to help with some report systems.
- Remove Beta Classifier
- Status is now "Development Status :: 5 - Production/Stable"
- Jump to 1.0 version, API is fairly stable.
- Fix #43/#44 tests with failing checks and failing asserts now report all issues.
- Add
is_()andis_not()
- Requires pytest 6.0 or above. (Removed some cruft to support pytest 5.x)