From 9e62f9d64edbd5928dbdab4dc7b83270659b4960 Mon Sep 17 00:00:00 2001 From: David Vo Date: Fri, 4 Jan 2019 11:50:36 +1100 Subject: [PATCH 01/17] Fix PEP 565 typo in warnings.rst --- doc/en/warnings.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 3e69d3480..421491086 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -155,7 +155,7 @@ DeprecationWarning and PendingDeprecationWarning .. versionchanged:: 3.9 By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings from -user code and third-party libraries, as recommended by `PEP-0506 `_. +user code and third-party libraries, as recommended by `PEP-0565 `_. This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed. Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over From 7f671586b079f2cbb91e8ac7c267b70f372a7a05 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 4 Jan 2019 10:37:07 -0200 Subject: [PATCH 02/17] Update copyright year --- LICENSE | 2 +- README.rst | 2 +- doc/en/conf.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/LICENSE b/LICENSE index 629df45ac..477af2d2e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2004-2017 Holger Krekel and others +Copyright (c) 2004-2019 Holger Krekel and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.rst b/README.rst index 7454893a2..bd7f1daa6 100644 --- a/README.rst +++ b/README.rst @@ -111,7 +111,7 @@ Consult the `Changelog `__ pag License ------- -Copyright Holger Krekel and others, 2004-2018. +Copyright Holger Krekel and others, 2004-2019. Distributed under the terms of the `MIT`_ license, pytest is free and open source software. diff --git a/doc/en/conf.py b/doc/en/conf.py index 445449185..53600e616 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -64,7 +64,7 @@ master_doc = "contents" # General information about the project. project = u"pytest" year = datetime.datetime.utcnow().year -copyright = u"2015–2018 , holger krekel and pytest-dev team" +copyright = u"2015–2019 , holger krekel and pytest-dev team" # The language for content autogenerated by Sphinx. Refer to documentation From 9d297c06e8679346a3046239554f5d67452b8dea Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 15:21:49 +0000 Subject: [PATCH 03/17] Preparing release version 4.1.0 --- CHANGELOG.rst | 226 ++++++++++++++++++++++++++++ changelog/2169.removal.rst | 1 - changelog/3050.deprecation.rst | 3 - changelog/3078.removal.rst | 3 - changelog/3079.removal.rst | 3 - changelog/3082.removal.rst | 3 - changelog/3083.removal.rst | 3 - changelog/3085.removal.rst | 3 - changelog/3086.removal.rst | 4 - changelog/3191.feature.rst | 23 --- changelog/3532.bugfix.rst | 1 - changelog/3616.removal.rst | 3 - changelog/3632.feature.rst | 1 - changelog/3974.deprecation.rst | 8 - changelog/4278.feature.rst | 4 - changelog/4292.feature.rst | 1 - changelog/4327.bugfix.rst | 1 - changelog/4371.feature.rst | 1 - changelog/4386.feature.rst | 1 - changelog/4397.bugfix.rst | 1 - changelog/4416.feature.rst | 6 - changelog/4421.removal.rst | 3 - changelog/4435.bugfix.rst | 1 - changelog/4435.deprecation.rst | 3 - changelog/4447.trivial.rst | 3 - changelog/4458.bugfix.rst | 1 - changelog/4483.feature.rst | 9 -- changelog/4489.removal.rst | 3 - changelog/4532.feature.rst | 3 - changelog/4535.removal.rst | 1 - changelog/4543.removal.rst | 3 - changelog/4545.removal.rst | 3 - changelog/4546.removal.rst | 3 - changelog/4547.removal.rst | 3 - changelog/4548.removal.rst | 3 - changelog/4557.doc.rst | 1 - changelog/4558.doc.rst | 1 - changelog/4580.doc.rst | 1 - changelog/4599.feature.rst | 2 - changelog/891.removal.rst | 1 - doc/en/announce/index.rst | 1 + doc/en/announce/release-4.1.0.rst | 44 ++++++ doc/en/builtin.rst | 2 - doc/en/cache.rst | 6 +- doc/en/example/nonpython.rst | 8 +- doc/en/example/parametrize.rst | 40 ++--- doc/en/example/pythoncollection.rst | 18 +-- doc/en/example/reportingdemo.rst | 99 +++++++----- doc/en/example/simple.rst | 2 +- doc/en/fixture.rst | 28 ++-- doc/en/usage.rst | 59 +------- 51 files changed, 391 insertions(+), 264 deletions(-) delete mode 100644 changelog/2169.removal.rst delete mode 100644 changelog/3050.deprecation.rst delete mode 100644 changelog/3078.removal.rst delete mode 100644 changelog/3079.removal.rst delete mode 100644 changelog/3082.removal.rst delete mode 100644 changelog/3083.removal.rst delete mode 100644 changelog/3085.removal.rst delete mode 100644 changelog/3086.removal.rst delete mode 100644 changelog/3191.feature.rst delete mode 100644 changelog/3532.bugfix.rst delete mode 100644 changelog/3616.removal.rst delete mode 100644 changelog/3632.feature.rst delete mode 100644 changelog/3974.deprecation.rst delete mode 100644 changelog/4278.feature.rst delete mode 100644 changelog/4292.feature.rst delete mode 100644 changelog/4327.bugfix.rst delete mode 100644 changelog/4371.feature.rst delete mode 100644 changelog/4386.feature.rst delete mode 100644 changelog/4397.bugfix.rst delete mode 100644 changelog/4416.feature.rst delete mode 100644 changelog/4421.removal.rst delete mode 100644 changelog/4435.bugfix.rst delete mode 100644 changelog/4435.deprecation.rst delete mode 100644 changelog/4447.trivial.rst delete mode 100644 changelog/4458.bugfix.rst delete mode 100644 changelog/4483.feature.rst delete mode 100644 changelog/4489.removal.rst delete mode 100644 changelog/4532.feature.rst delete mode 100644 changelog/4535.removal.rst delete mode 100644 changelog/4543.removal.rst delete mode 100644 changelog/4545.removal.rst delete mode 100644 changelog/4546.removal.rst delete mode 100644 changelog/4547.removal.rst delete mode 100644 changelog/4548.removal.rst delete mode 100644 changelog/4557.doc.rst delete mode 100644 changelog/4558.doc.rst delete mode 100644 changelog/4580.doc.rst delete mode 100644 changelog/4599.feature.rst delete mode 100644 changelog/891.removal.rst create mode 100644 doc/en/announce/release-4.1.0.rst diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 22f3ac862..86d751b63 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,232 @@ with advance notice in the **Deprecations** section of releases. .. towncrier release notes start +pytest 4.1.0 (2019-01-05) +========================= + +Removals +-------- + +- `#2169 `_: ``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred. + + +- `#3078 `_: Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented. + + See our `docs `__ on information on how to update your code. + + +- `#3079 `_: Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated. + + See our `docs `__ on information on how to update your code. + + +- `#3082 `_: Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead. + + See our `docs `__ on information on how to update your code. + + +- `#3083 `_: Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``. + + See our `docs `__ on information on how to update your code. + + +- `#3085 `_: Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead. + + See our `docs `__ on information on how to update your code. + + +- `#3086 `_: ``[pytest]`` section in **setup.cfg** files is not longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files + are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs. + + Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``. + + +- `#3616 `_: Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now. + + See our `docs `__ on information on how to update your code. + + +- `#4421 `_: Removed the implementation of the ``pytest_namespace`` hook. + + See our `docs `__ on information on how to update your code. + + +- `#4489 `_: Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures. + + See our `docs `__ on information on how to update your code. + + +- `#4535 `_: Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago. + + +- `#4543 `_: Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead. + + See our `docs `__ on information on how to update your code. + + +- `#4545 `_: Calling fixtures directly is now always an error instead of a warning. + + See our `docs `__ on information on how to update your code. + + +- `#4546 `_: Remove ``Node.get_marker(name)`` the return value was not usable for more than a existence check. + + Use ``Node.get_closest_marker(name)`` as a replacement. + + +- `#4547 `_: The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead. + + See our `docs `__ for more information. + + +- `#4548 `_: An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``). + + See our `docs `__ for more information. + + +- `#891 `_: Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them. + + + +Deprecations +------------ + +- `#3050 `_: Deprecated the ``pytest.config`` global. + + See https://docs.pytest.org/en/latest/deprecations.html#pytest-config-global for rationale. + + +- `#3974 `_: Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``. + + It is a common mistake to think this parameter will match the exception message, while in fact + it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this + mistake and because it is believed to be little used, pytest is deprecating it without providing + an alternative for the moment. + + If you have concerns about this, please comment on `issue #3974 `__. + + +- `#4435 `_: Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``. + + See https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec for rationale and examples. + + + +Features +-------- + +- `#3191 `_: A warning is now issued when assertions are made for ``None``. + + This is a common source of confusion among new users, which write: + + .. code-block:: python + + assert mocked_object.assert_called_with(3, 4, 5, key="value") + + When they should write: + + .. code-block:: python + + mocked_object.assert_called_with(3, 4, 5, key="value") + + Because the ``assert_called_with`` method of mock objects already executes an assertion. + + This warning will not be issued when ``None`` is explicitly checked. An assertion like: + + .. code-block:: python + + assert variable is None + + will not issue the warning. + + +- `#3632 `_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs `_ or `dataclasses `_ (Python 3.7+, `backported to 3.6 `_). + + +- `#4278 `_: ``CACHEDIR.TAG`` files are now created inside cache directories. + + Those files are part of the `Cache Directory Tagging Standard `__, and can + be used by backup or synchronization programs to identify pytest's cache directory as such. + + +- `#4292 `_: ``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting. + + +- `#4371 `_: Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``. + + +- `#4386 `_: Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``. + + +- `#4416 `_: pdb: added support for keyword arguments with ``pdb.set_trace``. + + It handles ``header`` similar to Python 3.7 does it, and forwards any + other keyword arguments to the ``Pdb`` constructor. + + This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``. + + +- `#4483 `_: Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times. + + The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration + report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file: + + .. code-block:: ini + + [pytest] + junit_duration_report = call + + +- `#4532 `_: ``-ra`` now will show errors and failures last, instead of as the first items in the summary. + + This makes it easier to obtain a list of errors and failures to run tests selectively. + + +- `#4599 `_: ``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the + requested module cannot be imported. + + + +Bug Fixes +--------- + +- `#3532 `_: ``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``. + + +- `#4327 `_: ``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``. + + +- `#4397 `_: Ensure that node ids are printable. + + +- `#4435 `_: Fixed ``raises(..., 'code(string)')`` frame filename. + + +- `#4458 `_: Display actual test ids in ``--collect-only``. + + + +Improved Documentation +---------------------- + +- `#4557 `_: Markers example documentation page updated to support latest pytest version. + + +- `#4558 `_: Update cache documentation example to correctly show cache hit and miss. + + +- `#4580 `_: Improved detailed summary report documentation. + + + +Trivial/Internal Changes +------------------------ + +- `#4447 `_: Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``. + + It was decided to remove this feature at the next major revision. + + pytest 4.0.2 (2018-12-13) ========================= diff --git a/changelog/2169.removal.rst b/changelog/2169.removal.rst deleted file mode 100644 index 272ddbdfb..000000000 --- a/changelog/2169.removal.rst +++ /dev/null @@ -1 +0,0 @@ -``pytest.mark.parametrize``: in previous versions, errors raised by id functions were suppressed and changed into warnings. Now the exceptions are propagated, along with a pytest message informing the node, parameter value and index where the exception occurred. diff --git a/changelog/3050.deprecation.rst b/changelog/3050.deprecation.rst deleted file mode 100644 index fce5979d6..000000000 --- a/changelog/3050.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -Deprecated the ``pytest.config`` global. - -See https://docs.pytest.org/en/latest/deprecations.html#pytest-config-global for rationale. diff --git a/changelog/3078.removal.rst b/changelog/3078.removal.rst deleted file mode 100644 index 8f90811c3..000000000 --- a/changelog/3078.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Remove legacy internal warnings system: ``config.warn``, ``Node.warn``. The ``pytest_logwarning`` now issues a warning when implemented. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3079.removal.rst b/changelog/3079.removal.rst deleted file mode 100644 index cb2265ff3..000000000 --- a/changelog/3079.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed support for yield tests - they are fundamentally broken because they don't support fixtures properly since collection and test execution were separated. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3082.removal.rst b/changelog/3082.removal.rst deleted file mode 100644 index 750f097bc..000000000 --- a/changelog/3082.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed support for applying marks directly to values in ``@pytest.mark.parametrize``. Use ``pytest.param`` instead. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3083.removal.rst b/changelog/3083.removal.rst deleted file mode 100644 index 74d268a4e..000000000 --- a/changelog/3083.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed ``Metafunc.addcall``. This was the predecessor mechanism to ``@pytest.mark.parametrize``. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3085.removal.rst b/changelog/3085.removal.rst deleted file mode 100644 index 67ba04c28..000000000 --- a/changelog/3085.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed support for passing strings to ``pytest.main``. Now, always pass a list of strings instead. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3086.removal.rst b/changelog/3086.removal.rst deleted file mode 100644 index 3974aa500..000000000 --- a/changelog/3086.removal.rst +++ /dev/null @@ -1,4 +0,0 @@ -``[pytest]`` section in **setup.cfg** files is not longer supported, use ``[tool:pytest]`` instead. ``setup.cfg`` files -are meant for use with ``distutils``, and a section named ``pytest`` has notoriously been a source of conflicts and bugs. - -Note that for **pytest.ini** and **tox.ini** files the section remains ``[pytest]``. diff --git a/changelog/3191.feature.rst b/changelog/3191.feature.rst deleted file mode 100644 index dbf1c8304..000000000 --- a/changelog/3191.feature.rst +++ /dev/null @@ -1,23 +0,0 @@ -A warning is now issued when assertions are made for ``None``. - -This is a common source of confusion among new users, which write: - -.. code-block:: python - - assert mocked_object.assert_called_with(3, 4, 5, key="value") - -When they should write: - -.. code-block:: python - - mocked_object.assert_called_with(3, 4, 5, key="value") - -Because the ``assert_called_with`` method of mock objects already executes an assertion. - -This warning will not be issued when ``None`` is explicitly checked. An assertion like: - -.. code-block:: python - - assert variable is None - -will not issue the warning. diff --git a/changelog/3532.bugfix.rst b/changelog/3532.bugfix.rst deleted file mode 100644 index 8651458d9..000000000 --- a/changelog/3532.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -``-p`` now accepts its argument without a space between the value, for example ``-pmyplugin``. diff --git a/changelog/3616.removal.rst b/changelog/3616.removal.rst deleted file mode 100644 index 5d8c9134e..000000000 --- a/changelog/3616.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed the deprecated compat properties for ``node.Class/Function/Module`` - use ``pytest.Class/Function/Module`` now. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/3632.feature.rst b/changelog/3632.feature.rst deleted file mode 100644 index cb1d93750..000000000 --- a/changelog/3632.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs `_ or `dataclasses `_ (Python 3.7+, `backported to 3.6 `_). diff --git a/changelog/3974.deprecation.rst b/changelog/3974.deprecation.rst deleted file mode 100644 index 070ecb8b2..000000000 --- a/changelog/3974.deprecation.rst +++ /dev/null @@ -1,8 +0,0 @@ -Passing the ``message`` parameter of ``pytest.raises`` now issues a ``DeprecationWarning``. - -It is a common mistake to think this parameter will match the exception message, while in fact -it only serves to provide a custom message in case the ``pytest.raises`` check fails. To avoid this -mistake and because it is believed to be little used, pytest is deprecating it without providing -an alternative for the moment. - -If you have concerns about this, please comment on `issue #3974 `__. diff --git a/changelog/4278.feature.rst b/changelog/4278.feature.rst deleted file mode 100644 index 332e64572..000000000 --- a/changelog/4278.feature.rst +++ /dev/null @@ -1,4 +0,0 @@ -``CACHEDIR.TAG`` files are now created inside cache directories. - -Those files are part of the `Cache Directory Tagging Standard `__, and can -be used by backup or synchronization programs to identify pytest's cache directory as such. diff --git a/changelog/4292.feature.rst b/changelog/4292.feature.rst deleted file mode 100644 index 760a27783..000000000 --- a/changelog/4292.feature.rst +++ /dev/null @@ -1 +0,0 @@ -``pytest.outcomes.Exit`` is derived from ``SystemExit`` instead of ``KeyboardInterrupt``. This allows us to better handle ``pdb`` exiting. diff --git a/changelog/4327.bugfix.rst b/changelog/4327.bugfix.rst deleted file mode 100644 index 72223af4e..000000000 --- a/changelog/4327.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -``approx`` again works with more generic containers, more precisely instances of ``Iterable`` and ``Sized`` instead of more restrictive ``Sequence``. diff --git a/changelog/4371.feature.rst b/changelog/4371.feature.rst deleted file mode 100644 index f205fc269..000000000 --- a/changelog/4371.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Updated the ``--collect-only`` option to display test descriptions when ran using ``--verbose``. diff --git a/changelog/4386.feature.rst b/changelog/4386.feature.rst deleted file mode 100644 index 5133a39a7..000000000 --- a/changelog/4386.feature.rst +++ /dev/null @@ -1 +0,0 @@ -Restructured ``ExceptionInfo`` object construction and ensure incomplete instances have a ``repr``/``str``. diff --git a/changelog/4397.bugfix.rst b/changelog/4397.bugfix.rst deleted file mode 100644 index d1a5bd3ba..000000000 --- a/changelog/4397.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Ensure that node ids are printable. diff --git a/changelog/4416.feature.rst b/changelog/4416.feature.rst deleted file mode 100644 index 949e7c25a..000000000 --- a/changelog/4416.feature.rst +++ /dev/null @@ -1,6 +0,0 @@ -pdb: added support for keyword arguments with ``pdb.set_trace``. - -It handles ``header`` similar to Python 3.7 does it, and forwards any -other keyword arguments to the ``Pdb`` constructor. - -This allows for ``__import__("pdb").set_trace(skip=["foo.*"])``. diff --git a/changelog/4421.removal.rst b/changelog/4421.removal.rst deleted file mode 100644 index 4bebd5c19..000000000 --- a/changelog/4421.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed the implementation of the ``pytest_namespace`` hook. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/4435.bugfix.rst b/changelog/4435.bugfix.rst deleted file mode 100644 index 36ace1fab..000000000 --- a/changelog/4435.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Fixed ``raises(..., 'code(string)')`` frame filename. diff --git a/changelog/4435.deprecation.rst b/changelog/4435.deprecation.rst deleted file mode 100644 index 6815c1776..000000000 --- a/changelog/4435.deprecation.rst +++ /dev/null @@ -1,3 +0,0 @@ -Deprecated ``raises(..., 'code(as_a_string)')`` and ``warns(..., 'code(as_a_string)')``. - -See https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec for rationale and examples. diff --git a/changelog/4447.trivial.rst b/changelog/4447.trivial.rst deleted file mode 100644 index 884ccd4c9..000000000 --- a/changelog/4447.trivial.rst +++ /dev/null @@ -1,3 +0,0 @@ -Changed the deprecation type of ``--result-log`` to ``PytestDeprecationWarning``. - -It was decided to remove this feature at the next major revision. diff --git a/changelog/4458.bugfix.rst b/changelog/4458.bugfix.rst deleted file mode 100644 index 891fb9a2f..000000000 --- a/changelog/4458.bugfix.rst +++ /dev/null @@ -1 +0,0 @@ -Display actual test ids in ``--collect-only``. diff --git a/changelog/4483.feature.rst b/changelog/4483.feature.rst deleted file mode 100644 index 9b3018707..000000000 --- a/changelog/4483.feature.rst +++ /dev/null @@ -1,9 +0,0 @@ -Added ini parameter ``junit_duration_report`` to optionally report test call durations, excluding setup and teardown times. - -The JUnit XML specification and the default pytest behavior is to include setup and teardown times in the test duration -report. You can include just the call durations instead (excluding setup and teardown) by adding this to your ``pytest.ini`` file: - -.. code-block:: ini - - [pytest] - junit_duration_report = call diff --git a/changelog/4489.removal.rst b/changelog/4489.removal.rst deleted file mode 100644 index 423620465..000000000 --- a/changelog/4489.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed ``request.cached_setup``. This was the predecessor mechanism to modern fixtures. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/4532.feature.rst b/changelog/4532.feature.rst deleted file mode 100644 index ce7eb3729..000000000 --- a/changelog/4532.feature.rst +++ /dev/null @@ -1,3 +0,0 @@ -``-ra`` now will show errors and failures last, instead of as the first items in the summary. - -This makes it easier to obtain a list of errors and failures to run tests selectively. diff --git a/changelog/4535.removal.rst b/changelog/4535.removal.rst deleted file mode 100644 index 89de6b744..000000000 --- a/changelog/4535.removal.rst +++ /dev/null @@ -1 +0,0 @@ -Removed the deprecated ``PyCollector.makeitem`` method. This method was made public by mistake a long time ago. diff --git a/changelog/4543.removal.rst b/changelog/4543.removal.rst deleted file mode 100644 index 0a2b615f9..000000000 --- a/changelog/4543.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Removed support to define fixtures using the ``pytest_funcarg__`` prefix. Use the ``@pytest.fixture`` decorator instead. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/4545.removal.rst b/changelog/4545.removal.rst deleted file mode 100644 index 865d2fc12..000000000 --- a/changelog/4545.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Calling fixtures directly is now always an error instead of a warning. - -See our `docs `__ on information on how to update your code. diff --git a/changelog/4546.removal.rst b/changelog/4546.removal.rst deleted file mode 100644 index 977a30e8c..000000000 --- a/changelog/4546.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -Remove ``Node.get_marker(name)`` the return value was not usable for more than a existence check. - -Use ``Node.get_closest_marker(name)`` as a replacement. diff --git a/changelog/4547.removal.rst b/changelog/4547.removal.rst deleted file mode 100644 index a30d5d7bd..000000000 --- a/changelog/4547.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -The deprecated ``record_xml_property`` fixture has been removed, use the more generic ``record_property`` instead. - -See our `docs `__ for more information. diff --git a/changelog/4548.removal.rst b/changelog/4548.removal.rst deleted file mode 100644 index bd47b1d51..000000000 --- a/changelog/4548.removal.rst +++ /dev/null @@ -1,3 +0,0 @@ -An error is now raised if the ``pytest_plugins`` variable is defined in a non-top-level ``conftest.py`` file (i.e., not residing in the ``rootdir``). - -See our `docs `__ for more information. diff --git a/changelog/4557.doc.rst b/changelog/4557.doc.rst deleted file mode 100644 index dba2e39cd..000000000 --- a/changelog/4557.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Markers example documentation page updated to support latest pytest version. diff --git a/changelog/4558.doc.rst b/changelog/4558.doc.rst deleted file mode 100644 index 09dc5b863..000000000 --- a/changelog/4558.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Update cache documentation example to correctly show cache hit and miss. diff --git a/changelog/4580.doc.rst b/changelog/4580.doc.rst deleted file mode 100644 index 2d8d52f33..000000000 --- a/changelog/4580.doc.rst +++ /dev/null @@ -1 +0,0 @@ -Improved detailed summary report documentation. diff --git a/changelog/4599.feature.rst b/changelog/4599.feature.rst deleted file mode 100644 index 12ed20b23..000000000 --- a/changelog/4599.feature.rst +++ /dev/null @@ -1,2 +0,0 @@ -``pytest.importorskip`` now supports a ``reason`` parameter, which will be shown when the -requested module cannot be imported. diff --git a/changelog/891.removal.rst b/changelog/891.removal.rst deleted file mode 100644 index 82d75c530..000000000 --- a/changelog/891.removal.rst +++ /dev/null @@ -1 +0,0 @@ -Remove ``testfunction.markername`` attributes - use ``Node.iter_markers(name=None)`` to iterate them. diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst index d6379f1b3..40734e5b3 100644 --- a/doc/en/announce/index.rst +++ b/doc/en/announce/index.rst @@ -6,6 +6,7 @@ Release announcements :maxdepth: 2 + release-4.1.0 release-4.0.2 release-4.0.1 release-4.0.0 diff --git a/doc/en/announce/release-4.1.0.rst b/doc/en/announce/release-4.1.0.rst new file mode 100644 index 000000000..b7a076f61 --- /dev/null +++ b/doc/en/announce/release-4.1.0.rst @@ -0,0 +1,44 @@ +pytest-4.1.0 +======================================= + +The pytest team is proud to announce the 4.1.0 release! + +pytest is a mature Python testing tool with more than a 2000 tests +against itself, passing on many different interpreters and platforms. + +This release contains a number of bugs fixes and improvements, so users are encouraged +to take a look at the CHANGELOG: + + https://docs.pytest.org/en/latest/changelog.html + +For complete documentation, please visit: + + https://docs.pytest.org/en/latest/ + +As usual, you can upgrade from pypi via: + + pip install -U pytest + +Thanks to all who contributed to this release, among them: + +* Adam Johnson +* Aly Sivji +* Andrey Paramonov +* Anthony Sottile +* Bruno Oliveira +* Daniel Hahler +* David Vo +* Hyunchel Kim +* Jeffrey Rackauckas +* Kanguros +* Nicholas Devenish +* Pedro Algarvio +* Randy Barlow +* Ronny Pfannschmidt +* Tomer Keren +* feuillemorte +* wim glenn + + +Happy testing, +The Pytest Development Team diff --git a/doc/en/builtin.rst b/doc/en/builtin.rst index 1e376f0d3..a40dfc223 100644 --- a/doc/en/builtin.rst +++ b/doc/en/builtin.rst @@ -68,8 +68,6 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a def test_function(record_property): record_property("example_key", 1) - record_xml_property - (Deprecated) use record_property. record_xml_attribute Add extra xml attributes to the tag for the calling test. The fixture is callable with ``(name, value)``, with value being diff --git a/doc/en/cache.rst b/doc/en/cache.rst index a0fa72db1..ba9d87a5f 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -215,7 +215,9 @@ If you run this command for the first time, you can see the print statement: > assert mydata == 23 E assert 42 == 23 - test_caching.py:14: AssertionError + test_caching.py:17: AssertionError + -------------------------- Captured stdout setup --------------------------- + running expensive computation... 1 failed in 0.12 seconds If you run it a second time the value will be retrieved from @@ -234,7 +236,7 @@ the cache and nothing will be printed: > assert mydata == 23 E assert 42 == 23 - test_caching.py:14: AssertionError + test_caching.py:17: AssertionError 1 failed in 0.12 seconds See the :ref:`cache-api` for more details. diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index 5b96a33bf..eba8279f3 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -90,9 +90,9 @@ interesting to just look at the collection tree: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR/nonpython, inifile: collected 2 items - - - - + + + + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index d4540fe5e..92756e492 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -147,15 +147,15 @@ objects, they are still using the default pytest representation: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 8 items - - - - - - - - - + + + + + + + + + ======================= no tests ran in 0.12 seconds ======================= @@ -219,12 +219,12 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 4 items - - - - - - + + + + + + ======================= no tests ran in 0.12 seconds ======================= @@ -285,9 +285,9 @@ Let's first see how it looks like at collection time: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 2 items - - - + + + ======================= no tests ran in 0.12 seconds ======================= @@ -350,8 +350,8 @@ The result of this test will be successful: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 1 item - - + + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 3f1dd68ee..394924e2d 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -134,10 +134,10 @@ The test collection would look like this: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini collected 2 items - - - - + + + + ======================= no tests ran in 0.12 seconds ======================= @@ -189,11 +189,11 @@ You can always peek at the collection tree without running tests like this: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini collected 3 items - - - - - + + + + + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index ffccdf77f..2f8c25f02 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -15,9 +15,9 @@ get on the terminal - we are working on that): =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR/assertion, inifile: - collected 42 items + collected 44 items - failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] + failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] ================================= FAILURES ================================= ___________________________ test_generative[3-6] ___________________________ @@ -289,6 +289,36 @@ get on the terminal - we are working on that): E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ failure_demo.py:99: AssertionError + ______________ TestSpecialisedExplanations.test_eq_dataclass _______________ + + self = + + def test_eq_dataclass(self): + > from dataclasses import dataclass + E ModuleNotFoundError: No module named 'dataclasses' + + failure_demo.py:102: ModuleNotFoundError + ________________ TestSpecialisedExplanations.test_eq_attrs _________________ + + self = + + def test_eq_attrs(self): + import attr + + @attr.s + class Foo(object): + a = attr.ib() + b = attr.ib() + + left = Foo(1, "b") + right = Foo(1, "c") + > assert left == right + E AssertionError: assert Foo(a=1, b='b') == Foo(a=1, b='c') + E Omitting 1 identical items, use -vv to show + E Differing attributes: + E b: 'b' != 'c' + + failure_demo.py:123: AssertionError ______________________________ test_attribute ______________________________ def test_attribute(): @@ -300,7 +330,7 @@ get on the terminal - we are working on that): E assert 1 == 2 E + where 1 = .Foo object at 0xdeadbeef>.b - failure_demo.py:107: AssertionError + failure_demo.py:131: AssertionError _________________________ test_attribute_instance __________________________ def test_attribute_instance(): @@ -312,7 +342,7 @@ get on the terminal - we are working on that): E + where 1 = .Foo object at 0xdeadbeef>.b E + where .Foo object at 0xdeadbeef> = .Foo'>() - failure_demo.py:114: AssertionError + failure_demo.py:138: AssertionError __________________________ test_attribute_failure __________________________ def test_attribute_failure(): @@ -325,7 +355,7 @@ get on the terminal - we are working on that): i = Foo() > assert i.b == 2 - failure_demo.py:125: + failure_demo.py:149: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = .Foo object at 0xdeadbeef> @@ -334,7 +364,7 @@ get on the terminal - we are working on that): > raise Exception("Failed to get attrib") E Exception: Failed to get attrib - failure_demo.py:120: Exception + failure_demo.py:144: Exception _________________________ test_attribute_multiple __________________________ def test_attribute_multiple(): @@ -351,31 +381,26 @@ get on the terminal - we are working on that): E + and 2 = .Bar object at 0xdeadbeef>.b E + where .Bar object at 0xdeadbeef> = .Bar'>() - failure_demo.py:135: AssertionError + failure_demo.py:159: AssertionError __________________________ TestRaises.test_raises __________________________ self = def test_raises(self): - s = "qwe" # NOQA - > raises(TypeError, "int(s)") + s = "qwe" + > raises(TypeError, int, s) + E ValueError: invalid literal for int() with base 10: 'qwe' - failure_demo.py:145: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ - - > int(s) - E ValueError: invalid literal for int() with base 10: 'qwe' - - <0-codegen $REGENDOC_TMPDIR/assertion/failure_demo.py:145>:1: ValueError + failure_demo.py:169: ValueError ______________________ TestRaises.test_raises_doesnt _______________________ self = def test_raises_doesnt(self): - > raises(IOError, "int('3')") + > raises(IOError, int, "3") E Failed: DID NOT RAISE - failure_demo.py:148: Failed + failure_demo.py:172: Failed __________________________ TestRaises.test_raise ___________________________ self = @@ -384,7 +409,7 @@ get on the terminal - we are working on that): > raise ValueError("demo error") E ValueError: demo error - failure_demo.py:151: ValueError + failure_demo.py:175: ValueError ________________________ TestRaises.test_tupleerror ________________________ self = @@ -393,7 +418,7 @@ get on the terminal - we are working on that): > a, b = [1] # NOQA E ValueError: not enough values to unpack (expected 2, got 1) - failure_demo.py:154: ValueError + failure_demo.py:178: ValueError ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ self = @@ -404,7 +429,7 @@ get on the terminal - we are working on that): > a, b = items.pop() E TypeError: 'int' object is not iterable - failure_demo.py:159: TypeError + failure_demo.py:183: TypeError --------------------------- Captured stdout call --------------------------- items is [1, 2, 3] ________________________ TestRaises.test_some_error ________________________ @@ -415,7 +440,7 @@ get on the terminal - we are working on that): > if namenotexi: # NOQA E NameError: name 'namenotexi' is not defined - failure_demo.py:162: NameError + failure_demo.py:186: NameError ____________________ test_dynamic_compile_shows_nicely _____________________ def test_dynamic_compile_shows_nicely(): @@ -430,14 +455,14 @@ get on the terminal - we are working on that): sys.modules[name] = module > module.foo() - failure_demo.py:180: + failure_demo.py:204: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def foo(): > assert 1 == 0 E AssertionError - <2-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:177>:2: AssertionError + <0-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:201>:2: AssertionError ____________________ TestMoreErrors.test_complex_error _____________________ self = @@ -451,7 +476,7 @@ get on the terminal - we are working on that): > somefunc(f(), g()) - failure_demo.py:191: + failure_demo.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ failure_demo.py:13: in somefunc otherfunc(x, y) @@ -473,7 +498,7 @@ get on the terminal - we are working on that): > a, b = items E ValueError: not enough values to unpack (expected 2, got 0) - failure_demo.py:195: ValueError + failure_demo.py:219: ValueError ____________________ TestMoreErrors.test_z2_type_error _____________________ self = @@ -483,7 +508,7 @@ get on the terminal - we are working on that): > a, b = items E TypeError: 'int' object is not iterable - failure_demo.py:199: TypeError + failure_demo.py:223: TypeError ______________________ TestMoreErrors.test_startswith ______________________ self = @@ -496,7 +521,7 @@ get on the terminal - we are working on that): E + where False = ('456') E + where = '123'.startswith - failure_demo.py:204: AssertionError + failure_demo.py:228: AssertionError __________________ TestMoreErrors.test_startswith_nested ___________________ self = @@ -515,7 +540,7 @@ get on the terminal - we are working on that): E + where '123' = .f at 0xdeadbeef>() E + and '456' = .g at 0xdeadbeef>() - failure_demo.py:213: AssertionError + failure_demo.py:237: AssertionError _____________________ TestMoreErrors.test_global_func ______________________ self = @@ -526,7 +551,7 @@ get on the terminal - we are working on that): E + where False = isinstance(43, float) E + where 43 = globf(42) - failure_demo.py:216: AssertionError + failure_demo.py:240: AssertionError _______________________ TestMoreErrors.test_instance _______________________ self = @@ -537,7 +562,7 @@ get on the terminal - we are working on that): E assert 42 != 42 E + where 42 = .x - failure_demo.py:220: AssertionError + failure_demo.py:244: AssertionError _______________________ TestMoreErrors.test_compare ________________________ self = @@ -547,7 +572,7 @@ get on the terminal - we are working on that): E assert 11 < 5 E + where 11 = globf(10) - failure_demo.py:223: AssertionError + failure_demo.py:247: AssertionError _____________________ TestMoreErrors.test_try_finally ______________________ self = @@ -558,7 +583,7 @@ get on the terminal - we are working on that): > assert x == 0 E assert 1 == 0 - failure_demo.py:228: AssertionError + failure_demo.py:252: AssertionError ___________________ TestCustomAssertMsg.test_single_line ___________________ self = @@ -573,7 +598,7 @@ get on the terminal - we are working on that): E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:239: AssertionError + failure_demo.py:263: AssertionError ____________________ TestCustomAssertMsg.test_multiline ____________________ self = @@ -592,7 +617,7 @@ get on the terminal - we are working on that): E assert 1 == 2 E + where 1 = .A'>.a - failure_demo.py:246: AssertionError + failure_demo.py:270: AssertionError ___________________ TestCustomAssertMsg.test_custom_repr ___________________ self = @@ -614,5 +639,5 @@ get on the terminal - we are working on that): E assert 1 == 2 E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a - failure_demo.py:259: AssertionError - ======================== 42 failed in 0.12 seconds ========================= + failure_demo.py:283: AssertionError + ======================== 44 failed in 0.12 seconds ========================= diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 95c0e6365..76a1ddc80 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -598,7 +598,7 @@ We can run this: file $REGENDOC_TMPDIR/b/test_error.py, line 1 def test_root(db): # no db here, will error out E fixture 'db' not found - > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, record_xml_property, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory + > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory > use 'pytest --fixtures [testpath]' for help on them. $REGENDOC_TMPDIR/b/test_error.py:1 diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 133901dde..4dd68f8e4 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -628,7 +628,7 @@ So let's just do another run: response, msg = smtp_connection.ehlo() assert response == 250 > assert b"smtp.gmail.com" in msg - E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8' + E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8\nCHUNKING' test_module.py:5: AssertionError -------------------------- Captured stdout setup --------------------------- @@ -703,19 +703,19 @@ Running the above tests results in the following test IDs being used: platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: collected 10 items - - - - - - - - - - - - - + + + + + + + + + + + + + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/usage.rst b/doc/en/usage.rst index bb1e9218c..bd9706c4f 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -158,34 +158,9 @@ Example: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 7 items + collected 0 items - test_examples.py ..FEsxX [100%] - - ==================================== ERRORS ==================================== - _________________________ ERROR at setup of test_error _________________________ - file /Users/chainz/tmp/pytestratest/test_examples.py, line 17 - def test_error(unknown_fixture): - E fixture 'unknown_fixture' not found - > available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_xml_attribute, record_xml_property, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory - > use 'pytest --fixtures [testpath]' for help on them. - - /Users/chainz/tmp/pytestratest/test_examples.py:17 - =================================== FAILURES =================================== - __________________________________ test_fail ___________________________________ - - def test_fail(): - > assert 0 - E assert 0 - - test_examples.py:14: AssertionError - =========================== short test summary info ============================ - FAIL test_examples.py::test_fail - ERROR test_examples.py::test_error - SKIP [1] test_examples.py:21: Example - XFAIL test_examples.py::test_xfail - XPASS test_examples.py::test_xpass - = 1 failed, 2 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.07 seconds = + ======================= no tests ran in 0.12 seconds ======================= The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes". @@ -208,22 +183,9 @@ More than one character can be used, so for example to only see failed and skipp =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 2 items + collected 0 items - test_examples.py Fs [100%] - - =================================== FAILURES =================================== - __________________________________ test_fail ___________________________________ - - def test_fail(): - > assert 0 - E assert 0 - - test_examples.py:14: AssertionError - =========================== short test summary info ============================ - FAIL test_examples.py::test_fail - SKIP [1] test_examples.py:21: Example - ===================== 1 failed, 1 skipped in 0.09 seconds ====================== + ======================= no tests ran in 0.12 seconds ======================= Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had captured output: @@ -234,18 +196,9 @@ captured output: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y rootdir: $REGENDOC_TMPDIR, inifile: - collected 2 items + collected 0 items - test_examples.py .. [100%] - =========================== short test summary info ============================ - PASSED test_examples.py::test_pass - PASSED test_examples.py::test_pass_with_output - - ==================================== PASSES ==================================== - ____________________________ test_pass_with_output _____________________________ - ----------------------------- Captured stdout call ----------------------------- - Passing test - =========================== 2 passed in 0.04 seconds =========================== + ======================= no tests ran in 0.12 seconds ======================= .. _pdb-option: From e380d4306bcc56c441255c4a1d92878f4b553fce Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 15:31:42 -0200 Subject: [PATCH 04/17] Anonimize attrs links --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 86d751b63..3860ff735 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -157,7 +157,7 @@ Features will not issue the warning. -- `#3632 `_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs `_ or `dataclasses `_ (Python 3.7+, `backported to 3.6 `_). +- `#3632 `_: Richer equality comparison introspection on ``AssertionError`` for objects created using `attrs `__ or `dataclasses `_ (Python 3.7+, `backported to 3.6 `__). - `#4278 `_: ``CACHEDIR.TAG`` files are now created inside cache directories. @@ -1983,7 +1983,7 @@ Bug Fixes Trivial/Internal Changes ------------------------ -- pytest now depends on `attrs `_ for internal +- pytest now depends on `attrs `__ for internal structures to ease code maintainability. (`#2641 `_) From 5a8e674e927970e2f35d93b0fd2f10ea9c81d287 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 17:16:52 +0000 Subject: [PATCH 05/17] Add dataclasses as a regendoc dependency --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 7a69000c8..3d5c2fd56 100644 --- a/tox.ini +++ b/tox.ini @@ -148,6 +148,7 @@ deps = sphinx PyYAML regendoc>=0.6.1 + dataclasses whitelist_externals = rm make From d0e9b4812f083289cf14a581ab05da06d57d7174 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 17:32:16 +0000 Subject: [PATCH 06/17] Regendocs --- doc/en/assert.rst | 30 +++--- doc/en/cache.rst | 58 ++++++----- doc/en/capture.rst | 14 +-- doc/en/doctest.rst | 8 +- doc/en/example/markers.rst | 144 +++++++++++++++++----------- doc/en/example/nonpython.rst | 32 ++++--- doc/en/example/parametrize.rst | 78 ++++++++------- doc/en/example/pythoncollection.rst | 18 ++-- doc/en/example/reportingdemo.rst | 128 ++++++++++++++----------- doc/en/example/simple.rst | 144 ++++++++++++++++------------ doc/en/fixture.rst | 88 +++++++++-------- doc/en/getting-started.rst | 30 +++--- doc/en/index.rst | 12 ++- doc/en/parametrize.rst | 32 ++++--- doc/en/skipping.rst | 10 +- doc/en/tmpdir.rst | 24 +++-- doc/en/unittest.rst | 16 ++-- doc/en/usage.rst | 20 ++-- doc/en/warnings.rst | 20 ++-- doc/en/writing_plugins.rst | 10 +- 20 files changed, 532 insertions(+), 384 deletions(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index b13a071f6..7f422af1f 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -27,15 +27,17 @@ you will see the return value of the function call: .. code-block:: pytest $ pytest test_assert1.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_assert1.py F [100%] + test_assert1.py F [100%] - ================================= FAILURES ================================= - ______________________________ test_function _______________________________ + ====================================== FAILURES ====================================== + ___________________________________ test_function ____________________________________ def test_function(): > assert f() == 4 @@ -43,7 +45,7 @@ you will see the return value of the function call: E + where 3 = f() test_assert1.py:5: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== ``pytest`` has support for showing the values of the most common subexpressions including calls, attributes, comparisons, and binary and unary @@ -171,15 +173,17 @@ if you run this module: .. code-block:: pytest $ pytest test_assert2.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_assert2.py F [100%] + test_assert2.py F [100%] - ================================= FAILURES ================================= - ___________________________ test_set_comparison ____________________________ + ====================================== FAILURES ====================================== + ________________________________ test_set_comparison _________________________________ def test_set_comparison(): set1 = set("1308") @@ -193,7 +197,7 @@ if you run this module: E Use -v to get the full diff test_assert2.py:5: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== Special comparisons are done for a number of cases: @@ -243,9 +247,9 @@ the conftest file: .. code-block:: pytest $ pytest -q test_foocompare.py - F [100%] - ================================= FAILURES ================================= - _______________________________ test_compare _______________________________ + F [100%] + ====================================== FAILURES ====================================== + ____________________________________ test_compare ____________________________________ def test_compare(): f1 = Foo(1) diff --git a/doc/en/cache.rst b/doc/en/cache.rst index ba9d87a5f..1814d386d 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -48,9 +48,9 @@ If you run this for the first time you will see two failures: .. code-block:: pytest $ pytest -q - .................F.......F........................ [100%] - ================================= FAILURES ================================= - _______________________________ test_num[17] _______________________________ + .................F.......F........................ [100%] + ====================================== FAILURES ====================================== + ____________________________________ test_num[17] ____________________________________ i = 17 @@ -61,7 +61,7 @@ If you run this for the first time you will see two failures: E Failed: bad luck test_50.py:6: Failed - _______________________________ test_num[25] _______________________________ + ____________________________________ test_num[25] ____________________________________ i = 25 @@ -79,16 +79,18 @@ If you then run it with ``--lf``: .. code-block:: pytest $ pytest --lf - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 50 items / 48 deselected run-last-failure: rerun previous 2 failures - test_50.py FF [100%] + test_50.py FF [100%] - ================================= FAILURES ================================= - _______________________________ test_num[17] _______________________________ + ====================================== FAILURES ====================================== + ____________________________________ test_num[17] ____________________________________ i = 17 @@ -99,7 +101,7 @@ If you then run it with ``--lf``: E Failed: bad luck test_50.py:6: Failed - _______________________________ test_num[25] _______________________________ + ____________________________________ test_num[25] ____________________________________ i = 25 @@ -110,7 +112,7 @@ If you then run it with ``--lf``: E Failed: bad luck test_50.py:6: Failed - ================= 2 failed, 48 deselected in 0.12 seconds ================== + ====================== 2 failed, 48 deselected in 0.12 seconds ======================= You have run only the two failing test from the last run, while 48 tests have not been run ("deselected"). @@ -122,16 +124,18 @@ of ``FF`` and dots): .. code-block:: pytest $ pytest --ff - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 50 items run-last-failure: rerun previous 2 failures first - test_50.py FF................................................ [100%] + test_50.py FF................................................ [100%] - ================================= FAILURES ================================= - _______________________________ test_num[17] _______________________________ + ====================================== FAILURES ====================================== + ____________________________________ test_num[17] ____________________________________ i = 17 @@ -142,7 +146,7 @@ of ``FF`` and dots): E Failed: bad luck test_50.py:6: Failed - _______________________________ test_num[25] _______________________________ + ____________________________________ test_num[25] ____________________________________ i = 25 @@ -153,7 +157,7 @@ of ``FF`` and dots): E Failed: bad luck test_50.py:6: Failed - =================== 2 failed, 48 passed in 0.12 seconds ==================== + ======================== 2 failed, 48 passed in 0.12 seconds ========================= .. _`config.cache`: @@ -205,9 +209,9 @@ If you run this command for the first time, you can see the print statement: .. code-block:: pytest $ pytest -q - F [100%] - ================================= FAILURES ================================= - ______________________________ test_function _______________________________ + F [100%] + ====================================== FAILURES ====================================== + ___________________________________ test_function ____________________________________ mydata = 42 @@ -216,7 +220,7 @@ If you run this command for the first time, you can see the print statement: E assert 42 == 23 test_caching.py:17: AssertionError - -------------------------- Captured stdout setup --------------------------- + ------------------------------- Captured stdout setup -------------------------------- running expensive computation... 1 failed in 0.12 seconds @@ -226,9 +230,9 @@ the cache and nothing will be printed: .. code-block:: pytest $ pytest -q - F [100%] - ================================= FAILURES ================================= - ______________________________ test_function _______________________________ + F [100%] + ====================================== FAILURES ====================================== + ___________________________________ test_function ____________________________________ mydata = 42 @@ -251,11 +255,13 @@ You can always peek at the content of the cache using the .. code-block:: pytest $ pytest --cache-show - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y cachedir: $REGENDOC_TMPDIR/.pytest_cache - ------------------------------- cache values ------------------------------- + ------------------------------------ cache values ------------------------------------ cache/lastfailed contains: {'test_caching.py::test_function': True} cache/nodeids contains: @@ -265,7 +271,7 @@ You can always peek at the content of the cache using the example/value contains: 42 - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ Clearing Cache content ------------------------------- diff --git a/doc/en/capture.rst b/doc/en/capture.rst index 488b2b874..15ad75910 100644 --- a/doc/en/capture.rst +++ b/doc/en/capture.rst @@ -66,24 +66,26 @@ of the failing function and hide the other one: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py .F [100%] + test_module.py .F [100%] - ================================= FAILURES ================================= - ________________________________ test_func2 ________________________________ + ====================================== FAILURES ====================================== + _____________________________________ test_func2 _____________________________________ def test_func2(): > assert False E assert False test_module.py:9: AssertionError - -------------------------- Captured stdout setup --------------------------- + ------------------------------- Captured stdout setup -------------------------------- setting up - ==================== 1 failed, 1 passed in 0.12 seconds ==================== + ========================= 1 failed, 1 passed in 0.12 seconds ========================= Accessing captured output from a test function --------------------------------------------------- diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 125ed3aa7..c861ede8a 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -63,14 +63,16 @@ then you can just invoke ``pytest`` without command line options: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + plugins: hypothesis-3.x.y collected 1 item - mymodule.py . [100%] + mymodule.py . [100%] - ========================= 1 passed in 0.12 seconds ========================= + ============================== 1 passed in 0.12 seconds ============================== It is possible to use fixtures using the ``getfixture`` helper:: diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 9d325c30e..b27a4fcb2 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -32,32 +32,36 @@ You can then restrict a test run to only run tests marked with ``webtest``: .. code-block:: pytest $ pytest -v -m webtest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected - test_server.py::test_send_http PASSED [100%] + test_server.py::test_send_http PASSED [100%] - ================== 1 passed, 3 deselected in 0.12 seconds ================== + ======================= 1 passed, 3 deselected in 0.12 seconds ======================= Or the inverse, running all tests except the webtest ones: .. code-block:: pytest $ pytest -v -m "not webtest" - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected - test_server.py::test_something_quick PASSED [ 33%] - test_server.py::test_another PASSED [ 66%] - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::test_something_quick PASSED [ 33%] + test_server.py::test_another PASSED [ 66%] + test_server.py::TestClass::test_method PASSED [100%] - ================== 3 passed, 1 deselected in 0.12 seconds ================== + ======================= 3 passed, 1 deselected in 0.12 seconds ======================= Selecting tests based on their node ID -------------------------------------- @@ -69,46 +73,52 @@ tests based on their module, class, method, or function name: .. code-block:: pytest $ pytest -v test_server.py::TestClass::test_method - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 1 item - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::TestClass::test_method PASSED [100%] - ========================= 1 passed in 0.12 seconds ========================= + ============================== 1 passed in 0.12 seconds ============================== You can also select on the class: .. code-block:: pytest $ pytest -v test_server.py::TestClass - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 1 item - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::TestClass::test_method PASSED [100%] - ========================= 1 passed in 0.12 seconds ========================= + ============================== 1 passed in 0.12 seconds ============================== Or select multiple nodes: .. code-block:: pytest $ pytest -v test_server.py::TestClass test_server.py::test_send_http - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 2 items - test_server.py::TestClass::test_method PASSED [ 50%] - test_server.py::test_send_http PASSED [100%] + test_server.py::TestClass::test_method PASSED [ 50%] + test_server.py::test_send_http PASSED [100%] - ========================= 2 passed in 0.12 seconds ========================= + ============================== 2 passed in 0.12 seconds ============================== .. _node-id: @@ -139,48 +149,54 @@ select tests based on their names: .. code-block:: pytest $ pytest -v -k http # running with the above defined example module - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected - test_server.py::test_send_http PASSED [100%] + test_server.py::test_send_http PASSED [100%] - ================== 1 passed, 3 deselected in 0.12 seconds ================== + ======================= 1 passed, 3 deselected in 0.12 seconds ======================= And you can also run all tests except the ones that match the keyword: .. code-block:: pytest $ pytest -k "not send_http" -v - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected - test_server.py::test_something_quick PASSED [ 33%] - test_server.py::test_another PASSED [ 66%] - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::test_something_quick PASSED [ 33%] + test_server.py::test_another PASSED [ 66%] + test_server.py::TestClass::test_method PASSED [100%] - ================== 3 passed, 1 deselected in 0.12 seconds ================== + ======================= 3 passed, 1 deselected in 0.12 seconds ======================= Or to select "http" and "quick" tests: .. code-block:: pytest $ pytest -k "http or quick" -v - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 4 items / 2 deselected - test_server.py::test_send_http PASSED [ 50%] - test_server.py::test_something_quick PASSED [100%] + test_server.py::test_send_http PASSED [ 50%] + test_server.py::test_something_quick PASSED [100%] - ================== 2 passed, 2 deselected in 0.12 seconds ================== + ======================= 2 passed, 2 deselected in 0.12 seconds ======================= .. note:: @@ -216,6 +232,8 @@ You can ask which markers exist for your test suite - the list includes our just $ pytest --markers @pytest.mark.webtest: mark a test as a webtest. + @pytest.mark.hypothesis: Tests which use hypothesis. + @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test. @@ -363,34 +381,40 @@ the test needs: .. code-block:: pytest $ pytest -E stage2 - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_someenv.py s [100%] + test_someenv.py s [100%] - ======================== 1 skipped in 0.12 seconds ========================= + ============================= 1 skipped in 0.12 seconds ============================== and here is one that specifies exactly the environment needed: .. code-block:: pytest $ pytest -E stage1 - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_someenv.py . [100%] + test_someenv.py . [100%] - ========================= 1 passed in 0.12 seconds ========================= + ============================== 1 passed in 0.12 seconds ============================== The ``--markers`` option always gives you a list of available markers:: $ pytest --markers @pytest.mark.env(name): mark test to run only on named environment + @pytest.mark.hypothesis: Tests which use hypothesis. + @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test. @@ -544,30 +568,34 @@ then you will see two tests skipped and two executed tests as expected: .. code-block:: pytest $ pytest -rs # this option reports skip reasons - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items - test_plat.py s.s. [100%] - ========================= short test summary info ========================== + test_plat.py s.s. [100%] + ============================== short test summary info =============================== SKIP [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux - =================== 2 passed, 2 skipped in 0.12 seconds ==================== + ======================== 2 passed, 2 skipped in 0.12 seconds ========================= Note that if you specify a platform via the marker-command line option like this: .. code-block:: pytest $ pytest -m linux - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items / 3 deselected - test_plat.py . [100%] + test_plat.py . [100%] - ================== 1 passed, 3 deselected in 0.12 seconds ================== + ======================= 1 passed, 3 deselected in 0.12 seconds ======================= then the unmarked-tests will not be run. It is thus a way to restrict the run to the specific tests. @@ -613,47 +641,51 @@ We can now use the ``-m option`` to select one set: .. code-block:: pytest $ pytest -m interface --tb=short - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items / 2 deselected - test_module.py FF [100%] + test_module.py FF [100%] - ================================= FAILURES ================================= - __________________________ test_interface_simple ___________________________ + ====================================== FAILURES ====================================== + _______________________________ test_interface_simple ________________________________ test_module.py:3: in test_interface_simple assert 0 E assert 0 - __________________________ test_interface_complex __________________________ + _______________________________ test_interface_complex _______________________________ test_module.py:6: in test_interface_complex assert 0 E assert 0 - ================== 2 failed, 2 deselected in 0.12 seconds ================== + ======================= 2 failed, 2 deselected in 0.12 seconds ======================= or to select both "event" and "interface" tests: .. code-block:: pytest $ pytest -m "interface or event" --tb=short - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items / 1 deselected - test_module.py FFF [100%] + test_module.py FFF [100%] - ================================= FAILURES ================================= - __________________________ test_interface_simple ___________________________ + ====================================== FAILURES ====================================== + _______________________________ test_interface_simple ________________________________ test_module.py:3: in test_interface_simple assert 0 E assert 0 - __________________________ test_interface_complex __________________________ + _______________________________ test_interface_complex _______________________________ test_module.py:6: in test_interface_complex assert 0 E assert 0 - ____________________________ test_event_simple _____________________________ + _________________________________ test_event_simple __________________________________ test_module.py:9: in test_event_simple assert 0 E assert 0 - ================== 3 failed, 1 deselected in 0.12 seconds ================== + ======================= 3 failed, 1 deselected in 0.12 seconds ======================= diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index eba8279f3..1581b8672 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -28,19 +28,21 @@ now execute the test specification: .. code-block:: pytest nonpython $ pytest test_simple.yml - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_simple.yml F. [100%] + test_simple.yml F. [100%] - ================================= FAILURES ================================= - ______________________________ usecase: hello ______________________________ + ====================================== FAILURES ====================================== + ___________________________________ usecase: hello ___________________________________ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ==================== 1 failed, 1 passed in 0.12 seconds ==================== + ========================= 1 failed, 1 passed in 0.12 seconds ========================= .. regendoc:wipe @@ -62,21 +64,23 @@ consulted when reporting in ``verbose`` mode: .. code-block:: pytest nonpython $ pytest -v - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + plugins: hypothesis-3.x.y collecting ... collected 2 items - test_simple.yml::hello FAILED [ 50%] - test_simple.yml::ok PASSED [100%] + test_simple.yml::hello FAILED [ 50%] + test_simple.yml::ok PASSED [100%] - ================================= FAILURES ================================= - ______________________________ usecase: hello ______________________________ + ====================================== FAILURES ====================================== + ___________________________________ usecase: hello ___________________________________ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ==================== 1 failed, 1 passed in 0.12 seconds ==================== + ========================= 1 failed, 1 passed in 0.12 seconds ========================= .. regendoc:wipe @@ -86,13 +90,15 @@ interesting to just look at the collection tree: .. code-block:: pytest nonpython $ pytest --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: + plugins: hypothesis-3.x.y collected 2 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 92756e492..76cb68867 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -47,7 +47,7 @@ This means that we only run 2 tests if we do not pass ``--all``: .. code-block:: pytest $ pytest -q test_compute.py - .. [100%] + .. [100%] 2 passed in 0.12 seconds We run only two computations, so we see two dots. @@ -56,9 +56,9 @@ let's run the full monty: .. code-block:: pytest $ pytest -q --all - ....F [100%] - ================================= FAILURES ================================= - _____________________________ test_compute[4] ______________________________ + ....F [100%] + ====================================== FAILURES ====================================== + __________________________________ test_compute[4] ___________________________________ param1 = 4 @@ -143,9 +143,11 @@ objects, they are still using the default pytest representation: .. code-block:: pytest $ pytest test_time.py --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 8 items @@ -157,7 +159,7 @@ objects, they are still using the default pytest representation: - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ In ``test_timedistance_v3``, we used ``pytest.param`` to specify the test IDs together with the actual data, instead of listing them separately. @@ -201,23 +203,27 @@ this is a fully self-contained example which you can run with: .. code-block:: pytest $ pytest test_scenarios.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items - test_scenarios.py .... [100%] + test_scenarios.py .... [100%] - ========================= 4 passed in 0.12 seconds ========================= + ============================== 4 passed in 0.12 seconds ============================== If you just collect tests you'll also nicely see 'advanced' and 'basic' as variants for the test function: .. code-block:: pytest $ pytest --collect-only test_scenarios.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items @@ -226,7 +232,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ Note that we told ``metafunc.parametrize()`` that your scenario values should be considered class-scoped. With pytest-2.3 this leads to a @@ -281,24 +287,26 @@ Let's first see how it looks like at collection time: .. code-block:: pytest $ pytest test_backends.py --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ And then when we run the test: .. code-block:: pytest $ pytest -q test_backends.py - .F [100%] - ================================= FAILURES ================================= - _________________________ test_db_initialized[d2] __________________________ + .F [100%] + ====================================== FAILURES ====================================== + ______________________________ test_db_initialized[d2] _______________________________ db = @@ -346,14 +354,16 @@ The result of this test will be successful: .. code-block:: pytest $ pytest test_indirect_list.py --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. regendoc:wipe @@ -397,9 +407,9 @@ argument sets to use for each test function. Let's run it: .. code-block:: pytest $ pytest -q - F.. [100%] - ================================= FAILURES ================================= - ________________________ TestClass.test_equals[1-2] ________________________ + F.. [100%] + ====================================== FAILURES ====================================== + _____________________________ TestClass.test_equals[1-2] _____________________________ self = , a = 1, b = 2 @@ -429,8 +439,8 @@ Running it results in some skips if we don't have all the python interpreters in .. code-block:: pytest . $ pytest -rs -q multipython.py - ...sss...sssssssss...sss... [100%] - ========================= short test summary info ========================== + ...sss...sssssssss...sss... [100%] + ============================== short test summary info =============================== SKIP [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.4' not found 12 passed, 15 skipped in 0.12 seconds @@ -480,16 +490,18 @@ If you run this with reporting for skips enabled: .. code-block:: pytest $ pytest -rs test_module.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py .s [100%] - ========================= short test summary info ========================== + test_module.py .s [100%] + ============================== short test summary info =============================== SKIP [1] $REGENDOC_TMPDIR/conftest.py:11: could not import 'opt2' - =================== 1 passed, 1 skipped in 0.12 seconds ==================== + ======================== 1 passed, 1 skipped in 0.12 seconds ========================= You'll see that we don't have an ``opt2`` module and thus the second test run of our ``test_func1`` was skipped. A few notes: @@ -537,17 +549,19 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: .. code-block:: pytest $ pytest -v -m basic - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 17 items / 14 deselected - test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] - test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%] - test_pytest_param_example.py::test_eval[basic_6*9] xfail [100%] + test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] + test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%] + test_pytest_param_example.py::test_eval[basic_6*9] xfail [100%] - ============ 2 passed, 14 deselected, 1 xfailed in 0.12 seconds ============ + ================= 2 passed, 14 deselected, 1 xfailed in 0.12 seconds ================= As the result: diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 394924e2d..bc7e0c0d2 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -130,16 +130,18 @@ The test collection would look like this: .. code-block:: pytest $ pytest --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + plugins: hypothesis-3.x.y collected 2 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ You can check for multiple glob patterns by adding a space between the patterns:: @@ -185,9 +187,11 @@ You can always peek at the collection tree without running tests like this: .. code-block:: pytest . $ pytest --collect-only pythoncollection.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/CWD/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + plugins: hypothesis-3.x.y collected 3 items @@ -195,7 +199,7 @@ You can always peek at the collection tree without running tests like this: - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. _customizing-test-collection: @@ -257,9 +261,11 @@ file will be left out: .. code-block:: pytest $ pytest --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index 2f8c25f02..d99a06725 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -12,15 +12,17 @@ get on the terminal - we are working on that): .. code-block:: pytest assertion $ pytest failure_demo.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/assertion/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/assertion, inifile: + plugins: hypothesis-3.x.y collected 44 items - failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] + failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] - ================================= FAILURES ================================= - ___________________________ test_generative[3-6] ___________________________ + ====================================== FAILURES ====================================== + ________________________________ test_generative[3-6] ________________________________ param1 = 3, param2 = 6 @@ -30,7 +32,7 @@ get on the terminal - we are working on that): E assert (3 * 2) < 6 failure_demo.py:22: AssertionError - _________________________ TestFailing.test_simple __________________________ + ______________________________ TestFailing.test_simple _______________________________ self = @@ -47,7 +49,7 @@ get on the terminal - we are working on that): E + and 43 = .g at 0xdeadbeef>() failure_demo.py:33: AssertionError - ____________________ TestFailing.test_simple_multiline _____________________ + _________________________ TestFailing.test_simple_multiline __________________________ self = @@ -55,7 +57,7 @@ get on the terminal - we are working on that): > otherfunc_multi(42, 6 * 9) failure_demo.py:36: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 42, b = 54 @@ -64,7 +66,7 @@ get on the terminal - we are working on that): E assert 42 == 54 failure_demo.py:17: AssertionError - ___________________________ TestFailing.test_not ___________________________ + ________________________________ TestFailing.test_not ________________________________ self = @@ -77,7 +79,7 @@ get on the terminal - we are working on that): E + where 42 = .f at 0xdeadbeef>() failure_demo.py:42: AssertionError - _________________ TestSpecialisedExplanations.test_eq_text _________________ + ______________________ TestSpecialisedExplanations.test_eq_text ______________________ self = @@ -88,7 +90,7 @@ get on the terminal - we are working on that): E + eggs failure_demo.py:47: AssertionError - _____________ TestSpecialisedExplanations.test_eq_similar_text _____________ + __________________ TestSpecialisedExplanations.test_eq_similar_text __________________ self = @@ -101,7 +103,7 @@ get on the terminal - we are working on that): E ? ^ failure_demo.py:50: AssertionError - ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________ + _________________ TestSpecialisedExplanations.test_eq_multiline_text _________________ self = @@ -114,7 +116,7 @@ get on the terminal - we are working on that): E bar failure_demo.py:53: AssertionError - ______________ TestSpecialisedExplanations.test_eq_long_text _______________ + ___________________ TestSpecialisedExplanations.test_eq_long_text ____________________ self = @@ -131,7 +133,7 @@ get on the terminal - we are working on that): E ? ^ failure_demo.py:58: AssertionError - _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________ + ______________ TestSpecialisedExplanations.test_eq_long_text_multiline _______________ self = @@ -151,7 +153,7 @@ get on the terminal - we are working on that): E ...Full output truncated (7 lines hidden), use '-vv' to show failure_demo.py:63: AssertionError - _________________ TestSpecialisedExplanations.test_eq_list _________________ + ______________________ TestSpecialisedExplanations.test_eq_list ______________________ self = @@ -162,7 +164,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:66: AssertionError - ______________ TestSpecialisedExplanations.test_eq_list_long _______________ + ___________________ TestSpecialisedExplanations.test_eq_list_long ____________________ self = @@ -175,7 +177,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:71: AssertionError - _________________ TestSpecialisedExplanations.test_eq_dict _________________ + ______________________ TestSpecialisedExplanations.test_eq_dict ______________________ self = @@ -193,7 +195,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:74: AssertionError - _________________ TestSpecialisedExplanations.test_eq_set __________________ + ______________________ TestSpecialisedExplanations.test_eq_set _______________________ self = @@ -211,7 +213,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:77: AssertionError - _____________ TestSpecialisedExplanations.test_eq_longer_list ______________ + __________________ TestSpecialisedExplanations.test_eq_longer_list ___________________ self = @@ -222,7 +224,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:80: AssertionError - _________________ TestSpecialisedExplanations.test_in_list _________________ + ______________________ TestSpecialisedExplanations.test_in_list ______________________ self = @@ -231,7 +233,7 @@ get on the terminal - we are working on that): E assert 1 in [0, 2, 3, 4, 5] failure_demo.py:83: AssertionError - __________ TestSpecialisedExplanations.test_not_in_text_multiline __________ + _______________ TestSpecialisedExplanations.test_not_in_text_multiline _______________ self = @@ -250,7 +252,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:87: AssertionError - ___________ TestSpecialisedExplanations.test_not_in_text_single ____________ + ________________ TestSpecialisedExplanations.test_not_in_text_single _________________ self = @@ -263,7 +265,7 @@ get on the terminal - we are working on that): E ? +++ failure_demo.py:91: AssertionError - _________ TestSpecialisedExplanations.test_not_in_text_single_long _________ + ______________ TestSpecialisedExplanations.test_not_in_text_single_long ______________ self = @@ -276,7 +278,7 @@ get on the terminal - we are working on that): E ? +++ failure_demo.py:95: AssertionError - ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______ + ___________ TestSpecialisedExplanations.test_not_in_text_single_long_term ____________ self = @@ -289,16 +291,28 @@ get on the terminal - we are working on that): E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ failure_demo.py:99: AssertionError - ______________ TestSpecialisedExplanations.test_eq_dataclass _______________ + ___________________ TestSpecialisedExplanations.test_eq_dataclass ____________________ self = def test_eq_dataclass(self): - > from dataclasses import dataclass - E ModuleNotFoundError: No module named 'dataclasses' + from dataclasses import dataclass - failure_demo.py:102: ModuleNotFoundError - ________________ TestSpecialisedExplanations.test_eq_attrs _________________ + @dataclass + class Foo(object): + a: int + b: str + + left = Foo(1, "b") + right = Foo(1, "c") + > assert left == right + E AssertionError: assert TestSpecialis...oo(a=1, b='b') == TestSpecialise...oo(a=1, b='c') + E Omitting 1 identical items, use -vv to show + E Differing attributes: + E b: 'b' != 'c' + + failure_demo.py:111: AssertionError + _____________________ TestSpecialisedExplanations.test_eq_attrs ______________________ self = @@ -319,7 +333,7 @@ get on the terminal - we are working on that): E b: 'b' != 'c' failure_demo.py:123: AssertionError - ______________________________ test_attribute ______________________________ + ___________________________________ test_attribute ___________________________________ def test_attribute(): class Foo(object): @@ -331,7 +345,7 @@ get on the terminal - we are working on that): E + where 1 = .Foo object at 0xdeadbeef>.b failure_demo.py:131: AssertionError - _________________________ test_attribute_instance __________________________ + ______________________________ test_attribute_instance _______________________________ def test_attribute_instance(): class Foo(object): @@ -343,7 +357,7 @@ get on the terminal - we are working on that): E + where .Foo object at 0xdeadbeef> = .Foo'>() failure_demo.py:138: AssertionError - __________________________ test_attribute_failure __________________________ + _______________________________ test_attribute_failure _______________________________ def test_attribute_failure(): class Foo(object): @@ -356,7 +370,7 @@ get on the terminal - we are working on that): > assert i.b == 2 failure_demo.py:149: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = .Foo object at 0xdeadbeef> @@ -365,7 +379,7 @@ get on the terminal - we are working on that): E Exception: Failed to get attrib failure_demo.py:144: Exception - _________________________ test_attribute_multiple __________________________ + ______________________________ test_attribute_multiple _______________________________ def test_attribute_multiple(): class Foo(object): @@ -382,7 +396,7 @@ get on the terminal - we are working on that): E + where .Bar object at 0xdeadbeef> = .Bar'>() failure_demo.py:159: AssertionError - __________________________ TestRaises.test_raises __________________________ + _______________________________ TestRaises.test_raises _______________________________ self = @@ -392,7 +406,7 @@ get on the terminal - we are working on that): E ValueError: invalid literal for int() with base 10: 'qwe' failure_demo.py:169: ValueError - ______________________ TestRaises.test_raises_doesnt _______________________ + ___________________________ TestRaises.test_raises_doesnt ____________________________ self = @@ -401,7 +415,7 @@ get on the terminal - we are working on that): E Failed: DID NOT RAISE failure_demo.py:172: Failed - __________________________ TestRaises.test_raise ___________________________ + _______________________________ TestRaises.test_raise ________________________________ self = @@ -410,7 +424,7 @@ get on the terminal - we are working on that): E ValueError: demo error failure_demo.py:175: ValueError - ________________________ TestRaises.test_tupleerror ________________________ + _____________________________ TestRaises.test_tupleerror _____________________________ self = @@ -419,7 +433,7 @@ get on the terminal - we are working on that): E ValueError: not enough values to unpack (expected 2, got 1) failure_demo.py:178: ValueError - ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ + ___________ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ___________ self = @@ -430,9 +444,9 @@ get on the terminal - we are working on that): E TypeError: 'int' object is not iterable failure_demo.py:183: TypeError - --------------------------- Captured stdout call --------------------------- + -------------------------------- Captured stdout call -------------------------------- items is [1, 2, 3] - ________________________ TestRaises.test_some_error ________________________ + _____________________________ TestRaises.test_some_error _____________________________ self = @@ -441,7 +455,7 @@ get on the terminal - we are working on that): E NameError: name 'namenotexi' is not defined failure_demo.py:186: NameError - ____________________ test_dynamic_compile_shows_nicely _____________________ + _________________________ test_dynamic_compile_shows_nicely __________________________ def test_dynamic_compile_shows_nicely(): import imp @@ -456,14 +470,14 @@ get on the terminal - we are working on that): > module.foo() failure_demo.py:204: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def foo(): > assert 1 == 0 E AssertionError <0-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:201>:2: AssertionError - ____________________ TestMoreErrors.test_complex_error _____________________ + _________________________ TestMoreErrors.test_complex_error __________________________ self = @@ -477,10 +491,10 @@ get on the terminal - we are working on that): > somefunc(f(), g()) failure_demo.py:215: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ failure_demo.py:13: in somefunc otherfunc(x, y) - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 44, b = 43 @@ -489,7 +503,7 @@ get on the terminal - we are working on that): E assert 44 == 43 failure_demo.py:9: AssertionError - ___________________ TestMoreErrors.test_z1_unpack_error ____________________ + ________________________ TestMoreErrors.test_z1_unpack_error _________________________ self = @@ -499,7 +513,7 @@ get on the terminal - we are working on that): E ValueError: not enough values to unpack (expected 2, got 0) failure_demo.py:219: ValueError - ____________________ TestMoreErrors.test_z2_type_error _____________________ + _________________________ TestMoreErrors.test_z2_type_error __________________________ self = @@ -509,7 +523,7 @@ get on the terminal - we are working on that): E TypeError: 'int' object is not iterable failure_demo.py:223: TypeError - ______________________ TestMoreErrors.test_startswith ______________________ + ___________________________ TestMoreErrors.test_startswith ___________________________ self = @@ -522,7 +536,7 @@ get on the terminal - we are working on that): E + where = '123'.startswith failure_demo.py:228: AssertionError - __________________ TestMoreErrors.test_startswith_nested ___________________ + _______________________ TestMoreErrors.test_startswith_nested ________________________ self = @@ -541,7 +555,7 @@ get on the terminal - we are working on that): E + and '456' = .g at 0xdeadbeef>() failure_demo.py:237: AssertionError - _____________________ TestMoreErrors.test_global_func ______________________ + __________________________ TestMoreErrors.test_global_func ___________________________ self = @@ -552,7 +566,7 @@ get on the terminal - we are working on that): E + where 43 = globf(42) failure_demo.py:240: AssertionError - _______________________ TestMoreErrors.test_instance _______________________ + ____________________________ TestMoreErrors.test_instance ____________________________ self = @@ -563,7 +577,7 @@ get on the terminal - we are working on that): E + where 42 = .x failure_demo.py:244: AssertionError - _______________________ TestMoreErrors.test_compare ________________________ + ____________________________ TestMoreErrors.test_compare _____________________________ self = @@ -573,7 +587,7 @@ get on the terminal - we are working on that): E + where 11 = globf(10) failure_demo.py:247: AssertionError - _____________________ TestMoreErrors.test_try_finally ______________________ + __________________________ TestMoreErrors.test_try_finally ___________________________ self = @@ -584,7 +598,7 @@ get on the terminal - we are working on that): E assert 1 == 0 failure_demo.py:252: AssertionError - ___________________ TestCustomAssertMsg.test_single_line ___________________ + ________________________ TestCustomAssertMsg.test_single_line ________________________ self = @@ -599,7 +613,7 @@ get on the terminal - we are working on that): E + where 1 = .A'>.a failure_demo.py:263: AssertionError - ____________________ TestCustomAssertMsg.test_multiline ____________________ + _________________________ TestCustomAssertMsg.test_multiline _________________________ self = @@ -618,7 +632,7 @@ get on the terminal - we are working on that): E + where 1 = .A'>.a failure_demo.py:270: AssertionError - ___________________ TestCustomAssertMsg.test_custom_repr ___________________ + ________________________ TestCustomAssertMsg.test_custom_repr ________________________ self = @@ -640,4 +654,4 @@ get on the terminal - we are working on that): E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a failure_demo.py:283: AssertionError - ======================== 44 failed in 0.12 seconds ========================= + ============================= 44 failed in 0.12 seconds ============================== diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 76a1ddc80..26d5d6c4b 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -48,9 +48,9 @@ Let's run this without supplying our new option: .. code-block:: pytest $ pytest -q test_sample.py - F [100%] - ================================= FAILURES ================================= - _______________________________ test_answer ________________________________ + F [100%] + ====================================== FAILURES ====================================== + ____________________________________ test_answer _____________________________________ cmdopt = 'type1' @@ -63,7 +63,7 @@ Let's run this without supplying our new option: E assert 0 test_sample.py:6: AssertionError - --------------------------- Captured stdout call --------------------------- + -------------------------------- Captured stdout call -------------------------------- first 1 failed in 0.12 seconds @@ -72,9 +72,9 @@ And now with supplying a command line option: .. code-block:: pytest $ pytest -q --cmdopt=type2 - F [100%] - ================================= FAILURES ================================= - _______________________________ test_answer ________________________________ + F [100%] + ====================================== FAILURES ====================================== + ____________________________________ test_answer _____________________________________ cmdopt = 'type2' @@ -87,7 +87,7 @@ And now with supplying a command line option: E assert 0 test_sample.py:6: AssertionError - --------------------------- Captured stdout call --------------------------- + -------------------------------- Captured stdout call -------------------------------- second 1 failed in 0.12 seconds @@ -126,12 +126,14 @@ directory with the above conftest.py: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. _`excontrolskip`: @@ -186,30 +188,34 @@ and when running it will see a skipped "slow" test: .. code-block:: pytest $ pytest -rs # "-rs" means report details on the little 's' - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py .s [100%] - ========================= short test summary info ========================== + test_module.py .s [100%] + ============================== short test summary info =============================== SKIP [1] test_module.py:8: need --runslow option to run - =================== 1 passed, 1 skipped in 0.12 seconds ==================== + ======================== 1 passed, 1 skipped in 0.12 seconds ========================= Or run it including the ``slow`` marked test: .. code-block:: pytest $ pytest --runslow - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py .. [100%] + test_module.py .. [100%] - ========================= 2 passed in 0.12 seconds ========================= + ============================== 2 passed in 0.12 seconds ============================== Writing well integrated assertion helpers -------------------------------------------------- @@ -245,9 +251,9 @@ Let's run our little function: .. code-block:: pytest $ pytest -q test_checkconfig.py - F [100%] - ================================= FAILURES ================================= - ______________________________ test_something ______________________________ + F [100%] + ====================================== FAILURES ====================================== + ___________________________________ test_something ___________________________________ def test_something(): > checkconfig(42) @@ -344,13 +350,15 @@ which will add the string to the test header accordingly: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') project deps: mylib-1.1 rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. regendoc:wipe @@ -372,27 +380,31 @@ which will add info only when run with "--v": .. code-block:: pytest $ pytest -v - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') info1: did you know that ... did you? rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ and nothing when run plainly: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ profiling test duration -------------------------- @@ -426,18 +438,20 @@ Now we can profile which test functions execute the slowest: .. code-block:: pytest $ pytest --durations=3 - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 3 items - test_some_are_slow.py ... [100%] + test_some_are_slow.py ... [100%] - ========================= slowest 3 test durations ========================= + ============================== slowest 3 test durations ============================== 0.30s call test_some_are_slow.py::test_funcslow2 0.20s call test_some_are_slow.py::test_funcslow1 0.10s call test_some_are_slow.py::test_funcfast - ========================= 3 passed in 0.12 seconds ========================= + ============================== 3 passed in 0.12 seconds ============================== incremental testing - test steps --------------------------------------------------- @@ -500,15 +514,17 @@ If we run this: .. code-block:: pytest $ pytest -rx - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 4 items - test_step.py .Fx. [100%] + test_step.py .Fx. [100%] - ================================= FAILURES ================================= - ____________________ TestUserHandling.test_modification ____________________ + ====================================== FAILURES ====================================== + _________________________ TestUserHandling.test_modification _________________________ self = @@ -517,10 +533,10 @@ If we run this: E assert 0 test_step.py:11: AssertionError - ========================= short test summary info ========================== + ============================== short test summary info =============================== XFAIL test_step.py::TestUserHandling::test_deletion reason: previous test failed (test_modification) - ============== 1 failed, 2 passed, 1 xfailed in 0.12 seconds =============== + =================== 1 failed, 2 passed, 1 xfailed in 0.12 seconds ==================== We'll see that ``test_deletion`` was not executed because ``test_modification`` failed. It is reported as an "expected failure". @@ -583,18 +599,20 @@ We can run this: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 7 items - test_step.py .Fx. [ 57%] - a/test_db.py F [ 71%] - a/test_db2.py F [ 85%] - b/test_error.py E [100%] + test_step.py .Fx. [ 57%] + a/test_db.py F [ 71%] + a/test_db2.py F [ 85%] + b/test_error.py E [100%] - ================================== ERRORS ================================== - _______________________ ERROR at setup of test_root ________________________ + ======================================= ERRORS ======================================= + ____________________________ ERROR at setup of test_root _____________________________ file $REGENDOC_TMPDIR/b/test_error.py, line 1 def test_root(db): # no db here, will error out E fixture 'db' not found @@ -602,8 +620,8 @@ We can run this: > use 'pytest --fixtures [testpath]' for help on them. $REGENDOC_TMPDIR/b/test_error.py:1 - ================================= FAILURES ================================= - ____________________ TestUserHandling.test_modification ____________________ + ====================================== FAILURES ====================================== + _________________________ TestUserHandling.test_modification _________________________ self = @@ -612,7 +630,7 @@ We can run this: E assert 0 test_step.py:11: AssertionError - _________________________________ test_a1 __________________________________ + ______________________________________ test_a1 _______________________________________ db = @@ -622,7 +640,7 @@ We can run this: E assert 0 a/test_db.py:2: AssertionError - _________________________________ test_a2 __________________________________ + ______________________________________ test_a2 _______________________________________ db = @@ -632,7 +650,7 @@ We can run this: E assert 0 a/test_db2.py:2: AssertionError - ========== 3 failed, 2 passed, 1 xfailed, 1 error in 0.12 seconds ========== + =============== 3 failed, 2 passed, 1 xfailed, 1 error in 0.12 seconds =============== The two test modules in the ``a`` directory see the same ``db`` fixture instance while the one test in the sister-directory ``b`` doesn't see it. We could of course @@ -696,15 +714,17 @@ and run them: .. code-block:: pytest $ pytest test_module.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py FF [100%] + test_module.py FF [100%] - ================================= FAILURES ================================= - ________________________________ test_fail1 ________________________________ + ====================================== FAILURES ====================================== + _____________________________________ test_fail1 _____________________________________ tmpdir = local('PYTEST_TMPDIR/test_fail10') @@ -713,14 +733,14 @@ and run them: E assert 0 test_module.py:2: AssertionError - ________________________________ test_fail2 ________________________________ + _____________________________________ test_fail2 _____________________________________ def test_fail2(): > assert 0 E assert 0 test_module.py:6: AssertionError - ========================= 2 failed in 0.12 seconds ========================= + ============================== 2 failed in 0.12 seconds ============================== you will have a "failures" file which contains the failing test ids:: @@ -797,17 +817,19 @@ and run it: .. code-block:: pytest $ pytest -s test_module.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 3 items test_module.py Esetting up a test failed! test_module.py::test_setup_fails Fexecuting test failed test_module.py::test_call_fails F - ================================== ERRORS ================================== - ____________________ ERROR at setup of test_setup_fails ____________________ + ======================================= ERRORS ======================================= + _________________________ ERROR at setup of test_setup_fails _________________________ @pytest.fixture def other(): @@ -815,8 +837,8 @@ and run it: E assert 0 test_module.py:7: AssertionError - ================================= FAILURES ================================= - _____________________________ test_call_fails ______________________________ + ====================================== FAILURES ====================================== + __________________________________ test_call_fails ___________________________________ something = None @@ -825,14 +847,14 @@ and run it: E assert 0 test_module.py:15: AssertionError - ________________________________ test_fail2 ________________________________ + _____________________________________ test_fail2 _____________________________________ def test_fail2(): > assert 0 E assert 0 test_module.py:19: AssertionError - ==================== 2 failed, 1 error in 0.12 seconds ===================== + ========================= 2 failed, 1 error in 0.12 seconds ========================== You'll see that the fixture finalizers could use the precise reporting information. diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 4dd68f8e4..6aed3ca08 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -71,15 +71,17 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: .. code-block:: pytest $ pytest test_smtpsimple.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_smtpsimple.py F [100%] + test_smtpsimple.py F [100%] - ================================= FAILURES ================================= - ________________________________ test_ehlo _________________________________ + ====================================== FAILURES ====================================== + _____________________________________ test_ehlo ______________________________________ smtp_connection = @@ -90,7 +92,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: E assert 0 test_smtpsimple.py:11: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== In the failure traceback we see that the test function was called with a ``smtp_connection`` argument, the ``smtplib.SMTP()`` instance created by the fixture @@ -211,15 +213,17 @@ inspect what is going on and can now run the tests: .. code-block:: pytest $ pytest test_module.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_module.py FF [100%] + test_module.py FF [100%] - ================================= FAILURES ================================= - ________________________________ test_ehlo _________________________________ + ====================================== FAILURES ====================================== + _____________________________________ test_ehlo ______________________________________ smtp_connection = @@ -231,7 +235,7 @@ inspect what is going on and can now run the tests: E assert 0 test_module.py:6: AssertionError - ________________________________ test_noop _________________________________ + _____________________________________ test_noop ______________________________________ smtp_connection = @@ -242,7 +246,7 @@ inspect what is going on and can now run the tests: E assert 0 test_module.py:11: AssertionError - ========================= 2 failed in 0.12 seconds ========================= + ============================== 2 failed in 0.12 seconds ============================== You see the two ``assert 0`` failing and more importantly you can also see that the same (module-scoped) ``smtp_connection`` object was passed into the @@ -491,14 +495,14 @@ Running it: .. code-block:: pytest $ pytest -qq --tb=short test_anothersmtp.py - F [100%] - ================================= FAILURES ================================= - ______________________________ test_showhelo _______________________________ + F [100%] + ====================================== FAILURES ====================================== + ___________________________________ test_showhelo ____________________________________ test_anothersmtp.py:5: in test_showhelo assert 0, smtp_connection.helo() E AssertionError: (250, b'mail.python.org') E assert 0 - ------------------------- Captured stdout teardown ------------------------- + ------------------------------ Captured stdout teardown ------------------------------ finalizing (mail.python.org) voila! The ``smtp_connection`` fixture function picked up our mail server name @@ -595,9 +599,9 @@ So let's just do another run: .. code-block:: pytest $ pytest -q test_module.py - FFFF [100%] - ================================= FAILURES ================================= - ________________________ test_ehlo[smtp.gmail.com] _________________________ + FFFF [100%] + ====================================== FAILURES ====================================== + _____________________________ test_ehlo[smtp.gmail.com] ______________________________ smtp_connection = @@ -609,7 +613,7 @@ So let's just do another run: E assert 0 test_module.py:6: AssertionError - ________________________ test_noop[smtp.gmail.com] _________________________ + _____________________________ test_noop[smtp.gmail.com] ______________________________ smtp_connection = @@ -620,7 +624,7 @@ So let's just do another run: E assert 0 test_module.py:11: AssertionError - ________________________ test_ehlo[mail.python.org] ________________________ + _____________________________ test_ehlo[mail.python.org] _____________________________ smtp_connection = @@ -631,9 +635,9 @@ So let's just do another run: E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8\nCHUNKING' test_module.py:5: AssertionError - -------------------------- Captured stdout setup --------------------------- + ------------------------------- Captured stdout setup -------------------------------- finalizing - ________________________ test_noop[mail.python.org] ________________________ + _____________________________ test_noop[mail.python.org] _____________________________ smtp_connection = @@ -644,7 +648,7 @@ So let's just do another run: E assert 0 test_module.py:11: AssertionError - ------------------------- Captured stdout teardown ------------------------- + ------------------------------ Captured stdout teardown ------------------------------ finalizing 4 failed in 0.12 seconds @@ -699,9 +703,11 @@ Running the above tests results in the following test IDs being used: .. code-block:: pytest $ pytest --collect-only - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 10 items @@ -717,7 +723,7 @@ Running the above tests results in the following test IDs being used: - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. _`fixture-parametrize-marks`: @@ -743,17 +749,19 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: .. code-block:: pytest $ pytest test_fixture_marks.py -v - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 3 items - test_fixture_marks.py::test_data[0] PASSED [ 33%] - test_fixture_marks.py::test_data[1] PASSED [ 66%] - test_fixture_marks.py::test_data[2] SKIPPED [100%] + test_fixture_marks.py::test_data[0] PASSED [ 33%] + test_fixture_marks.py::test_data[1] PASSED [ 66%] + test_fixture_marks.py::test_data[2] SKIPPED [100%] - =================== 2 passed, 1 skipped in 0.12 seconds ==================== + ======================== 2 passed, 1 skipped in 0.12 seconds ========================= .. _`interdependent fixtures`: @@ -788,16 +796,18 @@ Here we declare an ``app`` fixture which receives the previously defined .. code-block:: pytest $ pytest -v test_appsetup.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 2 items - test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] - test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%] + test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] + test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%] - ========================= 2 passed in 0.12 seconds ========================= + ============================== 2 passed in 0.12 seconds ============================== Due to the parametrization of ``smtp_connection``, the test will run twice with two different ``App`` instances and respective smtp servers. There is no @@ -859,10 +869,12 @@ Let's run the tests in verbose mode and with looking at the print-output: .. code-block:: pytest $ pytest -v -s test_module.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collecting ... collected 8 items test_module.py::test_0[1] SETUP otherarg 1 @@ -898,7 +910,7 @@ Let's run the tests in verbose mode and with looking at the print-output: TEARDOWN modarg mod2 - ========================= 8 passed in 0.12 seconds ========================= + ============================== 8 passed in 0.12 seconds ============================== You can see that the parametrized module-scoped ``modarg`` resource caused an ordering of test execution that lead to the fewest possible "active" resources. @@ -963,7 +975,7 @@ to verify our fixture is activated and the tests pass: .. code-block:: pytest $ pytest -q - .. [100%] + .. [100%] 2 passed in 0.12 seconds You can specify multiple fixtures like this: @@ -1064,7 +1076,7 @@ If we run it, we get two passing tests: .. code-block:: pytest $ pytest -q - .. [100%] + .. [100%] 2 passed in 0.12 seconds Here is how autouse fixtures work in other scopes: diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 500fc3d93..31910fa02 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -25,6 +25,8 @@ Install ``pytest`` $ pytest --version This is pytest version 4.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py + setuptools registered plugins: + hypothesis-3.x.y at $PYTHON_PREFIX/lib/python3.6/site-packages/hypothesis/extra/pytestplugin.py .. _`simpletest`: @@ -45,15 +47,17 @@ That’s it. You can now execute the test function: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_sample.py F [100%] + test_sample.py F [100%] - ================================= FAILURES ================================= - _______________________________ test_answer ________________________________ + ====================================== FAILURES ====================================== + ____________________________________ test_answer _____________________________________ def test_answer(): > assert func(3) == 5 @@ -61,7 +65,7 @@ That’s it. You can now execute the test function: E + where 4 = func(3) test_sample.py:5: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== This test returns a failure report because ``func(3)`` does not return ``5``. @@ -94,7 +98,7 @@ Execute the test function with “quiet” reporting mode: .. code-block:: pytest $ pytest -q test_sysexit.py - . [100%] + . [100%] 1 passed in 0.12 seconds Group multiple tests in a class @@ -117,9 +121,9 @@ Once you develop multiple tests, you may want to group them into a class. pytest .. code-block:: pytest $ pytest -q test_class.py - .F [100%] - ================================= FAILURES ================================= - ____________________________ TestClass.test_two ____________________________ + .F [100%] + ====================================== FAILURES ====================================== + _________________________________ TestClass.test_two _________________________________ self = @@ -149,9 +153,9 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look .. code-block:: pytest $ pytest -q test_tmpdir.py - F [100%] - ================================= FAILURES ================================= - _____________________________ test_needsfiles ______________________________ + F [100%] + ====================================== FAILURES ====================================== + __________________________________ test_needsfiles ___________________________________ tmpdir = local('PYTEST_TMPDIR/test_needsfiles0') @@ -161,7 +165,7 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look E assert 0 test_tmpdir.py:3: AssertionError - --------------------------- Captured stdout call --------------------------- + -------------------------------- Captured stdout call -------------------------------- PYTEST_TMPDIR/test_needsfiles0 1 failed in 0.12 seconds diff --git a/doc/en/index.rst b/doc/en/index.rst index 7c201fbd7..3c9cb0241 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -27,15 +27,17 @@ To execute it: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_sample.py F [100%] + test_sample.py F [100%] - ================================= FAILURES ================================= - _______________________________ test_answer ________________________________ + ====================================== FAILURES ====================================== + ____________________________________ test_answer _____________________________________ def test_answer(): > assert inc(3) == 5 @@ -43,7 +45,7 @@ To execute it: E + where 4 = inc(3) test_sample.py:6: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See :ref:`Getting Started ` for more examples. diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 099b531c2..0808b08df 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -55,15 +55,17 @@ them in turn: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 3 items - test_expectation.py ..F [100%] + test_expectation.py ..F [100%] - ================================= FAILURES ================================= - ____________________________ test_eval[6*9-42] _____________________________ + ====================================== FAILURES ====================================== + _________________________________ test_eval[6*9-42] __________________________________ test_input = '6*9', expected = 42 @@ -78,7 +80,7 @@ them in turn: E + where 54 = eval('6*9') test_expectation.py:8: AssertionError - ==================== 1 failed, 2 passed in 0.12 seconds ==================== + ========================= 1 failed, 2 passed in 0.12 seconds ========================= As designed in this example, only one pair of input/output values fails the simple test function. And as usual with test function arguments, @@ -106,14 +108,16 @@ Let's run this: .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 3 items - test_expectation.py ..x [100%] + test_expectation.py ..x [100%] - =================== 2 passed, 1 xfailed in 0.12 seconds ==================== + ======================== 2 passed, 1 xfailed in 0.12 seconds ========================= The one parameter set which caused a failure previously now shows up as an "xfailed (expected to fail)" test. @@ -173,7 +177,7 @@ command line option and the parametrization of our test function:: If we now pass two stringinput values, our test will run twice:: $ pytest -q --stringinput="hello" --stringinput="world" test_strings.py - .. [100%] + .. [100%] 2 passed in 0.12 seconds Let's also run with a stringinput that will lead to a failing test: @@ -181,9 +185,9 @@ Let's also run with a stringinput that will lead to a failing test: .. code-block:: pytest $ pytest -q --stringinput="!" test_strings.py - F [100%] - ================================= FAILURES ================================= - ___________________________ test_valid_string[!] ___________________________ + F [100%] + ====================================== FAILURES ====================================== + ________________________________ test_valid_string[!] ________________________________ stringinput = '!' @@ -205,8 +209,8 @@ list: .. code-block:: pytest $ pytest -q -rs test_strings.py - s [100%] - ========================= short test summary info ========================== + s [100%] + ============================== short test summary info =============================== SKIP [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1 1 skipped in 0.12 seconds diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index ae1dc7149..0f2073090 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -328,13 +328,15 @@ Running it with the report-on-xfail option gives this output: .. code-block:: pytest example $ pytest -rx xfail_demo.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/example/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/example, inifile: + plugins: hypothesis-3.x.y collected 7 items - xfail_demo.py xxxxxxx [100%] - ========================= short test summary info ========================== + xfail_demo.py xxxxxxx [100%] + ============================== short test summary info =============================== XFAIL xfail_demo.py::test_hello XFAIL xfail_demo.py::test_hello2 reason: [NOTRUN] @@ -348,7 +350,7 @@ Running it with the report-on-xfail option gives this output: reason: reason XFAIL xfail_demo.py::test_hello7 - ======================== 7 xfailed in 0.12 seconds ========================= + ============================= 7 xfailed in 0.12 seconds ============================== .. _`skip/xfail with parametrize`: diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index 8c21e17e5..5f7e98a84 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -40,15 +40,17 @@ Running this would result in a passed test except for the last .. code-block:: pytest $ pytest test_tmp_path.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_tmp_path.py F [100%] + test_tmp_path.py F [100%] - ================================= FAILURES ================================= - _____________________________ test_create_file _____________________________ + ====================================== FAILURES ====================================== + __________________________________ test_create_file __________________________________ tmp_path = PosixPath('PYTEST_TMPDIR/test_create_file0') @@ -63,7 +65,7 @@ Running this would result in a passed test except for the last E assert 0 test_tmp_path.py:13: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== The ``tmp_path_factory`` fixture -------------------------------- @@ -102,15 +104,17 @@ Running this would result in a passed test except for the last .. code-block:: pytest $ pytest test_tmpdir.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_tmpdir.py F [100%] + test_tmpdir.py F [100%] - ================================= FAILURES ================================= - _____________________________ test_create_file _____________________________ + ====================================== FAILURES ====================================== + __________________________________ test_create_file __________________________________ tmpdir = local('PYTEST_TMPDIR/test_create_file0') @@ -123,7 +127,7 @@ Running this would result in a passed test except for the last E assert 0 test_tmpdir.py:7: AssertionError - ========================= 1 failed in 0.12 seconds ========================= + ============================== 1 failed in 0.12 seconds ============================== .. _`tmpdir factory example`: diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index 34c8a35db..fe7f2e550 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -127,15 +127,17 @@ the ``self.db`` values in the traceback: .. code-block:: pytest $ pytest test_unittest_db.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 2 items - test_unittest_db.py FF [100%] + test_unittest_db.py FF [100%] - ================================= FAILURES ================================= - ___________________________ MyTest.test_method1 ____________________________ + ====================================== FAILURES ====================================== + ________________________________ MyTest.test_method1 _________________________________ self = @@ -146,7 +148,7 @@ the ``self.db`` values in the traceback: E assert 0 test_unittest_db.py:9: AssertionError - ___________________________ MyTest.test_method2 ____________________________ + ________________________________ MyTest.test_method2 _________________________________ self = @@ -156,7 +158,7 @@ the ``self.db`` values in the traceback: E assert 0 test_unittest_db.py:12: AssertionError - ========================= 2 failed in 0.12 seconds ========================= + ============================== 2 failed in 0.12 seconds ============================== This default pytest traceback shows that the two test methods share the same ``self.db`` instance which was our intention @@ -206,7 +208,7 @@ Running this test module ...: .. code-block:: pytest $ pytest -q test_unittest_cleandir.py - . [100%] + . [100%] 1 passed in 0.12 seconds ... gives us one passed test because the ``initdir`` fixture function diff --git a/doc/en/usage.rst b/doc/en/usage.rst index bd9706c4f..87171507d 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -155,12 +155,14 @@ Example: .. code-block:: pytest $ pytest -ra - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes". @@ -180,12 +182,14 @@ More than one character can be used, so for example to only see failed and skipp .. code-block:: pytest $ pytest -rfs - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had captured output: @@ -193,12 +197,14 @@ captured output: .. code-block:: pytest $ pytest -rpP - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 0 items - ======================= no tests ran in 0.12 seconds ======================= + ============================ no tests ran in 0.12 seconds ============================ .. _pdb-option: @@ -584,7 +590,7 @@ Running it will show that ``MyPlugin`` was added and its hook was invoked:: $ python myinvoke.py - . [100%]*** test run reporting finishing + . [100%]*** test run reporting finishing .. note:: diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 3e69d3480..8de555d3c 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -23,20 +23,22 @@ Running pytest now produces this output: .. code-block:: pytest $ pytest test_show_warnings.py - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: + plugins: hypothesis-3.x.y collected 1 item - test_show_warnings.py . [100%] + test_show_warnings.py . [100%] - ============================= warnings summary ============================= + ================================== warnings summary ================================== test_show_warnings.py::test_one $REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2 warnings.warn(UserWarning("api v1, should use functions from v2")) -- Docs: https://docs.pytest.org/en/latest/warnings.html - =================== 1 passed, 1 warnings in 0.12 seconds =================== + ======================== 1 passed, 1 warnings in 0.12 seconds ======================== The ``-W`` flag can be passed to control which warnings will be displayed or even turn them into errors: @@ -44,15 +46,15 @@ them into errors: .. code-block:: pytest $ pytest -q test_show_warnings.py -W error::UserWarning - F [100%] - ================================= FAILURES ================================= - _________________________________ test_one _________________________________ + F [100%] + ====================================== FAILURES ====================================== + ______________________________________ test_one ______________________________________ def test_one(): > assert api_v1() == 1 test_show_warnings.py:8: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def api_v1(): > warnings.warn(UserWarning("api v1, should use functions from v2")) @@ -355,7 +357,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta $ pytest test_pytest_warnings.py -q - ============================= warnings summary ============================= + ================================== warnings summary ================================== test_pytest_warnings.py:1 $REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestWarning: cannot collect test class 'Test' because it has a __init__ constructor class Test: diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index 70bf315aa..f627fec05 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -411,20 +411,22 @@ additionally it is possible to copy examples for an example folder before runnin .. code-block:: pytest $ pytest - =========================== test session starts ============================ + ================================ test session starts ================================= platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y + hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini + plugins: hypothesis-3.x.y collected 2 items - test_example.py .. [100%] + test_example.py .. [100%] - ============================= warnings summary ============================= + ================================== warnings summary ================================== test_example.py::test_plugin $REGENDOC_TMPDIR/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time testdir.copy_example("test_example.py") -- Docs: https://docs.pytest.org/en/latest/warnings.html - =================== 2 passed, 1 warnings in 0.12 seconds =================== + ======================== 2 passed, 1 warnings in 0.12 seconds ======================== For more information about the result object that ``runpytest()`` returns, and the methods that it provides please check out the :py:class:`RunResult From 01151ff566388a53b5cac3eeb90aae6045275c75 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 16:53:12 -0200 Subject: [PATCH 07/17] Add example for -ra usage to the docs --- doc/en/usage.rst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 87171507d..2a2d972c0 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -152,6 +152,42 @@ making it easy in large test suites to get a clear picture of all failures, skip Example: +.. code-block:: python + + # content of test_example.py + import pytest + + + @pytest.fixture + def error_fixture(): + assert 0 + + + def test_ok(): + print("ok") + + + def test_fail(): + assert 0 + + + def test_error(error_fixture): + pass + + + def test_skip(): + pytest.skip("skipping this test") + + + def test_xfail(): + pytest.xfail("xfailing this test") + + + @pytest.mark.xfail(reason="always xfail") + def test_xpass(): + pass + + .. code-block:: pytest $ pytest -ra From 5d0bcb441937ec5d1cc4e5dff1d3002d7bb00801 Mon Sep 17 00:00:00 2001 From: "dmitry.dygalo" Date: Sat, 5 Jan 2019 20:08:09 +0100 Subject: [PATCH 08/17] Fix typo in the Changelog for `get_closest_marker` --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 22f3ac862..f63fd0813 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1022,7 +1022,7 @@ Features - Revamp the internals of the ``pytest.mark`` implementation with correct per node handling which fixes a number of long standing bugs caused by the old design. This introduces new ``Node.iter_markers(name)`` and - ``Node.get_closest_mark(name)`` APIs. Users are **strongly encouraged** to + ``Node.get_closest_marker(name)`` APIs. Users are **strongly encouraged** to read the `reasons for the revamp in the docs `_, or jump over to details about `updating existing code to use the new APIs From d7465895d09e71225ffa6ae6943e2ae6b6136ec8 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 19:19:40 +0000 Subject: [PATCH 09/17] Regendoc again --- doc/en/assert.rst | 26 +++--- doc/en/cache.rst | 52 ++++++------ doc/en/capture.rst | 12 +-- doc/en/doctest.rst | 6 +- doc/en/example/markers.rst | 112 ++++++++++++------------- doc/en/example/nonpython.rst | 26 +++--- doc/en/example/parametrize.rst | 64 +++++++-------- doc/en/example/pythoncollection.rst | 12 +-- doc/en/example/reportingdemo.rst | 108 ++++++++++++------------ doc/en/example/simple.rst | 122 ++++++++++++++-------------- doc/en/fixture.rst | 76 ++++++++--------- doc/en/getting-started.rst | 26 +++--- doc/en/index.rst | 10 +-- doc/en/parametrize.rst | 28 +++---- doc/en/skipping.rst | 8 +- doc/en/tmpdir.rst | 20 ++--- doc/en/unittest.rst | 14 ++-- doc/en/usage.rst | 110 ++++++++++++++++++++++--- doc/en/warnings.rst | 18 ++-- doc/en/writing_plugins.rst | 8 +- 20 files changed, 474 insertions(+), 384 deletions(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 7f422af1f..511839d88 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -27,17 +27,17 @@ you will see the return value of the function call: .. code-block:: pytest $ pytest test_assert1.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_assert1.py F [100%] + test_assert1.py F [100%] - ====================================== FAILURES ====================================== - ___________________________________ test_function ____________________________________ + ================================= FAILURES ================================= + ______________________________ test_function _______________________________ def test_function(): > assert f() == 4 @@ -45,7 +45,7 @@ you will see the return value of the function call: E + where 3 = f() test_assert1.py:5: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= ``pytest`` has support for showing the values of the most common subexpressions including calls, attributes, comparisons, and binary and unary @@ -173,17 +173,17 @@ if you run this module: .. code-block:: pytest $ pytest test_assert2.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_assert2.py F [100%] + test_assert2.py F [100%] - ====================================== FAILURES ====================================== - ________________________________ test_set_comparison _________________________________ + ================================= FAILURES ================================= + ___________________________ test_set_comparison ____________________________ def test_set_comparison(): set1 = set("1308") @@ -197,7 +197,7 @@ if you run this module: E Use -v to get the full diff test_assert2.py:5: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= Special comparisons are done for a number of cases: @@ -247,9 +247,9 @@ the conftest file: .. code-block:: pytest $ pytest -q test_foocompare.py - F [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_compare ____________________________________ + F [100%] + ================================= FAILURES ================================= + _______________________________ test_compare _______________________________ def test_compare(): f1 = Foo(1) diff --git a/doc/en/cache.rst b/doc/en/cache.rst index 1814d386d..caa170027 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -48,9 +48,9 @@ If you run this for the first time you will see two failures: .. code-block:: pytest $ pytest -q - .................F.......F........................ [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_num[17] ____________________________________ + .................F.......F........................ [100%] + ================================= FAILURES ================================= + _______________________________ test_num[17] _______________________________ i = 17 @@ -61,7 +61,7 @@ If you run this for the first time you will see two failures: E Failed: bad luck test_50.py:6: Failed - ____________________________________ test_num[25] ____________________________________ + _______________________________ test_num[25] _______________________________ i = 25 @@ -79,7 +79,7 @@ If you then run it with ``--lf``: .. code-block:: pytest $ pytest --lf - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -87,10 +87,10 @@ If you then run it with ``--lf``: collected 50 items / 48 deselected run-last-failure: rerun previous 2 failures - test_50.py FF [100%] + test_50.py FF [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_num[17] ____________________________________ + ================================= FAILURES ================================= + _______________________________ test_num[17] _______________________________ i = 17 @@ -101,7 +101,7 @@ If you then run it with ``--lf``: E Failed: bad luck test_50.py:6: Failed - ____________________________________ test_num[25] ____________________________________ + _______________________________ test_num[25] _______________________________ i = 25 @@ -112,7 +112,7 @@ If you then run it with ``--lf``: E Failed: bad luck test_50.py:6: Failed - ====================== 2 failed, 48 deselected in 0.12 seconds ======================= + ================= 2 failed, 48 deselected in 0.12 seconds ================== You have run only the two failing test from the last run, while 48 tests have not been run ("deselected"). @@ -124,7 +124,7 @@ of ``FF`` and dots): .. code-block:: pytest $ pytest --ff - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -132,10 +132,10 @@ of ``FF`` and dots): collected 50 items run-last-failure: rerun previous 2 failures first - test_50.py FF................................................ [100%] + test_50.py FF................................................ [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_num[17] ____________________________________ + ================================= FAILURES ================================= + _______________________________ test_num[17] _______________________________ i = 17 @@ -146,7 +146,7 @@ of ``FF`` and dots): E Failed: bad luck test_50.py:6: Failed - ____________________________________ test_num[25] ____________________________________ + _______________________________ test_num[25] _______________________________ i = 25 @@ -157,7 +157,7 @@ of ``FF`` and dots): E Failed: bad luck test_50.py:6: Failed - ======================== 2 failed, 48 passed in 0.12 seconds ========================= + =================== 2 failed, 48 passed in 0.12 seconds ==================== .. _`config.cache`: @@ -209,9 +209,9 @@ If you run this command for the first time, you can see the print statement: .. code-block:: pytest $ pytest -q - F [100%] - ====================================== FAILURES ====================================== - ___________________________________ test_function ____________________________________ + F [100%] + ================================= FAILURES ================================= + ______________________________ test_function _______________________________ mydata = 42 @@ -220,7 +220,7 @@ If you run this command for the first time, you can see the print statement: E assert 42 == 23 test_caching.py:17: AssertionError - ------------------------------- Captured stdout setup -------------------------------- + -------------------------- Captured stdout setup --------------------------- running expensive computation... 1 failed in 0.12 seconds @@ -230,9 +230,9 @@ the cache and nothing will be printed: .. code-block:: pytest $ pytest -q - F [100%] - ====================================== FAILURES ====================================== - ___________________________________ test_function ____________________________________ + F [100%] + ================================= FAILURES ================================= + ______________________________ test_function _______________________________ mydata = 42 @@ -255,13 +255,13 @@ You can always peek at the content of the cache using the .. code-block:: pytest $ pytest --cache-show - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y cachedir: $REGENDOC_TMPDIR/.pytest_cache - ------------------------------------ cache values ------------------------------------ + ------------------------------- cache values ------------------------------- cache/lastfailed contains: {'test_caching.py::test_function': True} cache/nodeids contains: @@ -271,7 +271,7 @@ You can always peek at the content of the cache using the example/value contains: 42 - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= Clearing Cache content ------------------------------- diff --git a/doc/en/capture.rst b/doc/en/capture.rst index 15ad75910..7d452b9f9 100644 --- a/doc/en/capture.rst +++ b/doc/en/capture.rst @@ -66,26 +66,26 @@ of the failing function and hide the other one: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py .F [100%] + test_module.py .F [100%] - ====================================== FAILURES ====================================== - _____________________________________ test_func2 _____________________________________ + ================================= FAILURES ================================= + ________________________________ test_func2 ________________________________ def test_func2(): > assert False E assert False test_module.py:9: AssertionError - ------------------------------- Captured stdout setup -------------------------------- + -------------------------- Captured stdout setup --------------------------- setting up - ========================= 1 failed, 1 passed in 0.12 seconds ========================= + ==================== 1 failed, 1 passed in 0.12 seconds ==================== Accessing captured output from a test function --------------------------------------------------- diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index c861ede8a..69a9cd18a 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -63,16 +63,16 @@ then you can just invoke ``pytest`` without command line options: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini plugins: hypothesis-3.x.y collected 1 item - mymodule.py . [100%] + mymodule.py . [100%] - ============================== 1 passed in 0.12 seconds ============================== + ========================= 1 passed in 0.12 seconds ========================= It is possible to use fixtures using the ``getfixture`` helper:: diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index b27a4fcb2..637640062 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -32,7 +32,7 @@ You can then restrict a test run to only run tests marked with ``webtest``: .. code-block:: pytest $ pytest -v -m webtest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -40,16 +40,16 @@ You can then restrict a test run to only run tests marked with ``webtest``: plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected - test_server.py::test_send_http PASSED [100%] + test_server.py::test_send_http PASSED [100%] - ======================= 1 passed, 3 deselected in 0.12 seconds ======================= + ================== 1 passed, 3 deselected in 0.12 seconds ================== Or the inverse, running all tests except the webtest ones: .. code-block:: pytest $ pytest -v -m "not webtest" - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -57,11 +57,11 @@ Or the inverse, running all tests except the webtest ones: plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected - test_server.py::test_something_quick PASSED [ 33%] - test_server.py::test_another PASSED [ 66%] - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::test_something_quick PASSED [ 33%] + test_server.py::test_another PASSED [ 66%] + test_server.py::TestClass::test_method PASSED [100%] - ======================= 3 passed, 1 deselected in 0.12 seconds ======================= + ================== 3 passed, 1 deselected in 0.12 seconds ================== Selecting tests based on their node ID -------------------------------------- @@ -73,7 +73,7 @@ tests based on their module, class, method, or function name: .. code-block:: pytest $ pytest -v test_server.py::TestClass::test_method - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -81,16 +81,16 @@ tests based on their module, class, method, or function name: plugins: hypothesis-3.x.y collecting ... collected 1 item - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::TestClass::test_method PASSED [100%] - ============================== 1 passed in 0.12 seconds ============================== + ========================= 1 passed in 0.12 seconds ========================= You can also select on the class: .. code-block:: pytest $ pytest -v test_server.py::TestClass - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -98,16 +98,16 @@ You can also select on the class: plugins: hypothesis-3.x.y collecting ... collected 1 item - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::TestClass::test_method PASSED [100%] - ============================== 1 passed in 0.12 seconds ============================== + ========================= 1 passed in 0.12 seconds ========================= Or select multiple nodes: .. code-block:: pytest $ pytest -v test_server.py::TestClass test_server.py::test_send_http - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -115,10 +115,10 @@ Or select multiple nodes: plugins: hypothesis-3.x.y collecting ... collected 2 items - test_server.py::TestClass::test_method PASSED [ 50%] - test_server.py::test_send_http PASSED [100%] + test_server.py::TestClass::test_method PASSED [ 50%] + test_server.py::test_send_http PASSED [100%] - ============================== 2 passed in 0.12 seconds ============================== + ========================= 2 passed in 0.12 seconds ========================= .. _node-id: @@ -149,7 +149,7 @@ select tests based on their names: .. code-block:: pytest $ pytest -v -k http # running with the above defined example module - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -157,16 +157,16 @@ select tests based on their names: plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected - test_server.py::test_send_http PASSED [100%] + test_server.py::test_send_http PASSED [100%] - ======================= 1 passed, 3 deselected in 0.12 seconds ======================= + ================== 1 passed, 3 deselected in 0.12 seconds ================== And you can also run all tests except the ones that match the keyword: .. code-block:: pytest $ pytest -k "not send_http" -v - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -174,18 +174,18 @@ And you can also run all tests except the ones that match the keyword: plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected - test_server.py::test_something_quick PASSED [ 33%] - test_server.py::test_another PASSED [ 66%] - test_server.py::TestClass::test_method PASSED [100%] + test_server.py::test_something_quick PASSED [ 33%] + test_server.py::test_another PASSED [ 66%] + test_server.py::TestClass::test_method PASSED [100%] - ======================= 3 passed, 1 deselected in 0.12 seconds ======================= + ================== 3 passed, 1 deselected in 0.12 seconds ================== Or to select "http" and "quick" tests: .. code-block:: pytest $ pytest -k "http or quick" -v - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -193,10 +193,10 @@ Or to select "http" and "quick" tests: plugins: hypothesis-3.x.y collecting ... collected 4 items / 2 deselected - test_server.py::test_send_http PASSED [ 50%] - test_server.py::test_something_quick PASSED [100%] + test_server.py::test_send_http PASSED [ 50%] + test_server.py::test_something_quick PASSED [100%] - ======================= 2 passed, 2 deselected in 0.12 seconds ======================= + ================== 2 passed, 2 deselected in 0.12 seconds ================== .. note:: @@ -381,32 +381,32 @@ the test needs: .. code-block:: pytest $ pytest -E stage2 - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_someenv.py s [100%] + test_someenv.py s [100%] - ============================= 1 skipped in 0.12 seconds ============================== + ======================== 1 skipped in 0.12 seconds ========================= and here is one that specifies exactly the environment needed: .. code-block:: pytest $ pytest -E stage1 - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_someenv.py . [100%] + test_someenv.py . [100%] - ============================== 1 passed in 0.12 seconds ============================== + ========================= 1 passed in 0.12 seconds ========================= The ``--markers`` option always gives you a list of available markers:: @@ -568,34 +568,34 @@ then you will see two tests skipped and two executed tests as expected: .. code-block:: pytest $ pytest -rs # this option reports skip reasons - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items - test_plat.py s.s. [100%] - ============================== short test summary info =============================== + test_plat.py s.s. [100%] + ========================= short test summary info ========================== SKIP [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux - ======================== 2 passed, 2 skipped in 0.12 seconds ========================= + =================== 2 passed, 2 skipped in 0.12 seconds ==================== Note that if you specify a platform via the marker-command line option like this: .. code-block:: pytest $ pytest -m linux - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items / 3 deselected - test_plat.py . [100%] + test_plat.py . [100%] - ======================= 1 passed, 3 deselected in 0.12 seconds ======================= + ================== 1 passed, 3 deselected in 0.12 seconds ================== then the unmarked-tests will not be run. It is thus a way to restrict the run to the specific tests. @@ -641,51 +641,51 @@ We can now use the ``-m option`` to select one set: .. code-block:: pytest $ pytest -m interface --tb=short - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items / 2 deselected - test_module.py FF [100%] + test_module.py FF [100%] - ====================================== FAILURES ====================================== - _______________________________ test_interface_simple ________________________________ + ================================= FAILURES ================================= + __________________________ test_interface_simple ___________________________ test_module.py:3: in test_interface_simple assert 0 E assert 0 - _______________________________ test_interface_complex _______________________________ + __________________________ test_interface_complex __________________________ test_module.py:6: in test_interface_complex assert 0 E assert 0 - ======================= 2 failed, 2 deselected in 0.12 seconds ======================= + ================== 2 failed, 2 deselected in 0.12 seconds ================== or to select both "event" and "interface" tests: .. code-block:: pytest $ pytest -m "interface or event" --tb=short - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items / 1 deselected - test_module.py FFF [100%] + test_module.py FFF [100%] - ====================================== FAILURES ====================================== - _______________________________ test_interface_simple ________________________________ + ================================= FAILURES ================================= + __________________________ test_interface_simple ___________________________ test_module.py:3: in test_interface_simple assert 0 E assert 0 - _______________________________ test_interface_complex _______________________________ + __________________________ test_interface_complex __________________________ test_module.py:6: in test_interface_complex assert 0 E assert 0 - _________________________________ test_event_simple __________________________________ + ____________________________ test_event_simple _____________________________ test_module.py:9: in test_event_simple assert 0 E assert 0 - ======================= 3 failed, 1 deselected in 0.12 seconds ======================= + ================== 3 failed, 1 deselected in 0.12 seconds ================== diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index 1581b8672..3db466391 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -28,21 +28,21 @@ now execute the test specification: .. code-block:: pytest nonpython $ pytest test_simple.yml - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: plugins: hypothesis-3.x.y collected 2 items - test_simple.yml F. [100%] + test_simple.yml F. [100%] - ====================================== FAILURES ====================================== - ___________________________________ usecase: hello ___________________________________ + ================================= FAILURES ================================= + ______________________________ usecase: hello ______________________________ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ========================= 1 failed, 1 passed in 0.12 seconds ========================= + ==================== 1 failed, 1 passed in 0.12 seconds ==================== .. regendoc:wipe @@ -64,7 +64,7 @@ consulted when reporting in ``verbose`` mode: .. code-block:: pytest nonpython $ pytest -v - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') @@ -72,15 +72,15 @@ consulted when reporting in ``verbose`` mode: plugins: hypothesis-3.x.y collecting ... collected 2 items - test_simple.yml::hello FAILED [ 50%] - test_simple.yml::ok PASSED [100%] + test_simple.yml::hello FAILED [ 50%] + test_simple.yml::ok PASSED [100%] - ====================================== FAILURES ====================================== - ___________________________________ usecase: hello ___________________________________ + ================================= FAILURES ================================= + ______________________________ usecase: hello ______________________________ usecase execution failed spec failed: 'some': 'other' no further details known at this point. - ========================= 1 failed, 1 passed in 0.12 seconds ========================= + ==================== 1 failed, 1 passed in 0.12 seconds ==================== .. regendoc:wipe @@ -90,7 +90,7 @@ interesting to just look at the collection tree: .. code-block:: pytest nonpython $ pytest --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: @@ -101,4 +101,4 @@ interesting to just look at the collection tree: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 76cb68867..133add2c6 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -47,7 +47,7 @@ This means that we only run 2 tests if we do not pass ``--all``: .. code-block:: pytest $ pytest -q test_compute.py - .. [100%] + .. [100%] 2 passed in 0.12 seconds We run only two computations, so we see two dots. @@ -56,9 +56,9 @@ let's run the full monty: .. code-block:: pytest $ pytest -q --all - ....F [100%] - ====================================== FAILURES ====================================== - __________________________________ test_compute[4] ___________________________________ + ....F [100%] + ================================= FAILURES ================================= + _____________________________ test_compute[4] ______________________________ param1 = 4 @@ -143,7 +143,7 @@ objects, they are still using the default pytest representation: .. code-block:: pytest $ pytest test_time.py --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -159,7 +159,7 @@ objects, they are still using the default pytest representation: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= In ``test_timedistance_v3``, we used ``pytest.param`` to specify the test IDs together with the actual data, instead of listing them separately. @@ -203,23 +203,23 @@ this is a fully self-contained example which you can run with: .. code-block:: pytest $ pytest test_scenarios.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items - test_scenarios.py .... [100%] + test_scenarios.py .... [100%] - ============================== 4 passed in 0.12 seconds ============================== + ========================= 4 passed in 0.12 seconds ========================= If you just collect tests you'll also nicely see 'advanced' and 'basic' as variants for the test function: .. code-block:: pytest $ pytest --collect-only test_scenarios.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -232,7 +232,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= Note that we told ``metafunc.parametrize()`` that your scenario values should be considered class-scoped. With pytest-2.3 this leads to a @@ -287,7 +287,7 @@ Let's first see how it looks like at collection time: .. code-block:: pytest $ pytest test_backends.py --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -297,16 +297,16 @@ Let's first see how it looks like at collection time: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= And then when we run the test: .. code-block:: pytest $ pytest -q test_backends.py - .F [100%] - ====================================== FAILURES ====================================== - ______________________________ test_db_initialized[d2] _______________________________ + .F [100%] + ================================= FAILURES ================================= + _________________________ test_db_initialized[d2] __________________________ db = @@ -354,7 +354,7 @@ The result of this test will be successful: .. code-block:: pytest $ pytest test_indirect_list.py --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -363,7 +363,7 @@ The result of this test will be successful: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= .. regendoc:wipe @@ -407,9 +407,9 @@ argument sets to use for each test function. Let's run it: .. code-block:: pytest $ pytest -q - F.. [100%] - ====================================== FAILURES ====================================== - _____________________________ TestClass.test_equals[1-2] _____________________________ + F.. [100%] + ================================= FAILURES ================================= + ________________________ TestClass.test_equals[1-2] ________________________ self = , a = 1, b = 2 @@ -439,8 +439,8 @@ Running it results in some skips if we don't have all the python interpreters in .. code-block:: pytest . $ pytest -rs -q multipython.py - ...sss...sssssssss...sss... [100%] - ============================== short test summary info =============================== + ...sss...sssssssss...sss... [100%] + ========================= short test summary info ========================== SKIP [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.4' not found 12 passed, 15 skipped in 0.12 seconds @@ -490,18 +490,18 @@ If you run this with reporting for skips enabled: .. code-block:: pytest $ pytest -rs test_module.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py .s [100%] - ============================== short test summary info =============================== + test_module.py .s [100%] + ========================= short test summary info ========================== SKIP [1] $REGENDOC_TMPDIR/conftest.py:11: could not import 'opt2' - ======================== 1 passed, 1 skipped in 0.12 seconds ========================= + =================== 1 passed, 1 skipped in 0.12 seconds ==================== You'll see that we don't have an ``opt2`` module and thus the second test run of our ``test_func1`` was skipped. A few notes: @@ -549,7 +549,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: .. code-block:: pytest $ pytest -v -m basic - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -557,11 +557,11 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: plugins: hypothesis-3.x.y collecting ... collected 17 items / 14 deselected - test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] - test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%] - test_pytest_param_example.py::test_eval[basic_6*9] xfail [100%] + test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] + test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%] + test_pytest_param_example.py::test_eval[basic_6*9] xfail [100%] - ================= 2 passed, 14 deselected, 1 xfailed in 0.12 seconds ================= + ============ 2 passed, 14 deselected, 1 xfailed in 0.12 seconds ============ As the result: diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index bc7e0c0d2..53e7cd321 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -130,7 +130,7 @@ The test collection would look like this: .. code-block:: pytest $ pytest --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini @@ -141,7 +141,7 @@ The test collection would look like this: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= You can check for multiple glob patterns by adding a space between the patterns:: @@ -187,7 +187,7 @@ You can always peek at the collection tree without running tests like this: .. code-block:: pytest . $ pytest --collect-only pythoncollection.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/CWD/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini @@ -199,7 +199,7 @@ You can always peek at the collection tree without running tests like this: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= .. _customizing-test-collection: @@ -261,11 +261,11 @@ file will be left out: .. code-block:: pytest $ pytest --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini plugins: hypothesis-3.x.y collected 0 items - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index d99a06725..c40e15572 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -12,17 +12,17 @@ get on the terminal - we are working on that): .. code-block:: pytest assertion $ pytest failure_demo.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/assertion/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/assertion, inifile: plugins: hypothesis-3.x.y collected 44 items - failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] + failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] - ====================================== FAILURES ====================================== - ________________________________ test_generative[3-6] ________________________________ + ================================= FAILURES ================================= + ___________________________ test_generative[3-6] ___________________________ param1 = 3, param2 = 6 @@ -32,7 +32,7 @@ get on the terminal - we are working on that): E assert (3 * 2) < 6 failure_demo.py:22: AssertionError - ______________________________ TestFailing.test_simple _______________________________ + _________________________ TestFailing.test_simple __________________________ self = @@ -49,7 +49,7 @@ get on the terminal - we are working on that): E + and 43 = .g at 0xdeadbeef>() failure_demo.py:33: AssertionError - _________________________ TestFailing.test_simple_multiline __________________________ + ____________________ TestFailing.test_simple_multiline _____________________ self = @@ -57,7 +57,7 @@ get on the terminal - we are working on that): > otherfunc_multi(42, 6 * 9) failure_demo.py:36: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 42, b = 54 @@ -66,7 +66,7 @@ get on the terminal - we are working on that): E assert 42 == 54 failure_demo.py:17: AssertionError - ________________________________ TestFailing.test_not ________________________________ + ___________________________ TestFailing.test_not ___________________________ self = @@ -79,7 +79,7 @@ get on the terminal - we are working on that): E + where 42 = .f at 0xdeadbeef>() failure_demo.py:42: AssertionError - ______________________ TestSpecialisedExplanations.test_eq_text ______________________ + _________________ TestSpecialisedExplanations.test_eq_text _________________ self = @@ -90,7 +90,7 @@ get on the terminal - we are working on that): E + eggs failure_demo.py:47: AssertionError - __________________ TestSpecialisedExplanations.test_eq_similar_text __________________ + _____________ TestSpecialisedExplanations.test_eq_similar_text _____________ self = @@ -103,7 +103,7 @@ get on the terminal - we are working on that): E ? ^ failure_demo.py:50: AssertionError - _________________ TestSpecialisedExplanations.test_eq_multiline_text _________________ + ____________ TestSpecialisedExplanations.test_eq_multiline_text ____________ self = @@ -116,7 +116,7 @@ get on the terminal - we are working on that): E bar failure_demo.py:53: AssertionError - ___________________ TestSpecialisedExplanations.test_eq_long_text ____________________ + ______________ TestSpecialisedExplanations.test_eq_long_text _______________ self = @@ -133,7 +133,7 @@ get on the terminal - we are working on that): E ? ^ failure_demo.py:58: AssertionError - ______________ TestSpecialisedExplanations.test_eq_long_text_multiline _______________ + _________ TestSpecialisedExplanations.test_eq_long_text_multiline __________ self = @@ -153,7 +153,7 @@ get on the terminal - we are working on that): E ...Full output truncated (7 lines hidden), use '-vv' to show failure_demo.py:63: AssertionError - ______________________ TestSpecialisedExplanations.test_eq_list ______________________ + _________________ TestSpecialisedExplanations.test_eq_list _________________ self = @@ -164,7 +164,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:66: AssertionError - ___________________ TestSpecialisedExplanations.test_eq_list_long ____________________ + ______________ TestSpecialisedExplanations.test_eq_list_long _______________ self = @@ -177,7 +177,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:71: AssertionError - ______________________ TestSpecialisedExplanations.test_eq_dict ______________________ + _________________ TestSpecialisedExplanations.test_eq_dict _________________ self = @@ -195,7 +195,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:74: AssertionError - ______________________ TestSpecialisedExplanations.test_eq_set _______________________ + _________________ TestSpecialisedExplanations.test_eq_set __________________ self = @@ -213,7 +213,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:77: AssertionError - __________________ TestSpecialisedExplanations.test_eq_longer_list ___________________ + _____________ TestSpecialisedExplanations.test_eq_longer_list ______________ self = @@ -224,7 +224,7 @@ get on the terminal - we are working on that): E Use -v to get the full diff failure_demo.py:80: AssertionError - ______________________ TestSpecialisedExplanations.test_in_list ______________________ + _________________ TestSpecialisedExplanations.test_in_list _________________ self = @@ -233,7 +233,7 @@ get on the terminal - we are working on that): E assert 1 in [0, 2, 3, 4, 5] failure_demo.py:83: AssertionError - _______________ TestSpecialisedExplanations.test_not_in_text_multiline _______________ + __________ TestSpecialisedExplanations.test_not_in_text_multiline __________ self = @@ -252,7 +252,7 @@ get on the terminal - we are working on that): E ...Full output truncated (2 lines hidden), use '-vv' to show failure_demo.py:87: AssertionError - ________________ TestSpecialisedExplanations.test_not_in_text_single _________________ + ___________ TestSpecialisedExplanations.test_not_in_text_single ____________ self = @@ -265,7 +265,7 @@ get on the terminal - we are working on that): E ? +++ failure_demo.py:91: AssertionError - ______________ TestSpecialisedExplanations.test_not_in_text_single_long ______________ + _________ TestSpecialisedExplanations.test_not_in_text_single_long _________ self = @@ -278,7 +278,7 @@ get on the terminal - we are working on that): E ? +++ failure_demo.py:95: AssertionError - ___________ TestSpecialisedExplanations.test_not_in_text_single_long_term ____________ + ______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______ self = @@ -291,7 +291,7 @@ get on the terminal - we are working on that): E ? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ failure_demo.py:99: AssertionError - ___________________ TestSpecialisedExplanations.test_eq_dataclass ____________________ + ______________ TestSpecialisedExplanations.test_eq_dataclass _______________ self = @@ -312,7 +312,7 @@ get on the terminal - we are working on that): E b: 'b' != 'c' failure_demo.py:111: AssertionError - _____________________ TestSpecialisedExplanations.test_eq_attrs ______________________ + ________________ TestSpecialisedExplanations.test_eq_attrs _________________ self = @@ -333,7 +333,7 @@ get on the terminal - we are working on that): E b: 'b' != 'c' failure_demo.py:123: AssertionError - ___________________________________ test_attribute ___________________________________ + ______________________________ test_attribute ______________________________ def test_attribute(): class Foo(object): @@ -345,7 +345,7 @@ get on the terminal - we are working on that): E + where 1 = .Foo object at 0xdeadbeef>.b failure_demo.py:131: AssertionError - ______________________________ test_attribute_instance _______________________________ + _________________________ test_attribute_instance __________________________ def test_attribute_instance(): class Foo(object): @@ -357,7 +357,7 @@ get on the terminal - we are working on that): E + where .Foo object at 0xdeadbeef> = .Foo'>() failure_demo.py:138: AssertionError - _______________________________ test_attribute_failure _______________________________ + __________________________ test_attribute_failure __________________________ def test_attribute_failure(): class Foo(object): @@ -370,7 +370,7 @@ get on the terminal - we are working on that): > assert i.b == 2 failure_demo.py:149: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = .Foo object at 0xdeadbeef> @@ -379,7 +379,7 @@ get on the terminal - we are working on that): E Exception: Failed to get attrib failure_demo.py:144: Exception - ______________________________ test_attribute_multiple _______________________________ + _________________________ test_attribute_multiple __________________________ def test_attribute_multiple(): class Foo(object): @@ -396,7 +396,7 @@ get on the terminal - we are working on that): E + where .Bar object at 0xdeadbeef> = .Bar'>() failure_demo.py:159: AssertionError - _______________________________ TestRaises.test_raises _______________________________ + __________________________ TestRaises.test_raises __________________________ self = @@ -406,7 +406,7 @@ get on the terminal - we are working on that): E ValueError: invalid literal for int() with base 10: 'qwe' failure_demo.py:169: ValueError - ___________________________ TestRaises.test_raises_doesnt ____________________________ + ______________________ TestRaises.test_raises_doesnt _______________________ self = @@ -415,7 +415,7 @@ get on the terminal - we are working on that): E Failed: DID NOT RAISE failure_demo.py:172: Failed - _______________________________ TestRaises.test_raise ________________________________ + __________________________ TestRaises.test_raise ___________________________ self = @@ -424,7 +424,7 @@ get on the terminal - we are working on that): E ValueError: demo error failure_demo.py:175: ValueError - _____________________________ TestRaises.test_tupleerror _____________________________ + ________________________ TestRaises.test_tupleerror ________________________ self = @@ -433,7 +433,7 @@ get on the terminal - we are working on that): E ValueError: not enough values to unpack (expected 2, got 1) failure_demo.py:178: ValueError - ___________ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ___________ + ______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______ self = @@ -444,9 +444,9 @@ get on the terminal - we are working on that): E TypeError: 'int' object is not iterable failure_demo.py:183: TypeError - -------------------------------- Captured stdout call -------------------------------- + --------------------------- Captured stdout call --------------------------- items is [1, 2, 3] - _____________________________ TestRaises.test_some_error _____________________________ + ________________________ TestRaises.test_some_error ________________________ self = @@ -455,7 +455,7 @@ get on the terminal - we are working on that): E NameError: name 'namenotexi' is not defined failure_demo.py:186: NameError - _________________________ test_dynamic_compile_shows_nicely __________________________ + ____________________ test_dynamic_compile_shows_nicely _____________________ def test_dynamic_compile_shows_nicely(): import imp @@ -470,14 +470,14 @@ get on the terminal - we are working on that): > module.foo() failure_demo.py:204: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def foo(): > assert 1 == 0 E AssertionError <0-codegen 'abc-123' $REGENDOC_TMPDIR/assertion/failure_demo.py:201>:2: AssertionError - _________________________ TestMoreErrors.test_complex_error __________________________ + ____________________ TestMoreErrors.test_complex_error _____________________ self = @@ -491,10 +491,10 @@ get on the terminal - we are working on that): > somefunc(f(), g()) failure_demo.py:215: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ failure_demo.py:13: in somefunc otherfunc(x, y) - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = 44, b = 43 @@ -503,7 +503,7 @@ get on the terminal - we are working on that): E assert 44 == 43 failure_demo.py:9: AssertionError - ________________________ TestMoreErrors.test_z1_unpack_error _________________________ + ___________________ TestMoreErrors.test_z1_unpack_error ____________________ self = @@ -513,7 +513,7 @@ get on the terminal - we are working on that): E ValueError: not enough values to unpack (expected 2, got 0) failure_demo.py:219: ValueError - _________________________ TestMoreErrors.test_z2_type_error __________________________ + ____________________ TestMoreErrors.test_z2_type_error _____________________ self = @@ -523,7 +523,7 @@ get on the terminal - we are working on that): E TypeError: 'int' object is not iterable failure_demo.py:223: TypeError - ___________________________ TestMoreErrors.test_startswith ___________________________ + ______________________ TestMoreErrors.test_startswith ______________________ self = @@ -536,7 +536,7 @@ get on the terminal - we are working on that): E + where = '123'.startswith failure_demo.py:228: AssertionError - _______________________ TestMoreErrors.test_startswith_nested ________________________ + __________________ TestMoreErrors.test_startswith_nested ___________________ self = @@ -555,7 +555,7 @@ get on the terminal - we are working on that): E + and '456' = .g at 0xdeadbeef>() failure_demo.py:237: AssertionError - __________________________ TestMoreErrors.test_global_func ___________________________ + _____________________ TestMoreErrors.test_global_func ______________________ self = @@ -566,7 +566,7 @@ get on the terminal - we are working on that): E + where 43 = globf(42) failure_demo.py:240: AssertionError - ____________________________ TestMoreErrors.test_instance ____________________________ + _______________________ TestMoreErrors.test_instance _______________________ self = @@ -577,7 +577,7 @@ get on the terminal - we are working on that): E + where 42 = .x failure_demo.py:244: AssertionError - ____________________________ TestMoreErrors.test_compare _____________________________ + _______________________ TestMoreErrors.test_compare ________________________ self = @@ -587,7 +587,7 @@ get on the terminal - we are working on that): E + where 11 = globf(10) failure_demo.py:247: AssertionError - __________________________ TestMoreErrors.test_try_finally ___________________________ + _____________________ TestMoreErrors.test_try_finally ______________________ self = @@ -598,7 +598,7 @@ get on the terminal - we are working on that): E assert 1 == 0 failure_demo.py:252: AssertionError - ________________________ TestCustomAssertMsg.test_single_line ________________________ + ___________________ TestCustomAssertMsg.test_single_line ___________________ self = @@ -613,7 +613,7 @@ get on the terminal - we are working on that): E + where 1 = .A'>.a failure_demo.py:263: AssertionError - _________________________ TestCustomAssertMsg.test_multiline _________________________ + ____________________ TestCustomAssertMsg.test_multiline ____________________ self = @@ -632,7 +632,7 @@ get on the terminal - we are working on that): E + where 1 = .A'>.a failure_demo.py:270: AssertionError - ________________________ TestCustomAssertMsg.test_custom_repr ________________________ + ___________________ TestCustomAssertMsg.test_custom_repr ___________________ self = @@ -654,4 +654,4 @@ get on the terminal - we are working on that): E + where 1 = This is JSON\n{\n 'foo': 'bar'\n}.a failure_demo.py:283: AssertionError - ============================= 44 failed in 0.12 seconds ============================== + ======================== 44 failed in 0.12 seconds ========================= diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 26d5d6c4b..6d06856d1 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -48,9 +48,9 @@ Let's run this without supplying our new option: .. code-block:: pytest $ pytest -q test_sample.py - F [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_answer _____________________________________ + F [100%] + ================================= FAILURES ================================= + _______________________________ test_answer ________________________________ cmdopt = 'type1' @@ -63,7 +63,7 @@ Let's run this without supplying our new option: E assert 0 test_sample.py:6: AssertionError - -------------------------------- Captured stdout call -------------------------------- + --------------------------- Captured stdout call --------------------------- first 1 failed in 0.12 seconds @@ -72,9 +72,9 @@ And now with supplying a command line option: .. code-block:: pytest $ pytest -q --cmdopt=type2 - F [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_answer _____________________________________ + F [100%] + ================================= FAILURES ================================= + _______________________________ test_answer ________________________________ cmdopt = 'type2' @@ -87,7 +87,7 @@ And now with supplying a command line option: E assert 0 test_sample.py:6: AssertionError - -------------------------------- Captured stdout call -------------------------------- + --------------------------- Captured stdout call --------------------------- second 1 failed in 0.12 seconds @@ -126,14 +126,14 @@ directory with the above conftest.py: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 0 items - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= .. _`excontrolskip`: @@ -188,34 +188,34 @@ and when running it will see a skipped "slow" test: .. code-block:: pytest $ pytest -rs # "-rs" means report details on the little 's' - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py .s [100%] - ============================== short test summary info =============================== + test_module.py .s [100%] + ========================= short test summary info ========================== SKIP [1] test_module.py:8: need --runslow option to run - ======================== 1 passed, 1 skipped in 0.12 seconds ========================= + =================== 1 passed, 1 skipped in 0.12 seconds ==================== Or run it including the ``slow`` marked test: .. code-block:: pytest $ pytest --runslow - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py .. [100%] + test_module.py .. [100%] - ============================== 2 passed in 0.12 seconds ============================== + ========================= 2 passed in 0.12 seconds ========================= Writing well integrated assertion helpers -------------------------------------------------- @@ -251,9 +251,9 @@ Let's run our little function: .. code-block:: pytest $ pytest -q test_checkconfig.py - F [100%] - ====================================== FAILURES ====================================== - ___________________________________ test_something ___________________________________ + F [100%] + ================================= FAILURES ================================= + ______________________________ test_something ______________________________ def test_something(): > checkconfig(42) @@ -350,7 +350,7 @@ which will add the string to the test header accordingly: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') project deps: mylib-1.1 @@ -358,7 +358,7 @@ which will add the string to the test header accordingly: plugins: hypothesis-3.x.y collected 0 items - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= .. regendoc:wipe @@ -380,7 +380,7 @@ which will add info only when run with "--v": .. code-block:: pytest $ pytest -v - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -390,21 +390,21 @@ which will add info only when run with "--v": plugins: hypothesis-3.x.y collecting ... collected 0 items - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= and nothing when run plainly: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 0 items - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= profiling test duration -------------------------- @@ -438,20 +438,20 @@ Now we can profile which test functions execute the slowest: .. code-block:: pytest $ pytest --durations=3 - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 3 items - test_some_are_slow.py ... [100%] + test_some_are_slow.py ... [100%] - ============================== slowest 3 test durations ============================== + ========================= slowest 3 test durations ========================= 0.30s call test_some_are_slow.py::test_funcslow2 0.20s call test_some_are_slow.py::test_funcslow1 0.10s call test_some_are_slow.py::test_funcfast - ============================== 3 passed in 0.12 seconds ============================== + ========================= 3 passed in 0.12 seconds ========================= incremental testing - test steps --------------------------------------------------- @@ -514,17 +514,17 @@ If we run this: .. code-block:: pytest $ pytest -rx - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 4 items - test_step.py .Fx. [100%] + test_step.py .Fx. [100%] - ====================================== FAILURES ====================================== - _________________________ TestUserHandling.test_modification _________________________ + ================================= FAILURES ================================= + ____________________ TestUserHandling.test_modification ____________________ self = @@ -533,10 +533,10 @@ If we run this: E assert 0 test_step.py:11: AssertionError - ============================== short test summary info =============================== + ========================= short test summary info ========================== XFAIL test_step.py::TestUserHandling::test_deletion reason: previous test failed (test_modification) - =================== 1 failed, 2 passed, 1 xfailed in 0.12 seconds ==================== + ============== 1 failed, 2 passed, 1 xfailed in 0.12 seconds =============== We'll see that ``test_deletion`` was not executed because ``test_modification`` failed. It is reported as an "expected failure". @@ -599,20 +599,20 @@ We can run this: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 7 items - test_step.py .Fx. [ 57%] - a/test_db.py F [ 71%] - a/test_db2.py F [ 85%] - b/test_error.py E [100%] + test_step.py .Fx. [ 57%] + a/test_db.py F [ 71%] + a/test_db2.py F [ 85%] + b/test_error.py E [100%] - ======================================= ERRORS ======================================= - ____________________________ ERROR at setup of test_root _____________________________ + ================================== ERRORS ================================== + _______________________ ERROR at setup of test_root ________________________ file $REGENDOC_TMPDIR/b/test_error.py, line 1 def test_root(db): # no db here, will error out E fixture 'db' not found @@ -620,8 +620,8 @@ We can run this: > use 'pytest --fixtures [testpath]' for help on them. $REGENDOC_TMPDIR/b/test_error.py:1 - ====================================== FAILURES ====================================== - _________________________ TestUserHandling.test_modification _________________________ + ================================= FAILURES ================================= + ____________________ TestUserHandling.test_modification ____________________ self = @@ -630,7 +630,7 @@ We can run this: E assert 0 test_step.py:11: AssertionError - ______________________________________ test_a1 _______________________________________ + _________________________________ test_a1 __________________________________ db = @@ -640,7 +640,7 @@ We can run this: E assert 0 a/test_db.py:2: AssertionError - ______________________________________ test_a2 _______________________________________ + _________________________________ test_a2 __________________________________ db = @@ -650,7 +650,7 @@ We can run this: E assert 0 a/test_db2.py:2: AssertionError - =============== 3 failed, 2 passed, 1 xfailed, 1 error in 0.12 seconds =============== + ========== 3 failed, 2 passed, 1 xfailed, 1 error in 0.12 seconds ========== The two test modules in the ``a`` directory see the same ``db`` fixture instance while the one test in the sister-directory ``b`` doesn't see it. We could of course @@ -714,17 +714,17 @@ and run them: .. code-block:: pytest $ pytest test_module.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py FF [100%] + test_module.py FF [100%] - ====================================== FAILURES ====================================== - _____________________________________ test_fail1 _____________________________________ + ================================= FAILURES ================================= + ________________________________ test_fail1 ________________________________ tmpdir = local('PYTEST_TMPDIR/test_fail10') @@ -733,14 +733,14 @@ and run them: E assert 0 test_module.py:2: AssertionError - _____________________________________ test_fail2 _____________________________________ + ________________________________ test_fail2 ________________________________ def test_fail2(): > assert 0 E assert 0 test_module.py:6: AssertionError - ============================== 2 failed in 0.12 seconds ============================== + ========================= 2 failed in 0.12 seconds ========================= you will have a "failures" file which contains the failing test ids:: @@ -817,7 +817,7 @@ and run it: .. code-block:: pytest $ pytest -s test_module.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -828,8 +828,8 @@ and run it: Fexecuting test failed test_module.py::test_call_fails F - ======================================= ERRORS ======================================= - _________________________ ERROR at setup of test_setup_fails _________________________ + ================================== ERRORS ================================== + ____________________ ERROR at setup of test_setup_fails ____________________ @pytest.fixture def other(): @@ -837,8 +837,8 @@ and run it: E assert 0 test_module.py:7: AssertionError - ====================================== FAILURES ====================================== - __________________________________ test_call_fails ___________________________________ + ================================= FAILURES ================================= + _____________________________ test_call_fails ______________________________ something = None @@ -847,14 +847,14 @@ and run it: E assert 0 test_module.py:15: AssertionError - _____________________________________ test_fail2 _____________________________________ + ________________________________ test_fail2 ________________________________ def test_fail2(): > assert 0 E assert 0 test_module.py:19: AssertionError - ========================= 2 failed, 1 error in 0.12 seconds ========================== + ==================== 2 failed, 1 error in 0.12 seconds ===================== You'll see that the fixture finalizers could use the precise reporting information. diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 6aed3ca08..9f13875d5 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -71,17 +71,17 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: .. code-block:: pytest $ pytest test_smtpsimple.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_smtpsimple.py F [100%] + test_smtpsimple.py F [100%] - ====================================== FAILURES ====================================== - _____________________________________ test_ehlo ______________________________________ + ================================= FAILURES ================================= + ________________________________ test_ehlo _________________________________ smtp_connection = @@ -92,7 +92,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: E assert 0 test_smtpsimple.py:11: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= In the failure traceback we see that the test function was called with a ``smtp_connection`` argument, the ``smtplib.SMTP()`` instance created by the fixture @@ -213,17 +213,17 @@ inspect what is going on and can now run the tests: .. code-block:: pytest $ pytest test_module.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_module.py FF [100%] + test_module.py FF [100%] - ====================================== FAILURES ====================================== - _____________________________________ test_ehlo ______________________________________ + ================================= FAILURES ================================= + ________________________________ test_ehlo _________________________________ smtp_connection = @@ -235,7 +235,7 @@ inspect what is going on and can now run the tests: E assert 0 test_module.py:6: AssertionError - _____________________________________ test_noop ______________________________________ + ________________________________ test_noop _________________________________ smtp_connection = @@ -246,7 +246,7 @@ inspect what is going on and can now run the tests: E assert 0 test_module.py:11: AssertionError - ============================== 2 failed in 0.12 seconds ============================== + ========================= 2 failed in 0.12 seconds ========================= You see the two ``assert 0`` failing and more importantly you can also see that the same (module-scoped) ``smtp_connection`` object was passed into the @@ -495,14 +495,14 @@ Running it: .. code-block:: pytest $ pytest -qq --tb=short test_anothersmtp.py - F [100%] - ====================================== FAILURES ====================================== - ___________________________________ test_showhelo ____________________________________ + F [100%] + ================================= FAILURES ================================= + ______________________________ test_showhelo _______________________________ test_anothersmtp.py:5: in test_showhelo assert 0, smtp_connection.helo() E AssertionError: (250, b'mail.python.org') E assert 0 - ------------------------------ Captured stdout teardown ------------------------------ + ------------------------- Captured stdout teardown ------------------------- finalizing (mail.python.org) voila! The ``smtp_connection`` fixture function picked up our mail server name @@ -599,9 +599,9 @@ So let's just do another run: .. code-block:: pytest $ pytest -q test_module.py - FFFF [100%] - ====================================== FAILURES ====================================== - _____________________________ test_ehlo[smtp.gmail.com] ______________________________ + FFFF [100%] + ================================= FAILURES ================================= + ________________________ test_ehlo[smtp.gmail.com] _________________________ smtp_connection = @@ -613,7 +613,7 @@ So let's just do another run: E assert 0 test_module.py:6: AssertionError - _____________________________ test_noop[smtp.gmail.com] ______________________________ + ________________________ test_noop[smtp.gmail.com] _________________________ smtp_connection = @@ -624,7 +624,7 @@ So let's just do another run: E assert 0 test_module.py:11: AssertionError - _____________________________ test_ehlo[mail.python.org] _____________________________ + ________________________ test_ehlo[mail.python.org] ________________________ smtp_connection = @@ -635,9 +635,9 @@ So let's just do another run: E AssertionError: assert b'smtp.gmail.com' in b'mail.python.org\nPIPELINING\nSIZE 51200000\nETRN\nSTARTTLS\nAUTH DIGEST-MD5 NTLM CRAM-MD5\nENHANCEDSTATUSCODES\n8BITMIME\nDSN\nSMTPUTF8\nCHUNKING' test_module.py:5: AssertionError - ------------------------------- Captured stdout setup -------------------------------- + -------------------------- Captured stdout setup --------------------------- finalizing - _____________________________ test_noop[mail.python.org] _____________________________ + ________________________ test_noop[mail.python.org] ________________________ smtp_connection = @@ -648,7 +648,7 @@ So let's just do another run: E assert 0 test_module.py:11: AssertionError - ------------------------------ Captured stdout teardown ------------------------------ + ------------------------- Captured stdout teardown ------------------------- finalizing 4 failed in 0.12 seconds @@ -703,7 +703,7 @@ Running the above tests results in the following test IDs being used: .. code-block:: pytest $ pytest --collect-only - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: @@ -723,7 +723,7 @@ Running the above tests results in the following test IDs being used: - ============================ no tests ran in 0.12 seconds ============================ + ======================= no tests ran in 0.12 seconds ======================= .. _`fixture-parametrize-marks`: @@ -749,7 +749,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: .. code-block:: pytest $ pytest test_fixture_marks.py -v - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -757,11 +757,11 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: plugins: hypothesis-3.x.y collecting ... collected 3 items - test_fixture_marks.py::test_data[0] PASSED [ 33%] - test_fixture_marks.py::test_data[1] PASSED [ 66%] - test_fixture_marks.py::test_data[2] SKIPPED [100%] + test_fixture_marks.py::test_data[0] PASSED [ 33%] + test_fixture_marks.py::test_data[1] PASSED [ 66%] + test_fixture_marks.py::test_data[2] SKIPPED [100%] - ======================== 2 passed, 1 skipped in 0.12 seconds ========================= + =================== 2 passed, 1 skipped in 0.12 seconds ==================== .. _`interdependent fixtures`: @@ -796,7 +796,7 @@ Here we declare an ``app`` fixture which receives the previously defined .. code-block:: pytest $ pytest -v test_appsetup.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -804,10 +804,10 @@ Here we declare an ``app`` fixture which receives the previously defined plugins: hypothesis-3.x.y collecting ... collected 2 items - test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] - test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%] + test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] + test_appsetup.py::test_smtp_connection_exists[mail.python.org] PASSED [100%] - ============================== 2 passed in 0.12 seconds ============================== + ========================= 2 passed in 0.12 seconds ========================= Due to the parametrization of ``smtp_connection``, the test will run twice with two different ``App`` instances and respective smtp servers. There is no @@ -869,7 +869,7 @@ Let's run the tests in verbose mode and with looking at the print-output: .. code-block:: pytest $ pytest -v -s test_module.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') @@ -910,7 +910,7 @@ Let's run the tests in verbose mode and with looking at the print-output: TEARDOWN modarg mod2 - ============================== 8 passed in 0.12 seconds ============================== + ========================= 8 passed in 0.12 seconds ========================= You can see that the parametrized module-scoped ``modarg`` resource caused an ordering of test execution that lead to the fewest possible "active" resources. @@ -975,7 +975,7 @@ to verify our fixture is activated and the tests pass: .. code-block:: pytest $ pytest -q - .. [100%] + .. [100%] 2 passed in 0.12 seconds You can specify multiple fixtures like this: @@ -1076,7 +1076,7 @@ If we run it, we get two passing tests: .. code-block:: pytest $ pytest -q - .. [100%] + .. [100%] 2 passed in 0.12 seconds Here is how autouse fixtures work in other scopes: diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index 31910fa02..cf94b93f4 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -47,17 +47,17 @@ That’s it. You can now execute the test function: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_sample.py F [100%] + test_sample.py F [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_answer _____________________________________ + ================================= FAILURES ================================= + _______________________________ test_answer ________________________________ def test_answer(): > assert func(3) == 5 @@ -65,7 +65,7 @@ That’s it. You can now execute the test function: E + where 4 = func(3) test_sample.py:5: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= This test returns a failure report because ``func(3)`` does not return ``5``. @@ -98,7 +98,7 @@ Execute the test function with “quiet” reporting mode: .. code-block:: pytest $ pytest -q test_sysexit.py - . [100%] + . [100%] 1 passed in 0.12 seconds Group multiple tests in a class @@ -121,9 +121,9 @@ Once you develop multiple tests, you may want to group them into a class. pytest .. code-block:: pytest $ pytest -q test_class.py - .F [100%] - ====================================== FAILURES ====================================== - _________________________________ TestClass.test_two _________________________________ + .F [100%] + ================================= FAILURES ================================= + ____________________________ TestClass.test_two ____________________________ self = @@ -153,9 +153,9 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look .. code-block:: pytest $ pytest -q test_tmpdir.py - F [100%] - ====================================== FAILURES ====================================== - __________________________________ test_needsfiles ___________________________________ + F [100%] + ================================= FAILURES ================================= + _____________________________ test_needsfiles ______________________________ tmpdir = local('PYTEST_TMPDIR/test_needsfiles0') @@ -165,7 +165,7 @@ List the name ``tmpdir`` in the test function signature and ``pytest`` will look E assert 0 test_tmpdir.py:3: AssertionError - -------------------------------- Captured stdout call -------------------------------- + --------------------------- Captured stdout call --------------------------- PYTEST_TMPDIR/test_needsfiles0 1 failed in 0.12 seconds diff --git a/doc/en/index.rst b/doc/en/index.rst index 3c9cb0241..414503e17 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -27,17 +27,17 @@ To execute it: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_sample.py F [100%] + test_sample.py F [100%] - ====================================== FAILURES ====================================== - ____________________________________ test_answer _____________________________________ + ================================= FAILURES ================================= + _______________________________ test_answer ________________________________ def test_answer(): > assert inc(3) == 5 @@ -45,7 +45,7 @@ To execute it: E + where 4 = inc(3) test_sample.py:6: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See :ref:`Getting Started ` for more examples. diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 0808b08df..500c5619f 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -55,17 +55,17 @@ them in turn: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 3 items - test_expectation.py ..F [100%] + test_expectation.py ..F [100%] - ====================================== FAILURES ====================================== - _________________________________ test_eval[6*9-42] __________________________________ + ================================= FAILURES ================================= + ____________________________ test_eval[6*9-42] _____________________________ test_input = '6*9', expected = 42 @@ -80,7 +80,7 @@ them in turn: E + where 54 = eval('6*9') test_expectation.py:8: AssertionError - ========================= 1 failed, 2 passed in 0.12 seconds ========================= + ==================== 1 failed, 2 passed in 0.12 seconds ==================== As designed in this example, only one pair of input/output values fails the simple test function. And as usual with test function arguments, @@ -108,16 +108,16 @@ Let's run this: .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 3 items - test_expectation.py ..x [100%] + test_expectation.py ..x [100%] - ======================== 2 passed, 1 xfailed in 0.12 seconds ========================= + =================== 2 passed, 1 xfailed in 0.12 seconds ==================== The one parameter set which caused a failure previously now shows up as an "xfailed (expected to fail)" test. @@ -177,7 +177,7 @@ command line option and the parametrization of our test function:: If we now pass two stringinput values, our test will run twice:: $ pytest -q --stringinput="hello" --stringinput="world" test_strings.py - .. [100%] + .. [100%] 2 passed in 0.12 seconds Let's also run with a stringinput that will lead to a failing test: @@ -185,9 +185,9 @@ Let's also run with a stringinput that will lead to a failing test: .. code-block:: pytest $ pytest -q --stringinput="!" test_strings.py - F [100%] - ====================================== FAILURES ====================================== - ________________________________ test_valid_string[!] ________________________________ + F [100%] + ================================= FAILURES ================================= + ___________________________ test_valid_string[!] ___________________________ stringinput = '!' @@ -209,8 +209,8 @@ list: .. code-block:: pytest $ pytest -q -rs test_strings.py - s [100%] - ============================== short test summary info =============================== + s [100%] + ========================= short test summary info ========================== SKIP [1] test_strings.py: got empty parameter set ['stringinput'], function test_valid_string at $REGENDOC_TMPDIR/test_strings.py:1 1 skipped in 0.12 seconds diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index 0f2073090..978f4dc5c 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -328,15 +328,15 @@ Running it with the report-on-xfail option gives this output: .. code-block:: pytest example $ pytest -rx xfail_demo.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/example/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/example, inifile: plugins: hypothesis-3.x.y collected 7 items - xfail_demo.py xxxxxxx [100%] - ============================== short test summary info =============================== + xfail_demo.py xxxxxxx [100%] + ========================= short test summary info ========================== XFAIL xfail_demo.py::test_hello XFAIL xfail_demo.py::test_hello2 reason: [NOTRUN] @@ -350,7 +350,7 @@ Running it with the report-on-xfail option gives this output: reason: reason XFAIL xfail_demo.py::test_hello7 - ============================= 7 xfailed in 0.12 seconds ============================== + ======================== 7 xfailed in 0.12 seconds ========================= .. _`skip/xfail with parametrize`: diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index 5f7e98a84..7db848280 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -40,17 +40,17 @@ Running this would result in a passed test except for the last .. code-block:: pytest $ pytest test_tmp_path.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_tmp_path.py F [100%] + test_tmp_path.py F [100%] - ====================================== FAILURES ====================================== - __________________________________ test_create_file __________________________________ + ================================= FAILURES ================================= + _____________________________ test_create_file _____________________________ tmp_path = PosixPath('PYTEST_TMPDIR/test_create_file0') @@ -65,7 +65,7 @@ Running this would result in a passed test except for the last E assert 0 test_tmp_path.py:13: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= The ``tmp_path_factory`` fixture -------------------------------- @@ -104,17 +104,17 @@ Running this would result in a passed test except for the last .. code-block:: pytest $ pytest test_tmpdir.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_tmpdir.py F [100%] + test_tmpdir.py F [100%] - ====================================== FAILURES ====================================== - __________________________________ test_create_file __________________________________ + ================================= FAILURES ================================= + _____________________________ test_create_file _____________________________ tmpdir = local('PYTEST_TMPDIR/test_create_file0') @@ -127,7 +127,7 @@ Running this would result in a passed test except for the last E assert 0 test_tmpdir.py:7: AssertionError - ============================== 1 failed in 0.12 seconds ============================== + ========================= 1 failed in 0.12 seconds ========================= .. _`tmpdir factory example`: diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index fe7f2e550..ff4e73a96 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -127,17 +127,17 @@ the ``self.db`` values in the traceback: .. code-block:: pytest $ pytest test_unittest_db.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 2 items - test_unittest_db.py FF [100%] + test_unittest_db.py FF [100%] - ====================================== FAILURES ====================================== - ________________________________ MyTest.test_method1 _________________________________ + ================================= FAILURES ================================= + ___________________________ MyTest.test_method1 ____________________________ self = @@ -148,7 +148,7 @@ the ``self.db`` values in the traceback: E assert 0 test_unittest_db.py:9: AssertionError - ________________________________ MyTest.test_method2 _________________________________ + ___________________________ MyTest.test_method2 ____________________________ self = @@ -158,7 +158,7 @@ the ``self.db`` values in the traceback: E assert 0 test_unittest_db.py:12: AssertionError - ============================== 2 failed in 0.12 seconds ============================== + ========================= 2 failed in 0.12 seconds ========================= This default pytest traceback shows that the two test methods share the same ``self.db`` instance which was our intention @@ -208,7 +208,7 @@ Running this test module ...: .. code-block:: pytest $ pytest -q test_unittest_cleandir.py - . [100%] + . [100%] 1 passed in 0.12 seconds ... gives us one passed test because the ``initdir`` fixture function diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 2a2d972c0..9fa3d6456 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -191,14 +191,40 @@ Example: .. code-block:: pytest $ pytest -ra - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y - collected 0 items + collected 6 items - ============================ no tests ran in 0.12 seconds ============================ + test_example.py .FEsxX [100%] + + ================================== ERRORS ================================== + _______________________ ERROR at setup of test_error _______________________ + + @pytest.fixture + def error_fixture(): + > assert 0 + E assert 0 + + test_example.py:6: AssertionError + ================================= FAILURES ================================= + ________________________________ test_fail _________________________________ + + def test_fail(): + > assert 0 + E assert 0 + + test_example.py:14: AssertionError + ========================= short test summary info ========================== + SKIP [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test + XFAIL test_example.py::test_xfail + reason: xfailing this test + XPASS test_example.py::test_xpass always xfail + ERROR test_example.py::test_error + FAIL test_example.py::test_fail + 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds The ``-r`` options accepts a number of characters after it, with ``a`` used above meaning "all except passes". @@ -218,14 +244,36 @@ More than one character can be used, so for example to only see failed and skipp .. code-block:: pytest $ pytest -rfs - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y - collected 0 items + collected 6 items - ============================ no tests ran in 0.12 seconds ============================ + test_example.py .FEsxX [100%] + + ================================== ERRORS ================================== + _______________________ ERROR at setup of test_error _______________________ + + @pytest.fixture + def error_fixture(): + > assert 0 + E assert 0 + + test_example.py:6: AssertionError + ================================= FAILURES ================================= + ________________________________ test_fail _________________________________ + + def test_fail(): + > assert 0 + E assert 0 + + test_example.py:14: AssertionError + ========================= short test summary info ========================== + FAIL test_example.py::test_fail + SKIP [1] $REGENDOC_TMPDIR/test_example.py:23: skipping this test + 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds Using ``p`` lists the passing tests, whilst ``P`` adds an extra section "PASSES" with those tests that passed but had captured output: @@ -233,14 +281,39 @@ captured output: .. code-block:: pytest $ pytest -rpP - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y - collected 0 items + collected 6 items - ============================ no tests ran in 0.12 seconds ============================ + test_example.py .FEsxX [100%] + + ================================== ERRORS ================================== + _______________________ ERROR at setup of test_error _______________________ + + @pytest.fixture + def error_fixture(): + > assert 0 + E assert 0 + + test_example.py:6: AssertionError + ================================= FAILURES ================================= + ________________________________ test_fail _________________________________ + + def test_fail(): + > assert 0 + E assert 0 + + test_example.py:14: AssertionError + ========================= short test summary info ========================== + PASSED test_example.py::test_ok + ================================== PASSES ================================== + _________________________________ test_ok __________________________________ + --------------------------- Captured stdout call --------------------------- + ok + 1 failed, 1 passed, 1 skipped, 1 xfailed, 1 xpassed, 1 error in 0.12 seconds .. _pdb-option: @@ -626,8 +699,25 @@ Running it will show that ``MyPlugin`` was added and its hook was invoked:: $ python myinvoke.py - . [100%]*** test run reporting finishing + .FEsxX. [100%]*** test run reporting finishing + ================================== ERRORS ================================== + _______________________ ERROR at setup of test_error _______________________ + + @pytest.fixture + def error_fixture(): + > assert 0 + E assert 0 + + test_example.py:6: AssertionError + ================================= FAILURES ================================= + ________________________________ test_fail _________________________________ + + def test_fail(): + > assert 0 + E assert 0 + + test_example.py:14: AssertionError .. note:: diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 8de555d3c..601459f1c 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -23,22 +23,22 @@ Running pytest now produces this output: .. code-block:: pytest $ pytest test_show_warnings.py - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: plugins: hypothesis-3.x.y collected 1 item - test_show_warnings.py . [100%] + test_show_warnings.py . [100%] - ================================== warnings summary ================================== + ============================= warnings summary ============================= test_show_warnings.py::test_one $REGENDOC_TMPDIR/test_show_warnings.py:4: UserWarning: api v1, should use functions from v2 warnings.warn(UserWarning("api v1, should use functions from v2")) -- Docs: https://docs.pytest.org/en/latest/warnings.html - ======================== 1 passed, 1 warnings in 0.12 seconds ======================== + =================== 1 passed, 1 warnings in 0.12 seconds =================== The ``-W`` flag can be passed to control which warnings will be displayed or even turn them into errors: @@ -46,15 +46,15 @@ them into errors: .. code-block:: pytest $ pytest -q test_show_warnings.py -W error::UserWarning - F [100%] - ====================================== FAILURES ====================================== - ______________________________________ test_one ______________________________________ + F [100%] + ================================= FAILURES ================================= + _________________________________ test_one _________________________________ def test_one(): > assert api_v1() == 1 test_show_warnings.py:8: - _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ def api_v1(): > warnings.warn(UserWarning("api v1, should use functions from v2")) @@ -357,7 +357,7 @@ defines an ``__init__`` constructor, as this prevents the class from being insta $ pytest test_pytest_warnings.py -q - ================================== warnings summary ================================== + ============================= warnings summary ============================= test_pytest_warnings.py:1 $REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestWarning: cannot collect test class 'Test' because it has a __init__ constructor class Test: diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index f627fec05..d23a15e00 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -411,22 +411,22 @@ additionally it is possible to copy examples for an example folder before runnin .. code-block:: pytest $ pytest - ================================ test session starts ================================= + =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini plugins: hypothesis-3.x.y collected 2 items - test_example.py .. [100%] + test_example.py .. [100%] - ================================== warnings summary ================================== + ============================= warnings summary ============================= test_example.py::test_plugin $REGENDOC_TMPDIR/test_example.py:4: PytestExperimentalApiWarning: testdir.copy_example is an experimental api that may change over time testdir.copy_example("test_example.py") -- Docs: https://docs.pytest.org/en/latest/warnings.html - ======================== 2 passed, 1 warnings in 0.12 seconds ======================== + =================== 2 passed, 1 warnings in 0.12 seconds =================== For more information about the result object that ``runpytest()`` returns, and the methods that it provides please check out the :py:class:`RunResult From 99ef8c6d1660365a836e1cf01bf0298009f11490 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 20:31:01 +0000 Subject: [PATCH 10/17] Fix typo in Makefile: PYTEST_ADDOPT -> PYTEST_ADDOPTS --- doc/en/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/Makefile b/doc/en/Makefile index fa8e8266a..f93d84557 100644 --- a/doc/en/Makefile +++ b/doc/en/Makefile @@ -39,7 +39,7 @@ clean: -rm -rf $(BUILDDIR)/* regen: - PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPT=-pno:hypothesis COLUMNS=76 regendoc --update *.rst */*.rst ${REGENDOC_ARGS} + PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS=-pno:hypothesis COLUMNS=76 regendoc --update *.rst */*.rst ${REGENDOC_ARGS} html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html From e24031fb3627ae6c187ea476c99a5f6d90e876f6 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 5 Jan 2019 20:42:44 +0000 Subject: [PATCH 11/17] Regendocs again, without hypothesis --- doc/en/assert.rst | 4 ---- doc/en/cache.rst | 6 ------ doc/en/capture.rst | 2 -- doc/en/doctest.rst | 2 -- doc/en/example/markers.rst | 32 ----------------------------- doc/en/example/nonpython.rst | 6 ------ doc/en/example/parametrize.rst | 14 ------------- doc/en/example/pythoncollection.rst | 6 ------ doc/en/example/reportingdemo.rst | 2 -- doc/en/example/simple.rst | 22 -------------------- doc/en/fixture.rst | 12 ----------- doc/en/getting-started.rst | 4 ---- doc/en/index.rst | 2 -- doc/en/parametrize.rst | 4 ---- doc/en/skipping.rst | 2 -- doc/en/tmpdir.rst | 4 ---- doc/en/unittest.rst | 2 -- doc/en/usage.rst | 6 ------ doc/en/warnings.rst | 2 -- doc/en/writing_plugins.rst | 2 -- 20 files changed, 136 deletions(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 511839d88..b13a071f6 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -29,9 +29,7 @@ you will see the return value of the function call: $ pytest test_assert1.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_assert1.py F [100%] @@ -175,9 +173,7 @@ if you run this module: $ pytest test_assert2.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_assert2.py F [100%] diff --git a/doc/en/cache.rst b/doc/en/cache.rst index caa170027..ba9d87a5f 100644 --- a/doc/en/cache.rst +++ b/doc/en/cache.rst @@ -81,9 +81,7 @@ If you then run it with ``--lf``: $ pytest --lf =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 50 items / 48 deselected run-last-failure: rerun previous 2 failures @@ -126,9 +124,7 @@ of ``FF`` and dots): $ pytest --ff =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 50 items run-last-failure: rerun previous 2 failures first @@ -257,9 +253,7 @@ You can always peek at the content of the cache using the $ pytest --cache-show =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y cachedir: $REGENDOC_TMPDIR/.pytest_cache ------------------------------- cache values ------------------------------- cache/lastfailed contains: diff --git a/doc/en/capture.rst b/doc/en/capture.rst index 7d452b9f9..488b2b874 100644 --- a/doc/en/capture.rst +++ b/doc/en/capture.rst @@ -68,9 +68,7 @@ of the failing function and hide the other one: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py .F [100%] diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 69a9cd18a..125ed3aa7 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -65,9 +65,7 @@ then you can just invoke ``pytest`` without command line options: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - plugins: hypothesis-3.x.y collected 1 item mymodule.py . [100%] diff --git a/doc/en/example/markers.rst b/doc/en/example/markers.rst index 637640062..9d325c30e 100644 --- a/doc/en/example/markers.rst +++ b/doc/en/example/markers.rst @@ -35,9 +35,7 @@ You can then restrict a test run to only run tests marked with ``webtest``: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected test_server.py::test_send_http PASSED [100%] @@ -52,9 +50,7 @@ Or the inverse, running all tests except the webtest ones: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected test_server.py::test_something_quick PASSED [ 33%] @@ -76,9 +72,7 @@ tests based on their module, class, method, or function name: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 1 item test_server.py::TestClass::test_method PASSED [100%] @@ -93,9 +87,7 @@ You can also select on the class: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 1 item test_server.py::TestClass::test_method PASSED [100%] @@ -110,9 +102,7 @@ Or select multiple nodes: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 2 items test_server.py::TestClass::test_method PASSED [ 50%] @@ -152,9 +142,7 @@ select tests based on their names: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 4 items / 3 deselected test_server.py::test_send_http PASSED [100%] @@ -169,9 +157,7 @@ And you can also run all tests except the ones that match the keyword: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 4 items / 1 deselected test_server.py::test_something_quick PASSED [ 33%] @@ -188,9 +174,7 @@ Or to select "http" and "quick" tests: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 4 items / 2 deselected test_server.py::test_send_http PASSED [ 50%] @@ -232,8 +216,6 @@ You can ask which markers exist for your test suite - the list includes our just $ pytest --markers @pytest.mark.webtest: mark a test as a webtest. - @pytest.mark.hypothesis: Tests which use hypothesis. - @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test. @@ -383,9 +365,7 @@ the test needs: $ pytest -E stage2 =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_someenv.py s [100%] @@ -399,9 +379,7 @@ and here is one that specifies exactly the environment needed: $ pytest -E stage1 =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_someenv.py . [100%] @@ -413,8 +391,6 @@ The ``--markers`` option always gives you a list of available markers:: $ pytest --markers @pytest.mark.env(name): mark test to run only on named environment - @pytest.mark.hypothesis: Tests which use hypothesis. - @pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/latest/warnings.html#pytest-mark-filterwarnings @pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test. @@ -570,9 +546,7 @@ then you will see two tests skipped and two executed tests as expected: $ pytest -rs # this option reports skip reasons =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items test_plat.py s.s. [100%] @@ -588,9 +562,7 @@ Note that if you specify a platform via the marker-command line option like this $ pytest -m linux =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items / 3 deselected test_plat.py . [100%] @@ -643,9 +615,7 @@ We can now use the ``-m option`` to select one set: $ pytest -m interface --tb=short =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items / 2 deselected test_module.py FF [100%] @@ -668,9 +638,7 @@ or to select both "event" and "interface" tests: $ pytest -m "interface or event" --tb=short =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items / 1 deselected test_module.py FFF [100%] diff --git a/doc/en/example/nonpython.rst b/doc/en/example/nonpython.rst index 3db466391..eba8279f3 100644 --- a/doc/en/example/nonpython.rst +++ b/doc/en/example/nonpython.rst @@ -30,9 +30,7 @@ now execute the test specification: nonpython $ pytest test_simple.yml =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: - plugins: hypothesis-3.x.y collected 2 items test_simple.yml F. [100%] @@ -67,9 +65,7 @@ consulted when reporting in ``verbose`` mode: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: - plugins: hypothesis-3.x.y collecting ... collected 2 items test_simple.yml::hello FAILED [ 50%] @@ -92,9 +88,7 @@ interesting to just look at the collection tree: nonpython $ pytest --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/nonpython/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/nonpython, inifile: - plugins: hypothesis-3.x.y collected 2 items diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst index 133add2c6..92756e492 100644 --- a/doc/en/example/parametrize.rst +++ b/doc/en/example/parametrize.rst @@ -145,9 +145,7 @@ objects, they are still using the default pytest representation: $ pytest test_time.py --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 8 items @@ -205,9 +203,7 @@ this is a fully self-contained example which you can run with: $ pytest test_scenarios.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items test_scenarios.py .... [100%] @@ -221,9 +217,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia $ pytest --collect-only test_scenarios.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items @@ -289,9 +283,7 @@ Let's first see how it looks like at collection time: $ pytest test_backends.py --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items @@ -356,9 +348,7 @@ The result of this test will be successful: $ pytest test_indirect_list.py --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item @@ -492,9 +482,7 @@ If you run this with reporting for skips enabled: $ pytest -rs test_module.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py .s [100%] @@ -552,9 +540,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 17 items / 14 deselected test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%] diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 53e7cd321..394924e2d 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -132,9 +132,7 @@ The test collection would look like this: $ pytest --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - plugins: hypothesis-3.x.y collected 2 items @@ -189,9 +187,7 @@ You can always peek at the collection tree without running tests like this: . $ pytest --collect-only pythoncollection.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/CWD/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - plugins: hypothesis-3.x.y collected 3 items @@ -263,9 +259,7 @@ file will be left out: $ pytest --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - plugins: hypothesis-3.x.y collected 0 items ======================= no tests ran in 0.12 seconds ======================= diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst index c40e15572..15d71caa0 100644 --- a/doc/en/example/reportingdemo.rst +++ b/doc/en/example/reportingdemo.rst @@ -14,9 +14,7 @@ get on the terminal - we are working on that): assertion $ pytest failure_demo.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/assertion/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/assertion, inifile: - plugins: hypothesis-3.x.y collected 44 items failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%] diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst index 6d06856d1..76a1ddc80 100644 --- a/doc/en/example/simple.rst +++ b/doc/en/example/simple.rst @@ -128,9 +128,7 @@ directory with the above conftest.py: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -190,9 +188,7 @@ and when running it will see a skipped "slow" test: $ pytest -rs # "-rs" means report details on the little 's' =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py .s [100%] @@ -208,9 +204,7 @@ Or run it including the ``slow`` marked test: $ pytest --runslow =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py .. [100%] @@ -352,10 +346,8 @@ which will add the string to the test header accordingly: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') project deps: mylib-1.1 rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -383,11 +375,9 @@ which will add info only when run with "--v": =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') info1: did you know that ... did you? rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -399,9 +389,7 @@ and nothing when run plainly: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 0 items ======================= no tests ran in 0.12 seconds ======================= @@ -440,9 +428,7 @@ Now we can profile which test functions execute the slowest: $ pytest --durations=3 =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 3 items test_some_are_slow.py ... [100%] @@ -516,9 +502,7 @@ If we run this: $ pytest -rx =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 4 items test_step.py .Fx. [100%] @@ -601,9 +585,7 @@ We can run this: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 7 items test_step.py .Fx. [ 57%] @@ -716,9 +698,7 @@ and run them: $ pytest test_module.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py FF [100%] @@ -819,9 +799,7 @@ and run it: $ pytest -s test_module.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 3 items test_module.py Esetting up a test failed! test_module.py::test_setup_fails diff --git a/doc/en/fixture.rst b/doc/en/fixture.rst index 9f13875d5..4dd68f8e4 100644 --- a/doc/en/fixture.rst +++ b/doc/en/fixture.rst @@ -73,9 +73,7 @@ marked ``smtp_connection`` fixture function. Running the test looks like this: $ pytest test_smtpsimple.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_smtpsimple.py F [100%] @@ -215,9 +213,7 @@ inspect what is going on and can now run the tests: $ pytest test_module.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_module.py FF [100%] @@ -705,9 +701,7 @@ Running the above tests results in the following test IDs being used: $ pytest --collect-only =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 10 items @@ -752,9 +746,7 @@ Running this test will *skip* the invocation of ``data_set`` with value ``2``: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 3 items test_fixture_marks.py::test_data[0] PASSED [ 33%] @@ -799,9 +791,7 @@ Here we declare an ``app`` fixture which receives the previously defined =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 2 items test_appsetup.py::test_smtp_connection_exists[smtp.gmail.com] PASSED [ 50%] @@ -872,9 +862,7 @@ Let's run the tests in verbose mode and with looking at the print-output: =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python3.6 cachedir: .pytest_cache - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collecting ... collected 8 items test_module.py::test_0[1] SETUP otherarg 1 diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst index cf94b93f4..500fc3d93 100644 --- a/doc/en/getting-started.rst +++ b/doc/en/getting-started.rst @@ -25,8 +25,6 @@ Install ``pytest`` $ pytest --version This is pytest version 4.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py - setuptools registered plugins: - hypothesis-3.x.y at $PYTHON_PREFIX/lib/python3.6/site-packages/hypothesis/extra/pytestplugin.py .. _`simpletest`: @@ -49,9 +47,7 @@ That’s it. You can now execute the test function: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_sample.py F [100%] diff --git a/doc/en/index.rst b/doc/en/index.rst index 414503e17..7c201fbd7 100644 --- a/doc/en/index.rst +++ b/doc/en/index.rst @@ -29,9 +29,7 @@ To execute it: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_sample.py F [100%] diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 500c5619f..099b531c2 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -57,9 +57,7 @@ them in turn: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 3 items test_expectation.py ..F [100%] @@ -110,9 +108,7 @@ Let's run this: $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 3 items test_expectation.py ..x [100%] diff --git a/doc/en/skipping.rst b/doc/en/skipping.rst index 978f4dc5c..ae1dc7149 100644 --- a/doc/en/skipping.rst +++ b/doc/en/skipping.rst @@ -330,9 +330,7 @@ Running it with the report-on-xfail option gives this output: example $ pytest -rx xfail_demo.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/example/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR/example, inifile: - plugins: hypothesis-3.x.y collected 7 items xfail_demo.py xxxxxxx [100%] diff --git a/doc/en/tmpdir.rst b/doc/en/tmpdir.rst index 7db848280..8c21e17e5 100644 --- a/doc/en/tmpdir.rst +++ b/doc/en/tmpdir.rst @@ -42,9 +42,7 @@ Running this would result in a passed test except for the last $ pytest test_tmp_path.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_tmp_path.py F [100%] @@ -106,9 +104,7 @@ Running this would result in a passed test except for the last $ pytest test_tmpdir.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_tmpdir.py F [100%] diff --git a/doc/en/unittest.rst b/doc/en/unittest.rst index ff4e73a96..34c8a35db 100644 --- a/doc/en/unittest.rst +++ b/doc/en/unittest.rst @@ -129,9 +129,7 @@ the ``self.db`` values in the traceback: $ pytest test_unittest_db.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 2 items test_unittest_db.py FF [100%] diff --git a/doc/en/usage.rst b/doc/en/usage.rst index 9fa3d6456..3ff6a0dd5 100644 --- a/doc/en/usage.rst +++ b/doc/en/usage.rst @@ -193,9 +193,7 @@ Example: $ pytest -ra =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 6 items test_example.py .FEsxX [100%] @@ -246,9 +244,7 @@ More than one character can be used, so for example to only see failed and skipp $ pytest -rfs =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 6 items test_example.py .FEsxX [100%] @@ -283,9 +279,7 @@ captured output: $ pytest -rpP =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 6 items test_example.py .FEsxX [100%] diff --git a/doc/en/warnings.rst b/doc/en/warnings.rst index 601459f1c..3e69d3480 100644 --- a/doc/en/warnings.rst +++ b/doc/en/warnings.rst @@ -25,9 +25,7 @@ Running pytest now produces this output: $ pytest test_show_warnings.py =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: - plugins: hypothesis-3.x.y collected 1 item test_show_warnings.py . [100%] diff --git a/doc/en/writing_plugins.rst b/doc/en/writing_plugins.rst index d23a15e00..70bf315aa 100644 --- a/doc/en/writing_plugins.rst +++ b/doc/en/writing_plugins.rst @@ -413,9 +413,7 @@ additionally it is possible to copy examples for an example folder before runnin $ pytest =========================== test session starts ============================ platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y - hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('$REGENDOC_TMPDIR/.hypothesis/examples') rootdir: $REGENDOC_TMPDIR, inifile: pytest.ini - plugins: hypothesis-3.x.y collected 2 items test_example.py .. [100%] From 4f38c610c30084cfb8b21fd972759235fc1077e5 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sun, 6 Jan 2019 07:49:40 -0800 Subject: [PATCH 12/17] Uninstall hypothesis in regen tox env --- changelog/4602.trivial.rst | 1 + tox.ini | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 changelog/4602.trivial.rst diff --git a/changelog/4602.trivial.rst b/changelog/4602.trivial.rst new file mode 100644 index 000000000..619b40601 --- /dev/null +++ b/changelog/4602.trivial.rst @@ -0,0 +1 @@ +Uninstall ``hypothesis`` in regen tox env. diff --git a/tox.ini b/tox.ini index 3d5c2fd56..7cb430223 100644 --- a/tox.ini +++ b/tox.ini @@ -153,6 +153,8 @@ whitelist_externals = rm make commands = + # don't show hypothesis plugin info in docs, see #4602 + pip uninstall hypothesis -y rm -rf /tmp/doc-exec* make regen From 948a5d5ac674b6db1d8df30072fad28ef2809381 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Wed, 9 Jan 2019 12:31:26 +0100 Subject: [PATCH 13/17] Added test for Issue 4617 --- testing/test_warnings.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testing/test_warnings.py b/testing/test_warnings.py index 3bac9a545..45e196149 100644 --- a/testing/test_warnings.py +++ b/testing/test_warnings.py @@ -683,3 +683,27 @@ class TestAssertionWarnings: self.create_file(testdir, False) result = testdir.runpytest() result.stdout.fnmatch_lines(["*1 failed in*"]) + + +def test_warningschecker_twice(testdir): + """Issue #4617""" + + testdir.makepyfile( + """ + import pytest + import warnings + + @pytest.mark.parametrize("other", [1, 2]) + @pytest.mark.parametrize("expectation", [ + pytest.warns(DeprecationWarning, + match="Message A"), + pytest.warns(DeprecationWarning, + match="Message A"), + ]) + def test_parametrized_warnings(other, expectation): + with expectation: + warnings.warn("Message A", DeprecationWarning) + """ + ) + result = testdir.runpytest() + result.stdout.fnmatch_lines(["* 4 passed in *"]) From df3b5557d176744967e1fef42c25c765794d2a32 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Wed, 9 Jan 2019 12:51:04 +0100 Subject: [PATCH 14/17] Reseting entered state in WarningsRecorder (fixes 4617) --- src/_pytest/recwarn.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index f39f7aee7..da408a892 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -192,6 +192,10 @@ class WarningsRecorder(warnings.catch_warnings): warnings.warn = self._saved_warn super(WarningsRecorder, self).__exit__(*exc_info) + # Built-in catch_warnings does not reset entered state so we do it + # manually here for this context manager to become reusable + self._entered = False + class WarningsChecker(WarningsRecorder): def __init__(self, expected_warning=None, match_expr=None): From fe4835c15e9164e346c885228a519b2f4fa64a70 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Wed, 9 Jan 2019 12:55:15 +0100 Subject: [PATCH 15/17] Added changelog entry. --- changelog/4617.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/4617.bugfix.rst diff --git a/changelog/4617.bugfix.rst b/changelog/4617.bugfix.rst new file mode 100644 index 000000000..048cd60be --- /dev/null +++ b/changelog/4617.bugfix.rst @@ -0,0 +1 @@ +Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization). \ No newline at end of file From 081accb62cea86164019c3df87f448f3b846a2d1 Mon Sep 17 00:00:00 2001 From: Victor Maryama Date: Wed, 9 Jan 2019 13:11:22 +0100 Subject: [PATCH 16/17] Fixed linting in changelog. --- changelog/4617.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/4617.bugfix.rst b/changelog/4617.bugfix.rst index 048cd60be..166378efd 100644 --- a/changelog/4617.bugfix.rst +++ b/changelog/4617.bugfix.rst @@ -1 +1 @@ -Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization). \ No newline at end of file +Fixed ``pytest.warns`` bug when context manager is reused (e.g. multiple parametrization). From 7ee03e0996d61099c594cf3f7046ee2ff4d30ee1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 9 Jan 2019 15:35:52 +0100 Subject: [PATCH 17/17] Punctuation [ci skip] --- src/_pytest/recwarn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/_pytest/recwarn.py b/src/_pytest/recwarn.py index da408a892..a58c75d3a 100644 --- a/src/_pytest/recwarn.py +++ b/src/_pytest/recwarn.py @@ -193,7 +193,7 @@ class WarningsRecorder(warnings.catch_warnings): super(WarningsRecorder, self).__exit__(*exc_info) # Built-in catch_warnings does not reset entered state so we do it - # manually here for this context manager to become reusable + # manually here for this context manager to become reusable. self._entered = False