pytest2/src/_pytest
David Röthlisberger aaa7e837cc doctest: Add +NUMBER option to ignore irrelevant floating-point differences
When enabled, floating-point numbers only need to match as far as the
precision you have written in the expected doctest output. This avoids
false positives caused by limited floating-point precision, like this:

    Expected:
        0.233
    Got:
        0.23300000000000001

This is inspired by Sébastien Boisgérault's [numtest] but the
implementation is a bit different:

* This implementation edits the literals that are in the "got"
  string (the actual output from the expression being tested), and then
  proceeds to compare the strings literally. This is similar to pytest's
  existing ALLOW_UNICODE and ALLOW_BYTES implementation.

* This implementation only compares floats against floats, not ints
  against floats. That is, the following doctest will fail with pytest
  whereas it would pass with numtest:

      >>> math.py  # doctest: +NUMBER
      3

  This behaviour should be less surprising (less false negatives) when
  you enable NUMBER globally in pytest.ini.

Advantages of this implementation compared to numtest:

* Doesn't require `import numtest` at the top level of the file.
* Works with pytest (if you try to use pytest & numtest together, pytest
  raises "TypeError: unbound method check_output() must be called with
  NumTestOutputChecker instance as first argument (got
  LiteralsOutputChecker instance instead)").
* Works with Python 3.

[numtest]: https://github.com/boisgera/numtest
2019-07-08 17:07:58 +01:00
..
_code remove commented code 2019-06-09 12:51:32 +02:00
_io pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
assertion Remove astor and reproduce the original assertion expression 2019-06-28 13:38:52 -07:00
config Replace importlib_metadata with importlib.metadata on Python 3.8+ 2019-07-04 15:00:10 +02:00
mark Pickup additional positional args passed to _parse_parametrize_args 2019-06-24 20:43:52 -04:00
__init__.py pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
_argcomplete.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
cacheprovider.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
capture.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
compat.py Replace importlib_metadata with importlib.metadata on Python 3.8+ 2019-07-04 15:00:10 +02:00
debugging.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
deprecated.py Deprecate funcargnames alias 2019-06-26 08:53:17 +10:00
doctest.py doctest: Add +NUMBER option to ignore irrelevant floating-point differences 2019-07-08 17:07:58 +01:00
faulthandler.py Change pytest-faulthandler for simplification 2019-06-22 19:22:43 -03:00
fixtures.py Deprecate funcargnames alias 2019-06-26 08:53:17 +10:00
freeze_support.py pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
helpconfig.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
hookspec.py Improve docs and reference 2019-06-26 19:15:00 -03:00
junitxml.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
logging.py Small cleanups on _pytest.compat 2019-06-15 10:06:37 -03:00
main.py Don't crash with --pyargs and a filename that looks like a module 2019-06-27 08:32:32 -07:00
monkeypatch.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
nodes.py Fix crash when discovery fails while using `-p no:terminal` 2019-06-27 10:24:29 -07:00
nose.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
outcomes.py Use new raise syntax in one case 2019-06-24 11:24:03 -07:00
pastebin.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
pathlib.py Switch from deprecated imp to importlib 2019-06-24 09:48:38 -07:00
pytester.py Switch from deprecated imp to importlib 2019-06-24 09:48:38 -07:00
python.py Remove unused/unneeded code 2019-06-15 10:45:16 -03:00
python_api.py Remove unused/unneeded code 2019-06-15 10:45:16 -03:00
recwarn.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
reports.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
resultlog.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
runner.py manual: remove dependence on six 2019-06-03 12:08:02 -03:00
setuponly.py pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
setupplan.py pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
skipping.py pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
stepwise.py Remove handling of collection errors by --sw 2019-06-13 17:19:36 -03:00
terminal.py minor: clarify help with reportchars 2019-06-24 06:07:52 +02:00
tmpdir.py pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
unittest.py item.obj is again a bound method on TestCase function items 2019-06-04 20:22:49 -03:00
warning_types.py Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types' 2019-06-15 11:48:34 -03:00
warnings.py Turn PytestDeprecationWarning into error 2019-06-05 19:02:52 -03:00