Compare commits

...

1164 Commits
4.6.7 ... 5.3.3

Author SHA1 Message Date
Bruno Oliveira
544b4a14d5 Fix Hugo van Kemenade name in release announcement
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-01-17 07:18:57 -03:00
Bruno Oliveira
56dc301c50 Preparing release version 5.3.3 2020-01-16 18:55:41 -05:00
Bruno Oliveira
aa05334984 Remove broken link for user @jgsonesen 2020-01-16 18:51:33 -05:00
Bruno Oliveira
4806878a7f Drop deploy from Travis in favor of GitHub actions (#6480)
Drop deploy from Travis in favor of GitHub actions
2020-01-16 18:34:44 -03:00
Bruno Oliveira
d1d7e5d41b Drop deploy from Travis in favor of GitHub actions
GitHub actions already should deploy.

This is a stop gap while we figure out why coverage dropped
when removing Travis builds in #6470
2020-01-16 18:12:47 -03:00
Daniel Hahler
5b0e255e85 Merge pull request #6465 from blueyed/doc-rootdir
doc: revisit section about rootdir
2020-01-16 21:55:12 +01:00
Daniel Hahler
f0fdafeddc Merge pull request #6477 from blueyed/tests-cleanup-unused-fixtures
tests: cleanup unused fixtures
2020-01-16 21:53:56 +01:00
Daniel Hahler
5049e25a6a tests: cleanup unused fixtures 2020-01-16 21:12:48 +01:00
Daniel Hahler
d36c712bb0 Merge pull request #6479 from blueyed/tests-fix-master
[master] Use a dummy RemoteTraceback for test in Python 3.5 Windows
2020-01-16 21:12:04 +01:00
Bruno Oliveira
7a0d1b387d Use a dummy RemoteTraceback for test in Python 3.5 Windows
Somehow in Python 3.5 on Windows this test fails with:
   File "c:\hostedtoolcache\windows\python\3.5.4\x64\Lib\multiprocessing\connection.py", line 302, in _recv_bytes
     overlapped=True)
OSError: [WinError 6] The handle is invalid

This only happens in this platform and Python version, decided to use
a dummy traceback as originally done in #6412.

(cherry picked from commit b9c136b809)
2020-01-16 20:03:16 +01:00
Daniel Hahler
749752d440 Merge pull request #6435 from blueyed/type_checking
Use TYPE_CHECKING instead of False
2020-01-16 19:45:00 +01:00
Bruno Oliveira
b91c721262 ci: github actions: only deploy pytest-dev/pytest (#6474)
ci: github actions: only deploy pytest-dev/pytest
2020-01-16 12:48:29 -03:00
Daniel Hahler
4630e2725e Use TYPE_CHECKING instead of False
This allows for e.g. Jedi to infer types (it checks the name).

It was only used to support Python 3.5.0/3.5.1, where this is is not
available in the `typing` module.

Ref: https://github.com/davidhalter/jedi/issues/1472

Uses `TYPE_CHECKING = False` in `_pytest.outcomes` to avoid having to
work around circular import.
2020-01-16 16:11:39 +01:00
Daniel Hahler
ea31649062 ci: github actions: only deploy pytest-dev/pytest 2020-01-16 13:57:46 +01:00
Bruno Oliveira
715f56dfbc Fixtures now register finalizers with all fixtures before them… (#6438)
Fixtures now register finalizers with all fixtures before them in the stack
2020-01-16 07:33:55 -03:00
Chris NeJame
99180939fe fixtures register finalizers with all fixtures before them in the stack 2020-01-15 11:00:42 -05:00
Bruno Oliveira
1ec5befdb7 Merge pull request #6468 from nicoddemus/deploy-release-notes-6369
Add deploy step: publish package and release notes
2020-01-15 09:05:23 -03:00
Bruno Oliveira
1d3f27cef0 Add deploy step: publish package and release notes
Fix #6369
2020-01-15 08:11:35 -03:00
Daniel Hahler
29703a5f51 Merge pull request #6466 from blueyed/cover-safe_getattr
tests: cover safe_getattr
2020-01-15 11:20:42 +01:00
Daniel Hahler
6f7a95c32e tests: cover safe_getattr 2020-01-15 11:20:00 +01:00
Daniel Hahler
bebfd28da3 doc: revisit section about rootdir
Ref: https://github.com/pytest-dev/pytest/issues/6376
2020-01-15 09:43:35 +01:00
Daniel Hahler
f5844449a8 Merge pull request #6442 from blueyed/rP
terminal: summary_passes: handle teardown sections
2020-01-15 03:02:09 +01:00
Daniel Hahler
4a265ba38b Merge pull request #6446 from blueyed/tox-mypy
tox: add mypy toxenv
2020-01-14 18:26:35 +01:00
Daniel Hahler
910d5df6a8 Merge pull request #6456 from blueyed/fix-doc-_splitnode
minor: fix doc/example for _pytest.nodes._splitnode
2020-01-14 15:22:01 +01:00
Bruno Oliveira
00adb4e42f Implement code coverage in GitHub actions (#6441)
Implement code coverage in GitHub actions
2020-01-14 09:14:57 -03:00
Daniel Hahler
b2cb87fae6 Merge pull request #6440 from blueyed/py351
ci: Travis: Python 3.5.1 via Trusty
2020-01-14 12:41:16 +01:00
Daniel Hahler
189fe3ba1d minor: fix doc/example for _pytest.nodes._splitnode 2020-01-14 12:40:36 +01:00
Bruno Oliveira
d291905825 Append token to codecov.yml instead of duplicating the file 2020-01-14 07:47:21 -03:00
Daniel Hahler
f0c7f21312 Remove "pragma: no cover" comments 2020-01-14 09:15:36 +01:00
Daniel Hahler
4ff7453b48 ci: Travis: Python 3.5.1 via Trusty
Python 3.5.0 caused flaky failures before
(https://github.com/pytest-dev/pytest/issues/5795).

This is pulled out of https://github.com/pytest-dev/pytest/pull/6435,
which adds code specific for Python < 3.5.2.

It only runs a specific test, while collecting everything to get
coverage of the version specific code around typing.
2020-01-14 09:15:36 +01:00
Daniel Hahler
0e70acab79 tox: add mypy toxenv
This is different from what pre-commit (in "linting") runs in that it
uses stubs from (test) dependencies.

It would make sense to run this on CI additionally (since there is no
"pre-commit --skip mypy", and a separate config is not worth it).
But currently it triggers a false positive though anyway
(https://github.com/erikrose/more-itertools/pull/374).
2020-01-14 08:59:48 +01:00
Daniel Hahler
8eec42f040 Merge pull request #6455 from blueyed/mypy-master
master: update mypy 0.740 -> 0.761
2020-01-14 08:56:51 +01:00
Daniel Hahler
3adaa3d87b Merge pull request #6447 from blueyed/fix-determine_setup
typing: fix _pytest.config.findpaths.determine_setup
2020-01-14 08:56:28 +01:00
Ran Benita
090e260517 master: update mypy 0.740 -> 0.761
(cherry picked from commit 16ff9f591e)
(cherry picked from commit 4848bbdf9a)
2020-01-14 06:31:41 +01:00
Daniel Hahler
117072d64c typing: fix _pytest.config.findpaths.determine_setup 2020-01-13 11:45:20 +01:00
Daniel Hahler
90740007a8 Merge pull request #6445 from blueyed/tox-pre-commit-posargs
tox: linting: pass posargs
2020-01-12 21:17:14 +01:00
Daniel Hahler
5e1c6ce630 tox: linting: pass posargs 2020-01-12 20:09:51 +01:00
Daniel Hahler
61d04d3084 terminal: summary_passes: handle teardown sections
Fixes https://github.com/pytest-dev/pytest/issues/2780.
2020-01-11 21:58:19 +01:00
Bruno Oliveira
a3bc6df950 Implement code coverage in GitHub actions
This overwrites the `codecov.yml` file in the root of the repository with
`codecov-upstream.yml` file (which contains the code-cov token)´, so PRs
and branches on the repository can upload coverage.

Suggestion from here:

https://github.com/pytest-dev/pytest/pull/6421#issuecomment-571934112

Security concerns: the token might be misused, but only to upload bogus coverage
to `codecov.io`, so the team believe this is harmless. If we decide to fallback
from this decision , we just need to revoke the token.

Related to #6369
2020-01-11 12:21:20 -03:00
Bruno Oliveira
622995a501 Fix grammar in README (#6427)
Fix grammar in README
2020-01-09 20:22:05 -03:00
Ryan Barner
36531599a4 Fix grammar in README
Corrects grammar error in "Support pytest" section.
2020-01-09 14:12:57 -08:00
Bruno Oliveira
24f8002de8 Fix wrong 'changelog' and 'reference' links in docs (#6424)
Fix wrong 'changelog' and 'reference' links in docs
2020-01-09 19:09:35 -03:00
Bruno Oliveira
23475b6ab9 Fix wrong 'changelog' and 'reference' links in docs
Both references were referencing links from Python because of our intersphinx
mapping in `conf.py`:

    intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}

Because Python's docs explicitly define both references, Sphinx fallbacks to
them instead of generating implicit references as was expected.

Fix #6397
2020-01-09 18:06:15 -03:00
Anthony Sottile
cff7843f3b Merge pull request #6412 from nicoddemus/remote-tb-5971
Fix serialization of 'None' reprcrashes
2020-01-07 11:08:28 -05:00
Bruno Oliveira
356d865ad7 Use concurrent.futures for fidelity to the original report
As requested in review
2020-01-07 12:45:18 -03:00
Bruno Oliveira
f46ad8d114 Unifying black version in pre-commit config file (#6413)
Unifying black version in pre-commit config file
2020-01-07 09:07:47 -03:00
Marcelo Duarte Trevisani
8dbf6a4b2d Unifying black version 2020-01-07 11:07:05 +00:00
Bruno Oliveira
0e00069340 Fix serialization of 'None' reprcrashes
Tracebacks coming from remote processes crated by the multiprocess module
will contain "RemoteTracebacks" which don't have a 'reprcrash' attribute

Fix #5971
2020-01-06 22:04:38 -03:00
Anthony Sottile
26a2e1aba7 Merge pull request #6401 from nicoddemus/4.6-maintenance-docs-onward
Update py27/py34 deprecation docs
2020-01-04 16:24:56 -05:00
Bruno Oliveira
7c80335c6b Merge pull request #6391 from asottile/release-4.6.9 (#6403)
Merge pull request #6391 from asottile/release-4.6.9
2020-01-04 18:13:56 -03:00
Anthony Sottile
75f964c08d Merge pull request #6391 from asottile/release-4.6.9
Preparing release version 4.6.9
2020-01-04 13:01:46 -08:00
Bruno Oliveira
4fa819e535 Update py27/py34 deprecation docs
I've updated the text and incorporated the topics from #5275, so this
can now be part of the official docs, and #5275 can be closed/unpinned.

Closes #5275
2020-01-04 17:52:02 -03:00
Bruno Oliveira
61061d2147 Update copyright year to 2020 (#6400)
Update copyright year to 2020
2020-01-04 09:41:53 -03:00
Bruno Oliveira
deb4287d1c Update copyright year to 2020
Merge pull request #6392 from hugovk/4.6-maintenance-2020
2020-01-04 08:46:58 -03:00
Daniel Hahler
7aac48c418 Merge pull request #6382 from blueyed/fix-parseoutcomes
Fix `RunResult.parseoutcomes` (follow-up to #6353)
2020-01-04 00:49:24 +01:00
Daniel Hahler
3b60e36dbb Merge pull request #6380 from blueyed/doc
minor: split doc with _early_rewrite_bailout
2020-01-01 14:16:22 +01:00
Anthony Sottile
162d737f68 Merge pull request #6385 from betchern0t/master
Added how to reserve an issue to yourself when contributing
2019-12-31 11:53:50 -05:00
PaulC
d884164160 removed trailing whitespace to fix linting issue 2019-12-31 12:49:37 +11:00
PaulC
9811ebdc57 Added how to reserve an issue to yourself when contributing 2019-12-31 10:32:31 +11:00
Daniel Hahler
1c0242dec1 Fix RunResult.parseoutcomes (follow-up to #6353) 2019-12-30 17:08:52 +01:00
Daniel Hahler
a5863ca760 minor: split doc with _early_rewrite_bailout 2019-12-30 09:41:36 +01:00
Bruno Oliveira
8077168387 pytester: quick fix error introduced in #5990 (#6353)
pytester: quick fix error introduced in #5990
2019-12-27 13:28:11 -03:00
Bruno Oliveira
afa899d5e1 Azure Pipelines: Test on Python 3.8 (#6159)
Azure Pipelines: Test on Python 3.8
2019-12-27 13:27:17 -03:00
Hugo
8de9b1be56 Test on Python 3.8 2019-12-27 13:10:43 -03:00
Bruno Oliveira
b532d15fe7 Improve warnings docs (#6366)
Improve warnings docs
2019-12-26 19:52:15 -03:00
Adam Johnson
73702ca88b Improve warnings docs
* Rearrange section about context manager to be in order
* Link to `pytest.warns` and `recwarn` since a reader going top to bottom won't have seen about those yet.
* Used only context manager form in the example; the call form is somewhat obsolete
  and is mentioned in the reference docs already.
* Reuse the 'myfunction' from first example on the second one

Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-Authored-By: Hugo van Kemenade <hugovk@users.noreply.github.com>
2019-12-26 19:16:19 -03:00
Anthony Sottile
d7b0389d1a Merge pull request #6347 from noviluni/delete_deprecated_function
delete inspect.getargspect() as is deprecated since Python 3.0
2019-12-26 13:45:46 -05:00
Bruno Oliveira
06206bcf37 Merge pull request #6355 from nicoddemus/add-gh-actions
Add GitHub actions for CI
2019-12-26 13:32:17 -03:00
Bruno Oliveira
9924432a2e Improve docs so regen doesn't leak temp directories (#6364)
Improve docs so regen doesn't leak temp directories
2019-12-21 13:23:08 -03:00
Bruno Oliveira
c7ac3379e7 Update release notes script after CHANGELOG changed location (#6362)
Update release notes script after CHANGELOG changed location
2019-12-21 13:22:42 -03:00
Anthony Sottile
6cd61390c2 Improve docs so regen doesn't leak temp directories 2019-12-20 13:18:49 -08:00
Bruno Oliveira
994909270f Update release notes script after CHANGELOG changed location 2019-12-20 08:54:44 -03:00
Bruno Oliveira
e1df9dbf0d Merge pull request #6360 from asottile/release-4.6.8 (#6361)
Merge pull request #6360 from asottile/release-4.6.8
2019-12-19 22:46:55 -03:00
Anthony Sottile
ab44d3d733 Merge pull request #6360 from asottile/release-4.6.8
Preparing release version 4.6.8
2019-12-19 16:01:04 -08:00
Bruno Oliveira
d76aa8b428 Add GitHub actions for CI
This includes our current full matrix (windows, linux and macos), for evaluting
purposes.

We should disconsider failures when evaluating PRs.

TODO:

- deploy
- coverage
- github release notes

Even with the above missing, I still believe it would be nice to merge
this and have GitHub actions working in parallel so we can evaluate performance
and usability from now on.
2019-12-19 11:06:57 -03:00
Bruno Oliveira
4dfd2947bc fix typos in docs (#6356)
fix typos in docs
2019-12-19 09:31:08 -03:00
marc
536177bb56 fix typos in docs 2019-12-19 10:35:15 +01:00
Alexandre Mulatinho
dc7bf518b3 pytester: quick fix error introduced in #5990
- added a test to check this condition

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
2019-12-18 16:36:24 -03:00
Bruno Oliveira
8be9684ab2 Optimized renaming of test parameter ids (#6350)
Optimized renaming of test parameter ids
2019-12-16 18:54:35 -03:00
Seth Junot
d4879c7afb Optimized renaming of test parameter ids
While using pytest-repeat, I noticed the previous implementation is slow
for a large number of duplicate test ids. To optimize, this commit
reduces the amount of data copied and avoids using `in` with List
(unhashable type, and therefore is very slow for many elements).
2019-12-16 18:53:48 -03:00
marc
d42f5a41a5 delete inspect.getargspect() as is deprecated since Python 3.0 2019-12-14 19:52:17 +01:00
Bruno Oliveira
a176ff77bc Release 5.3.2 (#6342)
Release 5.3.2
2019-12-14 10:39:19 -03:00
Bruno Oliveira
7f24cc2feb Remove duplicated user from announcement 2019-12-14 10:06:59 -03:00
Bruno Oliveira
d0c663a628 Improve warning about incoming change to 'junitxml_family' defa… (#6343)
Improve warning about incoming change to 'junitxml_family' default
2019-12-13 12:57:21 -03:00
Bruno Oliveira
f7409f8685 Improve warning about incoming change to 'junitxml_family' default
Fix #6265
2019-12-13 09:17:12 -03:00
Bruno Oliveira
10fcac7f90 Preparing release version 5.3.2 2019-12-13 08:51:15 -03:00
Bruno Oliveira
8942a05cfe Change 4639 from feature to improvement
An improvement seems more adequate here.
2019-12-13 08:46:47 -03:00
Bruno Oliveira
66c1a120ba Bugfix 5430 pass logs to junit report (#6274)
Bugfix 5430 pass logs to junit report
2019-12-12 09:35:25 -03:00
Zac Hatfield-Dodds
8cdf9d43a9 Fixes #6326: Typo in the Security section docs home page. (#6327)
Fixes #6326: Typo in the Security section docs home page.
2019-12-09 17:28:06 +11:00
Michael Rose
2ddc330b62 Fixes #6326: Typo in the Security section docs home page. 2019-12-08 22:26:53 -05:00
Bruno Oliveira
1c0ab3c2a3 Add 4.6.7 changelog to master (Wait until #6318) (#6319)
Add 4.6.7 changelog to master (Wait until #6318)
2019-12-05 22:45:12 -03:00
Anthony Sottile
7ff91d8127 Merge pull request #6313 from nicoddemus/egg-rewrite-6301
Fix assertion rewriting module detection for egg dists
2019-12-05 16:24:13 -08:00
Bruno Oliveira
64c71daa21 Add 4.6.7 changelog to master 2019-12-05 17:32:45 -03:00
Bruno Oliveira
c7f9fda42d Fix assertion rewriting module detection for egg dists
Fix #6301
2019-12-04 15:30:45 -03:00
Ran Benita
42fb1f7ede Merge pull request #6309 from jaredvasquez/fix-cafd-docs
Fix typo in documentation of capfd fixture
2019-12-03 12:15:40 +02:00
Jared Vasquez
c00a43a17d fix typo 2019-12-02 22:29:22 -08:00
Bruno Oliveira
1dc612f7d4 Merge pull request #6304 from nicoddemus/pytest-as-pkg
Convert pytest.py into a package
2019-12-02 21:10:15 -03:00
Bruno Oliveira
e5bd7fb053 Convert pytest.py into a package
As discussed in https://github.com/pytest-dev/pytest/issues/3342, this
is the first step to make pytest support static typing fully
2019-12-02 19:27:11 -03:00
Bruno Oliveira
256a9e0027 Remove outdated py2py3 example (#6306)
Remove outdated py2py3 example
2019-12-02 16:54:12 -03:00
Ran Benita
d2d7b97a70 Remove outdated py2py3 example 2019-12-02 21:16:15 +02:00
Bruno Oliveira
23f6adc760 Ensure cache supporting files still exist after --cache-clear (#6296)
Ensure cache supporting files still exist after --cache-clear
2019-12-01 10:37:22 -03:00
Bruno Oliveira
172b82875a Ensure cache supporting files still exist after --cache-clear
Fix #6290
2019-12-01 10:36:47 -03:00
Bruno Oliveira
277857b026 docs: move changelog to docs/en and allow sphinx directives (#6287)
docs: move changelog to docs/en and allow sphinx directives
2019-11-29 10:51:01 -03:00
Daniel Hahler
d3ab56f531 docs: move changelog to docs/en and allow sphinx directives
Now `tox -e docs` will also include the draft changelog for the
next version (locally only).

`CHANGELOG.rst` now only points to the changelog on READTHEDOCS so
sphinx diretives can be used.

Followup to https://github.com/pytest-dev/pytest/pull/6272
2019-11-28 21:23:58 -03:00
Anthony Sottile
209d99102d Merge pull request #6234 from asottile/remove_none_warning
Revert "A warning is now issued when assertions are made for `None`"
2019-11-26 13:04:42 -08:00
Ronny Pfannschmidt
6d31684da5 Merge pull request #6279 from nicoddemus/fix-changelog
Remove duplicated changelog entry for 5.3.1
2019-11-26 19:22:07 +01:00
Bruno Oliveira
4ee280ae1f Remove duplicated changelog entry for 5.3.1 2019-11-26 12:01:12 -03:00
Bruno Oliveira
8b8cba369c Preparing release version 5.3.1 (#6277)
Preparing release version 5.3.1
2019-11-26 11:56:56 -03:00
Bruno Oliveira
05008f6b55 Preparing release version 5.3.1 2019-11-25 14:32:37 -03:00
Claudio Madotto
83182b82ea Merge branch 'bugfix-5430-pass-logs-to-junit-report' of https://github.com/zupermanzupereroe/pytest into bugfix-5430-pass-logs-to-junit-report 2019-11-25 13:00:04 +01:00
Claudio Madotto
31d5cedc6d Avoid duplicating system-out and system-error tags 2019-11-25 12:59:03 +01:00
Claudio Madotto
91b3ff1bb7 Create changelog file and update AUTHORS 2019-11-25 12:59:03 +01:00
Claudio Madotto
b66dc80008 Fix for issue #5430 - junit-xml: logs are not passed to junit report for tests failed not in a teardown phase 2019-11-25 12:59:03 +01:00
zupermanzupereroe
69ad2026f6 Merge pull request #1 from pytest-dev/master
Update repository
2019-11-25 12:56:54 +01:00
Anthony Sottile
9d900930db Merge pull request #6242 from nicoddemus/testdir-changelog
Add link to testdir fixture in CHANGELOG entry
2019-11-24 17:23:02 -08:00
Daniel Hahler
a8230d77f4 Merge pull request #6270 from blueyed/docs-log_cli
docs: add missing `log_cli` confval
2019-11-24 23:21:49 +01:00
Daniel Hahler
b7d908f4a5 Merge pull request #6269 from blueyed/docs
tox: docs: --keep-going and posargs
2019-11-24 23:21:26 +01:00
Daniel Hahler
b9dd0e6210 docs: add missing log_cli confval 2019-11-24 22:34:15 +01:00
Daniel Hahler
57f3dc19b9 tox: docs: --keep-going and posargs
`--keep-going` makes sense with `-W` to see all warnings/errors.

`{posargs:}` is useful for passing in custom args.
2019-11-24 22:21:08 +01:00
Florian Bruhin
ed67312bca Merge pull request #6268 from felixonmars/patch-2
Correct a typo in _pytest/config/__init__.py
2019-11-24 17:04:26 +01:00
Claudio Madotto
2d24c062b6 Avoid duplicating system-out and system-error tags 2019-11-24 16:33:17 +01:00
Claudio Madotto
d940d0b657 Create changelog file and update AUTHORS 2019-11-24 16:08:45 +01:00
Claudio Madotto
f9f092a5e6 Fix for issue #5430 - junit-xml: logs are not passed to junit report for tests failed not in a teardown phase 2019-11-24 15:20:02 +01:00
Felix Yan
b7bc52f770 Correct a typo in _pytest/config/__init__.py 2019-11-24 20:28:10 +08:00
Daniel Hahler
d1eb89d694 Merge pull request #6086 from kondratyev-nv/master
Fix line detection for properties in doctest tests
2019-11-22 23:09:10 +01:00
Nikolay Kondratyev
5e097970df Fix line detection for properties in doctest tests
Co-Authored-By: Daniel Hahler <github@thequod.de>
2019-11-22 23:50:20 +03:00
Daniel Hahler
0601f5cdad Merge pull request #6261 from blueyed/stats-keys
terminal: _get_main_color: help pytest-parallel
2019-11-22 17:12:33 +01:00
Daniel Hahler
a7268aaa5d Merge pull request #6258 from blueyed/notify_exception-handle-exit-exc-upstream
main: wrap_session: handle exit.Exception with notify_exception
2019-11-22 05:49:04 +01:00
Daniel Hahler
1f736a663d terminal: _get_main_color: help pytest-parallel
Use `dict.keys()` to work around `__iter__` not working with a
multiprocessing DictProxy.

Ref: https://github.com/python/cpython/pull/17333
Fixes https://github.com/pytest-dev/pytest/issues/6254.
Ref: https://github.com/browsertron/pytest-parallel/issues/36
2019-11-22 05:48:10 +01:00
Daniel Hahler
2344982d7f main: wrap_session: handle exit.Exception with notify_exception
Fixes https://github.com/pytest-dev/pytest/issues/6257.
Via https://github.com/blueyed/pytest/pull/132.
2019-11-21 22:50:33 +01:00
Daniel Hahler
63c9ad02f4 Merge pull request #6252 from blueyed/minor-changelog
CHANGELOG: two minor fixes/improvements
2019-11-21 18:44:41 +01:00
Daniel Hahler
8b7aeefd7d Merge pull request #6248 from blueyed/default-role
docs: configure default_role=literal
2019-11-21 18:44:17 +01:00
Bruno Oliveira
f1ac0eeef0 Remove sys.last_traceback attribute using del instead of settin… (#6256)
Remove sys.last_traceback attribute using del instead of setting to None
2019-11-21 11:16:19 -03:00
Mark Dickinson
82424c9270 Fix reST markup. 2019-11-21 13:37:17 +00:00
Mark Dickinson
dbb8c146f0 Use proper reST attribute markup. 2019-11-21 13:22:34 +00:00
Mark Dickinson
8d686a8e46 Add self to AUTHORS 2019-11-21 13:14:19 +00:00
Mark Dickinson
9d1082bd30 Add changelog file. 2019-11-21 13:13:36 +00:00
Bruno Oliveira
490c7c7262 Add develop instructions to CONTRIBUTING (#6249)
Add develop instructions to CONTRIBUTING
2019-11-21 10:07:00 -03:00
Mark Dickinson
2ffbe41ae5 clear sys.last_traceback via del instead of = None 2019-11-21 13:06:47 +00:00
Bruno Oliveira
8f2fd8ffc0 Add develop instructions to CONTRIBUTING
From: https://github.com/pytest-dev/pytest/pull/6244
2019-11-21 10:06:32 -03:00
Mark Dickinson
64eb9ea670 Modify test for new expected behaviour 2019-11-21 11:50:40 +00:00
Zac Hatfield-Dodds
7e10c8191d Added link checking to tox and release.py (#5614)
Added link checking to tox and release.py
2019-11-21 16:46:13 +11:00
Daniel Hahler
6659fe0edc CHANGELOG: two minor fixes/improvements 2019-11-21 06:20:57 +01:00
Daniel Hahler
4ee984ff0a Merge pull request #6250 from blueyed/tbh
pytester: LineMatcher: __tracebackhide__ with _fail
2019-11-21 04:26:20 +01:00
Daniel Hahler
b96e0a71a6 pytester: LineMatcher: __tracebackhide__ with _fail
Follow-up to 2228ccb (gone lost in resolving the conflict).
2019-11-21 01:23:36 +01:00
Daniel Hahler
be722652f0 docs: configure default_role=literal
This configures the default role for interpreted text (single
backticks), avoiding the need to check for / enforce double backticks.

Fixes also one instance in the existing changelog:

    - Detect `pytest_` prefixed hooks using the internal plugin manager since
      ``pluggy`` is deprecating the ``implprefix`` argument to ``PluginManager``.
      (`#3487 <https://github.com/pytest-dev/pytest/issues/3487>`_)
2019-11-21 00:35:00 +01:00
Daniel Hahler
58ec5bea35 Merge pull request #6237 from blueyed/fix-no_fnmatch_line
pytester: reset log output in _match_lines
2019-11-20 18:44:37 +01:00
Bruno Oliveira
0be03d7fe4 Add link to testdir fixture in CHANGELOG entry
As per https://github.com/pytest-dev/pytest/pull/5914#issuecomment-556063975
2019-11-20 13:14:17 -03:00
Bruno Oliveira
2879d25812 Fix rendering of Before/After in changelog (#6238)
Fix rendering of Before/After in changelog
2019-11-20 07:32:17 -03:00
Bruno Oliveira
fe69a2cfb7 Delete 5934.feature.rst included in the wrong folder by accident 2019-11-20 07:06:11 -03:00
Bruno Oliveira
af9dfc604d Introduce 5934 in CHANGELOG and fix "pytest" blocks 2019-11-20 07:05:31 -03:00
Anthony Sottile
8c65eae5f4 Fix rendering of Before/After in changelog
Apparently the version of sphinx that rtd uses is a little more strict about whether an anonymous `code-block` can happen
2019-11-19 21:12:30 -08:00
Daniel Hahler
2228ccbfb4 pytester: reset log output in _match_lines (#70)
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.

(cherry picked from commit aade7ed0045ba32557ef8565cbab28a2c91053a7)

Ref: https://github.com/pytest-dev/pytest/pull/5914#issuecomment-549182242
2019-11-20 05:24:18 +01:00
Bruno Oliveira
7e5ad31428 Merge features into master after 5.3 (#6236)
Merge features into master after 5.3
2019-11-19 19:17:06 -03:00
Bruno Oliveira
688bbefed1 Improve instructions on how to write CHANGELOG entries (#6235)
Improve instructions on how to write CHANGELOG entries
2019-11-19 19:10:41 -03:00
Bruno Oliveira
5b3867fd65 Release 5.3.0 (#6233)
Release 5.3.0
2019-11-19 18:49:14 -03:00
Bruno Oliveira
36ef545b2d Improve instructions on how to write CHANGELOG entries
This makes easier for contributors to get the CHANGELOG entry
right the first time.
2019-11-19 14:15:55 -03:00
Daniel Hahler
1d368e0ed4 Merge pull request #6231 from blueyed/param-spell
Improve check for misspelling of parametrize
2019-11-19 17:57:28 +01:00
Bruno Oliveira
be59827216 Small fixes in the CHANGELOG for 5.3.0 2019-11-19 13:56:22 -03:00
Anthony Sottile
faea273c93 Revert "A warning is now issued when assertions are made for None" 2019-11-19 08:24:08 -08:00
Bruno Oliveira
4b16b93cf5 Preparing release version 5.3.0 2019-11-19 12:43:51 -03:00
Bruno Oliveira
21622d0df4 Merge remote-tracking branch 'upstream/master' into release-5.3.0 2019-11-19 12:42:11 -03:00
Daniel Hahler
4ad61cbcf6 Improve check for misspelling of parametrize
- there is no need to do this with `--strict-markers`
- it can be done when looking up marks, instead of for every generated
  test
2019-11-19 16:05:52 +01:00
Daniel Hahler
d1e2d12b3f python: remove unused pytest_make_parametrize_id hookimpl (#6228) 2019-11-19 02:55:24 +01:00
Bruno Oliveira
f36ea240fe Remove check for os.symlink, always there in py3+ (#6227)
Remove check for os.symlink, always there in py3+
2019-11-18 22:37:59 -03:00
Daniel Hahler
4804d4bc98 python: remove unused pytest_make_parametrize_id hookimpl
Added in 79927428d initially, but never used.
2019-11-19 02:27:53 +01:00
Daniel Hahler
b820b7e384 Merge pull request #6224 from blueyed/visit_Assert-minor-cleanup
minor: visit_Assert: move setting of `negation` out of branches
2019-11-19 01:11:53 +01:00
Daniel Hahler
8d3e8b1c54 Revert "ci: use tox -vv" (#6226) 2019-11-19 01:10:06 +01:00
Anthony Sottile
63a23d876c Remove check for os.symlink, always there in py3+ 2019-11-18 16:01:44 -08:00
Anthony Sottile
eeeb19626b Merge pull request #6202 from linw1995/fix_getmodpath
Fix incorrect result of getmodpath method.
2019-11-18 15:14:52 -08:00
Bruno Oliveira
bebd80456b Fix --setup-plan fixture lifetimes (#6214)
Fix --setup-plan fixture lifetimes
2019-11-18 20:04:17 -03:00
Daniel Hahler
f38f2d402e minor: visit_Assert: move setting of negation out of branches 2019-11-18 23:21:00 +01:00
Daniel Hahler
f9feef6808 Revert "ci: use tox -vv"
`tox -vv` is too verbose, and was only used as a hack to get the output
of durations.

As for information in logs `-v` could be used maybe still, but I've
decided to revert it for now.

This reverts commit 56cec5fa79.
2019-11-18 23:14:03 +01:00
Bruno Oliveira
89eeefbbaf Merge pull request #6192 from nicoddemus/remove-reportlog-6180
Remove report_log in favor of pytest-reportlog
2019-11-18 17:58:37 -03:00
Daniel Hahler
ed5f191da2 mypy: config: use mypy_path=src (#6222) 2019-11-18 21:51:39 +01:00
Daniel Hahler
b4ff6b3672 Metafunc: remove hack for DefinitionMock (#6223) 2019-11-18 19:56:00 +01:00
Daniel Hahler
2ad2fbc9a2 Metafunc: remove hack for DefinitionMock
Done initially in 99015bfc8.
2019-11-18 18:19:34 +01:00
Daniel Hahler
b461010f32 mypy: config: use mypy_path=src
This allows for checking files inside of "testing" without having
"src/…" as an argument also.
2019-11-18 18:12:59 +01:00
Daniel Hahler
64d8910516 Metafunc: remove unused _ids (#6220) 2019-11-18 18:00:29 +01:00
Daniel Hahler
b412661de9 Factor out _validate_parametrize_spelling (#6221) 2019-11-18 18:00:00 +01:00
林玮
5d5f480979 Hardening an existing test for demonstrating this change. 2019-11-18 23:46:38 +08:00
Daniel Hahler
91dec8e2bf Factor out _validate_parametrize_spelling
This makes it easier to read `pytest_generate_tests`.
2019-11-18 16:36:12 +01:00
Daniel Hahler
f3a10245d0 Metafunc: remove unused _ids
Forgotten in 40b85d7ee.
2019-11-18 16:21:13 +01:00
Josh Karpel
46ffdf0e3a Update AUTHORS 2019-11-17 17:17:47 -06:00
JoshKarpel
1e3be8ada4 fix whitespace issues in tests for #2049 2019-11-17 17:14:17 -06:00
JoshKarpel
6dfd683a0c changelog entry for #2049 2019-11-17 16:47:09 -06:00
JoshKarpel
9e759010d9 resolve #2049 2019-11-17 16:45:42 -06:00
Anthony Sottile
a2d48332fc Merge pull request #6201 from asottile/mm
Merge master into features
2019-11-17 11:30:51 -08:00
Daniel Hahler
bac6eebfff tests: revisit test_cacheprovider (#6199) 2019-11-17 19:23:16 +01:00
Ran Benita
fa578d7329 Merge pull request #6205 from bluetech/type-annotations-8
Add type annotations to _pytest.compat and _pytest._code.code
2019-11-17 09:45:32 +02:00
Daniel Hahler
b9a3ba1fe8 test_cache_writefail_permissions: ignore any other plugins 2019-11-16 23:29:24 +01:00
Daniel Hahler
1b4623a6d1 tests: revisit test_cacheprovider 2019-11-16 23:29:24 +01:00
Ran Benita
eaa34a9df0 Add type annotations to _pytest._code.code 2019-11-16 22:29:57 +02:00
Daniel Hahler
e3796047c1 pre-commit: upgrade black (#6208) 2019-11-16 19:20:12 +01:00
Daniel Hahler
54a954514b re-run black 2019-11-16 18:55:32 +01:00
Daniel Hahler
b1a597ab02 Remove (now) unnecessary fmt: off 2019-11-16 18:51:02 +01:00
Daniel Hahler
5d247b9caf pre-commit: upgrade black
This brings https://github.com/psf/black/pull/826, which helps with
https://github.com/psf/black/issues/601.
2019-11-16 18:42:17 +01:00
Daniel Hahler
4b7148f9a4 cacheprovider: set: use json.dumps + write (#6206) 2019-11-16 18:25:28 +01:00
Daniel Hahler
786d839db1 cacheprovider: set: use json.dumps + write
``json.dump`` is slower since it iterates over chunks [1].

For 100 ``cache.set`` calls this saved ~0.5s (2.5s => 2s), using a dict
with 1500 entries, and an encoded size of 500kb.

Python 3.7.4.

1: https://github.com/blueyed/cpython/blob/1c2e81ed00/Lib/json/__init__.py#L177-L180
2019-11-16 17:40:56 +01:00
Ran Benita
562d4811d5 Add type annotations to _pytest.compat 2019-11-16 17:22:11 +02:00
Ran Benita
a649f157de Make Source explicitly implement __iter__()
Source was previously iterable because it implements `__getitem__()`,
which is apparently a thing from before `__iter__()` was introduced.
To reduce mypy's and my own confusion, implement `__iter__()` directly.
2019-11-16 17:22:10 +02:00
Ran Benita
307add025b Simplify a FormattedExcinfo test
The previous test was better in that it used fakes to test all of the
real code paths. The problem with that is that it makes it impossible to
simplify the code with `isinstance` checks. So let's just simulate the
issue directly with a monkeypatch.
2019-11-16 17:22:09 +02:00
Ran Benita
e3ac44df36 Inline the FuncargnamesCompatAttr compat helper
It doesn't help much IMO, just adds indirection and makes it harder to
type.
2019-11-16 17:22:09 +02:00
Ran Benita
5bfe793fd5 Remove unneeded getrawcode() calls from tests 2019-11-16 17:22:08 +02:00
Ran Benita
04d68fbc9e Remove checks for Python2-only fields im_func and func_code 2019-11-16 17:22:07 +02:00
Ran Benita
c7a83a0f31 Remove a PyPy version check for an unsupported version
pytest doesn't support these PyPy versions anymore, so no need to have
checks for them.
2019-11-16 17:22:07 +02:00
Ran Benita
f760356578 A few linting fixes
Add some Python 3.8 type: ignores; all are already fixed in the next
mypy release, so can be removed once we upgrade.

Also move some flake8 ignores which seem to have changed places.
2019-11-16 17:22:06 +02:00
Zac Hatfield-Dodds
f24f20a46e Merge pull request #6204 from TH3CHARLie/add-changelog-on-tmp_path_factory
changelog: #3985 also introduce `tmp_path_factory`
2019-11-16 23:57:53 +11:00
TH3CHARLie
b090ac6204 remove trailing-whitespace 2019-11-16 18:01:08 +08:00
TH3CHARLie
9c681b45e3 change: #3985 also introduce 2019-11-16 17:34:05 +08:00
林玮
329f56ecec Fix incorrect result of getmodpath method. 2019-11-16 15:28:04 +08:00
Anthony Sottile
cc78444c30 Merge remote-tracking branch 'origin/master' into mm 2019-11-15 15:26:57 -08:00
Anthony Sottile
3a668ea6ff Merge pull request #6198 from asottile/release-5.2.4
Preparing release version 5.2.4
2019-11-15 14:57:08 -08:00
Daniel Hahler
c49c61fdaf Import Path from _pytest.pathlib for py35 (#6193) 2019-11-15 23:17:43 +01:00
Daniel Hahler
1abb08d52f tests: use sys.dont_write_bytecode
Setting PYTHONDONTWRITEBYTECODE in the environment does not change it
for the current process.
2019-11-15 23:13:08 +01:00
Anthony Sottile
c9a96cdee8 Preparing release version 5.2.4 2019-11-15 13:26:56 -08:00
Daniel Hahler
5979837c60 Import Path from _pytest.pathlib for py35
This is important for `isinstance` checks etc.
2019-11-15 22:19:53 +01:00
Anthony Sottile
19a15a94ee Merge pull request #6197 from asottile/fix_init_py_discovery
Fix incorrect discovery of non-test `__init__.py` files.
2019-11-15 13:19:48 -08:00
Anthony Sottile
4e0f99260d Add regression tests for __init__.py breakage 2019-11-15 13:19:31 -08:00
Anthony Sottile
176c7771fb Revert "fix bug with nonskipped first test in package (#5831)"
This reverts commit 85288b5321, reversing
changes made to 5f9db8a017.
2019-11-15 08:29:52 -08:00
Bruno Oliveira
d2ea9e2db5 Remove report_log in favor of pytest-reportlog
Fix #6180
2019-11-14 19:47:26 -03:00
Bruno Oliveira
e856638ba0 Preparing release version 5.2.3 (#6190)
Preparing release version 5.2.3
2019-11-14 18:17:28 -03:00
Bruno Oliveira
99f487864c Issue a warning to prepare change of 'junit_family' default val… (#6186)
Issue a warning to prepare change of 'junit_family' default value
2019-11-14 18:11:10 -03:00
Bruno Oliveira
dd9a27cf54 Adjust CHANGELOG 2019-11-14 17:51:38 -03:00
Daniel Hahler
d4e4ab5b3d Update text in PR template (#6188) 2019-11-14 21:30:16 +01:00
Bruno Oliveira
e2a0987156 Update advice about _called_from_test. (#6168)
Update advice about _called_from_test.
2019-11-14 17:10:53 -03:00
Michael Shields
bd68c2a3dc Update advice about _called_from_test.
Instead of giving an example of using sys and then, at the end,
advising not to use sys, just give a correct example. This is
especially helpful since mypy 0.740 has started (correctly) complaining
about sys._called_from_pytest not being present.
2019-11-14 19:44:27 +00:00
Bruno Oliveira
5e8c47faad Preparing release version 5.2.3 2019-11-14 11:12:06 -03:00
Hugo
48ec7d28c6 Make whole checklist a comment to avoid incomplete TODOs in PRs 2019-11-14 12:01:40 +02:00
Hugo
350c27c8b4 Update text in PR template 2019-11-14 11:36:47 +02:00
Daniel Hahler
2fc7d04fc3 Merge pull request #6187 from blueyed/minor
Minor fixes
2019-11-14 00:45:54 +01:00
Bruno Oliveira
92d6a0500b Show a better message when 'request' is used in parametrize (#6184)
Show a better message when 'request' is used in parametrize
2019-11-13 20:36:23 -03:00
Bruno Oliveira
6f2c0fd2e8 Show a better message when 'request' is used in parametrize
Fix #6183
2019-11-13 19:57:10 -03:00
Bruno Oliveira
2a67637acc Issue a warning to prepare change of 'junit_family' default value
Fix #6179
2019-11-13 19:55:13 -03:00
Daniel Hahler
772dfc4f9d terminal: fix/remove wrong typing for currentfspath
Can be -2, or py.path.local (not typed).
2019-11-13 23:24:24 +01:00
Daniel Hahler
55bc084dcc doc: s/_pytest.config.Parser/_pytest.config.argparsing.Parser/ 2019-11-13 23:22:25 +01:00
Daniel Hahler
b3bb604683 fix typo in _issue_warning_captured doc 2019-11-13 23:22:25 +01:00
Daniel Hahler
f91bf48a40 Merge pull request #6176 from blueyed/assertoutcome
pytester: Hookrecorder: improve assertoutcome
2019-11-13 19:27:18 +01:00
Daniel Hahler
a6e10cc2e3 Merge pull request #6181 from blueyed/maxfail-terminal-upstream
terminal: report ``session.shouldfail`` reason (``-x``)
2019-11-13 19:27:01 +01:00
Daniel Hahler
c232366f2f Merge pull request #6171 from blueyed/rm-xfail
tests: remove test_nested_marks (xfail)
2019-11-13 16:23:55 +01:00
Daniel Hahler
b06f33f474 terminal: report `session.shouldfail reason (-x`)
Via https://github.com/blueyed/pytest/pull/108.
2019-11-13 16:18:41 +01:00
Daniel Hahler
6ddf7c3d42 pytester: Hookrecorder: improve assertoutcome
Before:

        def assertoutcome(self, passed: int = 0, skipped: int = 0, failed: int = 0) -> None:
            realpassed, realskipped, realfailed = self.listoutcomes()
            assert passed == len(realpassed)
    >       assert skipped == len(realskipped)
    E       assert 1 == 0
    E        +  where 0 = len([])

After:

    >       reprec = testdir.inline_run(testpath, "-s")
    E       AssertionError: ([], [], [<TestReport 'nodeid' when='call' outcome='failed'>])
    E       assert {'failed': 1, 'passed': 0, 'skipped': 0} == {'failed': 0, 'passed': 0, 'skipped': 1}
2019-11-13 13:48:20 +01:00
Daniel Hahler
e2022a6d48 pytester: assert_outcomes: use/set __tracebackhide__ (#6172) 2019-11-12 23:07:58 +01:00
Zac Hatfield-Dodds
55a58bcd3d Merge pull request #6173 from brettcannon/patch-1
Delineate syntactically that the 'match' argument to 'raises' is keyword-only
2019-11-13 08:17:25 +11:00
Brett Cannon
0b40749c98 Delineate syntactically that the 'match' argument to 'raises' is keyword-only 2019-11-12 12:32:05 -08:00
Bruno Oliveira
1b84f099b6 Merge pull request #6170 from blueyed/imp
filterwarnings: ignore DeprecationWarning from nose
2019-11-12 13:00:50 -03:00
Bruno Oliveira
adccb63de0 setup.cfg: fix check-manifest ignore [ci skip] (#6156)
setup.cfg: fix check-manifest ignore  [ci skip]
2019-11-12 11:45:31 -03:00
Daniel Hahler
86e9ae39f0 pytester: assert_outcomes: use/set __tracebackhide__ 2019-11-12 15:28:36 +01:00
Daniel Hahler
dad4985be1 A bit more typing around Node (#6167) 2019-11-12 14:46:05 +01:00
Daniel Hahler
fc1c015c6b tests: remove test_nested_marks (xfail)
It currently fails with a TypeError, and was not updated since 2013 -
therefore it can be assumed that it is not important to support it.

```
____________________ ERROR collecting test_nested_marks.py _____________________
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:235: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
…/Vcs/pytest/src/_pytest/python.py:404: in _genfunctions
    self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
…/Vcs/pluggy/src/pluggy/hooks.py:324: in call_extra
    return self(**kwargs)
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:130: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
…/Vcs/pytest/src/_pytest/python.py:965: in parametrize
    function_definition=self.definition,
…/Vcs/pytest/src/_pytest/mark/structures.py:111: in _for_parametrize
    if len(param.values) != len(argnames):
E   TypeError: object of type 'MarkDecorator' has no len()
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
```
2019-11-12 14:44:03 +01:00
Daniel Hahler
4c7d971f13 filterwarnings: ignore DeprecationWarning from nose
This comes via hypothesis:

```
% COLUMNS=80 p testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis -vv --tb=short
============================= test session starts ==============================
platform linux -- Python 3.7.4, pytest-3.1.4.dev721+g3367bf03b.d20191112, py-1.8.1.dev11+g34f716fe, pluggy-0.13.1.dev8+ga5130ac.d20191103 -- …/Vcs/pytest/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase('…/Vcs/pytest/.hypothesis/examples')
rootdir: …/Vcs/pytest, inifile: tox.ini
plugins: forked-1.1.3, hypothesis-4.44.1, cov-2.8.1, coverage-pytest-plugin-0.1, enhancements-0.0.5.dev1-gf361636-dirty, xdist-1.30.0
collected 1 item

testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis FAILED   [100%]

=================================== FAILURES ===================================
______________________ TestMetafunc.test_idval_hypothesis ______________________
.venv/lib/python3.7/site-packages/hypothesis/core.py:588: in evaluate_test_data
    result = self.execute(data)
.venv/lib/python3.7/site-packages/hypothesis/core.py:553: in execute
    result = self.test_runner(data, run)
.venv/lib/python3.7/site-packages/hypothesis/executors.py:56: in default_new_style_executor
    return function(data)
.venv/lib/python3.7/site-packages/hypothesis/core.py:536: in run
    args, kwargs = data.draw(self.search_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:857: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/core.py:223: in do_draw
    return self.mapped_strategy.do_draw(data)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in do_draw
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in <genexpr>
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in do_draw
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:60: in <genexpr>
    return tuple(data.draw(e) for e in self.element_strategies)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:508: in do_draw
    return data.draw(self.element_strategies[i], label=self.branch_labels[i])
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/strategies.py:570: in do_draw
    result = self.pack(data.draw(self.mapped_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/lazy.py:156: in do_draw
    return data.draw(self.wrapped_strategy)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/collections.py:120: in do_draw
    result.append(data.draw(self.element_strategy))
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:852: in draw
    return strategy.do_draw(self)
.venv/lib/python3.7/site-packages/hypothesis/searchstrategy/numbers.py:62: in do_draw
    return d.integer_range(data, self.start, self.end)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/utils.py:105: in integer_range
    probe = data.draw_bits(bits)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:974: in draw_bits
    self.__check_capacity(n_bytes)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1019: in __check_capacity
    self.mark_overrun()
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1036: in mark_overrun
    self.conclude_test(Status.OVERRUN)
.venv/lib/python3.7/site-packages/hypothesis/internal/conjecture/data.py:1027: in conclude_test
    raise StopTest(self.testcounter)
E   hypothesis.errors.StopTest: 0

During handling of the above exception, another exception occurred:
testing/python/metafunc.py:195: in test_idval_hypothesis
    @hypothesis.settings(
.venv/lib/python3.7/site-packages/nose/__init__.py:1: in <module>
    from nose.core import collector, main, run, run_exit, runmodule
.venv/lib/python3.7/site-packages/nose/core.py:12: in <module>
    from nose.loader import defaultTestLoader
.venv/lib/python3.7/site-packages/nose/loader.py:21: in <module>
    from nose.importer import Importer, add_path, remove_path
.venv/lib/python3.7/site-packages/nose/importer.py:12: in <module>
    from imp import find_module, load_module, acquire_model1, release_model1
/usr/lib/python3.7/imp.py:33: in <module>
    DeprecationWarning, stacklevel=2)
E   DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
---------------------------------- Hypothesis ----------------------------------
You can add @seed(198901559535749756451579900660745168041) to this test or run pytest with --hypothesis-seed=198901559535749756451579900660745168041 to reproduce this failure.
=============================== warnings summary ===============================
testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis
  …/Vcs/pytest/.venv/lib/python3.7/site-packages/unittest2/compatibility.py:143: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class ChainMap(collections.MutableMapping):

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================== short test summary info ============================
FAILED testing/python/metafunc.py::TestMetafunc::test_idval_hypothesis - Depr...
```
2019-11-12 14:32:11 +01:00
Ran Benita
b352e34938 Merge pull request #6149 from bluetech/cached-property
Add a @cached_property implementation
2019-11-10 22:11:04 +02:00
Daniel Hahler
3ef8aa8173 A bit more typing around Node 2019-11-10 19:06:27 +01:00
Daniel Hahler
abcedd6095 _compare_eq_iterable: use AlwaysDispatchingPrettyPrinter (#6151) 2019-11-10 14:08:25 +01:00
Ran Benita
42a46ea786 Add a @cached_property implementation
This is a useful utility to abstract the caching property idiom.

It is in compat.py since eventually it will be replaced by
functools.cached_property.

Fixes #6131.
2019-11-10 10:21:55 +02:00
Daniel Hahler
710e3c40e0 typing around terminal (#6157) 2019-11-10 00:19:11 +01:00
Daniel Hahler
0bbc032db0 [WIP] typing around terminal 2019-11-09 23:53:37 +01:00
Daniel Hahler
96c315e439 showversion: no need for py.path.local (#6163) 2019-11-09 22:45:02 +01:00
Daniel Hahler
28edbaace4 showversion: no need for py.path.local 2019-11-09 21:45:35 +01:00
Daniel Hahler
41604eeb3e setup.cfg: fix check-manifest ignore [ci skip] 2019-11-08 22:39:39 +01:00
Bruno Oliveira
245e1f10e5 Merge pull request #6152 from grlee77/module_name_in_id
use __name__ attribute in the parametrize id for modules as well
2019-11-08 14:16:34 -03:00
Bruno Oliveira
c16b121594 Add CHANGELOG for #6152 2019-11-08 10:52:04 -03:00
Bruno Oliveira
04891048e1 Two minor tweaks in MarkDecorator's implementation (#6150)
Two minor tweaks in MarkDecorator's implementation
2019-11-08 10:46:48 -03:00
Ran Benita
84b2c81db4 Drop the "alias" helper used in MarkDecorator
It is a little too obscure IMO, but the reason I want to drop it is that
type checking has no hope of understanding such dynamic constructs.

The warning argument wasn't used.
2019-11-08 11:22:46 +02:00
Ran Benita
984d90a811 Drop redundant custom MarkDecorator __eq__ implementation
This is already covered by attrs.

Also, the custom implementation returns False when the types don't
match, but it's better to return `NotImplemented`. attrs does this.
2019-11-08 11:14:31 +02:00
Gregory Lee
db82432ec8 add minimal test case 2019-11-08 01:39:29 -05:00
Gregory Lee
cc6c5e15b8 update AUTHORS list 2019-11-08 01:39:29 -05:00
Gregory Lee
c22ce1a12c parametrize: allow __name__ id for modules or other objects as well 2019-11-08 01:39:29 -05:00
Daniel Hahler
cc503c1821 _compare_eq_iterable: use AlwaysDispatchingPrettyPrinter
This fixes/removes the previous hack of re-trying with minimum width,
which fails short when it splits strings.

This inherits from `pprint.PrettyPrinter` to override `_format` in a
minimal way to always dispatch, regardless of the given width.

Code ref: 5c0c325453/Lib/pprint.py (L170-L178)
2019-11-08 04:07:09 +01:00
Bruno Oliveira
6ad95716da add --co option to collect-only (#6116)
add --co option to collect-only
2019-11-07 19:03:32 -03:00
Bruno Oliveira
3b243404e6 Explicitly implement pytest_assertrepr_compare in assertion plu… (#6140)
Explicitly implement pytest_assertrepr_compare in assertion plugin
2019-11-07 18:45:26 -03:00
Daniel Hahler
09709bba06 Use atomicrewrites only on Windows (#6148) 2019-11-07 22:13:26 +01:00
Daniel Hahler
40626f48e7 Update changelog/6148.improvement.rst
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-11-07 22:13:03 +01:00
Bruno Oliveira
7ed33996f1 on_rm_rf_error: ignore os.open (no warning) (#6074)
on_rm_rf_error: ignore os.open (no warning)
2019-11-07 18:06:05 -03:00
Bruno Oliveira
0cf2002a1f Explicitly implement pytest_assertrepr_compare in assertion plugin
Previously it was an alias, which makes it unnecessary hard to find
all implementations (either by IDE or using a simple search).
2019-11-07 18:00:27 -03:00
NNRepos
4946cc8282 Add --co option to collect-only
Fix #5845
2019-11-07 17:50:27 -03:00
Daniel Hahler
45c4a8fb3d Use atomicrewrites only on Windows
Fixes https://github.com/pytest-dev/pytest/issues/6147
2019-11-07 20:57:45 +01:00
Ran Benita
e670ff76cb Merge pull request #6141 from bluetech/type-annotations-7
Add type annotations to _pytest.{warning_types,_code.source,pytester}
2019-11-07 17:11:01 +02:00
Daniel Hahler
19b2f4bb8a tests: use ids (#6145) 2019-11-07 14:43:46 +01:00
Daniel Hahler
f11237b066 _perform_collect: remove comment about untested code (#6144) 2019-11-07 13:18:08 +01:00
Daniel Hahler
14eaa05b60 Merge pull request #6143 from blueyed/test_source
test_source: do not instantiate Source objects during collection
2019-11-07 13:16:34 +01:00
Ran Benita
265a9eb6a2 Add type annotations to some of _pytest.pytester 2019-11-07 14:13:47 +02:00
Ran Benita
58f2849bf6 Add type annotations to _pytest._code.source
At least most of it.
2019-11-07 14:13:47 +02:00
Ran Benita
b2537b22d7 Add type annotations to _pytest.warning_types 2019-11-07 14:11:39 +02:00
Daniel Hahler
2adc84ed6c changelog 2019-11-07 12:55:01 +01:00
Daniel Hahler
2e5cf1cc78 Fix order of format args with warning 2019-11-07 12:50:04 +01:00
Daniel Hahler
8aa0809fbc on_rm_rf_error: ignore os.open (no warning)
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
2019-11-07 12:50:04 +01:00
Daniel Hahler
ab101658f0 saferepr: handle BaseExceptions (#6047) 2019-11-07 12:33:22 +01:00
Daniel Hahler
b268463243 Merge master into features (#6111) 2019-11-07 12:31:33 +01:00
Daniel Hahler
dd852ded70 _perform_collect: remove comment about untested code
Harden one test where it is tested.

All tests testing this:

    testing/acceptance_test.py:184(TestGeneralUsage::test_not_collectable_arguments)
    testing/acceptance_test.py:373(TestGeneralUsage::test_direct_addressing_notfound)
    testing/acceptance_test.py:403(TestGeneralUsage::test_issue134_report_error_when_collecting_member[test_fun.py::test_a])
    testing/acceptance_test.py:420(TestGeneralUsage::test_report_all_failed_collections_initargs)
    testing/test_config.py:1309(test_config_blocked_default_plugins[python])

(via https://github.com/blueyed/pytest/pull/88)
2019-11-07 12:29:36 +01:00
Daniel Hahler
dd6cf7c172 test_exc_chain_repr_without_traceback: use ids 2019-11-07 12:25:46 +01:00
Daniel Hahler
5c00226847 test_iterable_full_diff: use test ids 2019-11-07 12:24:01 +01:00
Daniel Hahler
e8a3d1adf2 Fix test_trace_with_parametrize_handles_shared_fixtureinfo for colors 2019-11-07 11:48:51 +01:00
Daniel Hahler
cb21a8db1d test_source: do not instantiate Source objects during collection 2019-11-07 11:44:26 +01:00
Daniel Hahler
0c0d33f78e Session: collect: keep/use already parsed initialpart (#6120) 2019-11-07 11:16:24 +01:00
Daniel Hahler
c4a110b20a Session: collect: keep/use already parsed initialpart
Via https://github.com/blueyed/pytest/pull/42.
2019-11-06 22:09:24 +01:00
Daniel Hahler
fee7c7b032 py38: do not call None() directly
Works around:

    _____ ERROR collecting testing/io/test_saferepr.py _____
    src/_pytest/python.py:502: in _importtestmodule
        mod = self.fspath.pyimport(ensuresyspath=importmode)
    .venv38/lib/python3.8/site-packages/py/_path/local.py:701: in pyimport
        __import__(modname)
    <frozen importlib._bootstrap>:991: in _find_and_load
        ???
    <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
        ???
    <frozen importlib._bootstrap>:671: in _load_unlocked
        ???
    src/_pytest/assertion/rewrite.py:136: in exec_module
        source_stat, co = _rewrite_test(fn, self.config)
    src/_pytest/assertion/rewrite.py:288: in _rewrite_test
        co = compile(tree, fn, "exec", dont_inherit=True)
    E     File "…/Vcs/pytest/testing/io/test_saferepr.py", line 45
    E       None()
    E       ^
    E   SyntaxError: 'NoneType' object is not callable; perhaps you missed a comma?
2019-11-06 22:08:10 +01:00
Daniel Hahler
eb7a4e32ad saferepr: handle BaseExceptions
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.

Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Daniel Hahler
5be3a9b5ce tests: speed up test_faulthandler.test_timeout (#6075) 2019-11-06 22:07:28 +01:00
Daniel Hahler
fe429d4ce8 assert: fix _compare_eq_iterable: re-format both sides (#6137) 2019-11-06 22:06:39 +01:00
Steffen Schroeder
ceeb7bd085 Fixed broken links 2019-11-06 20:54:41 +01:00
Steffen Schroeder
1cecdf6619 Added checklinks to tox and release.py 2019-11-06 20:54:41 +01:00
Bruno Oliveira
5738d189a4 [RDY] tox: remove platform restriction, only used for pexpect (#6068)
[RDY] tox: remove platform restriction, only used for pexpect
2019-11-06 16:09:27 -03:00
Bruno Oliveira
85288b5321 fix bug with nonskipped first test in package (#5831)
fix bug with nonskipped first test in package
2019-11-06 16:06:46 -03:00
Bruno Oliveira
74f4ec5986 Making it possible to access the pluginmanager in the pytest_ad… (#6106)
Making it possible to access the pluginmanager in the pytest_addoptio…
2019-11-06 15:18:59 -03:00
Daniel Hahler
8dcee39ce9 Merge pull request #6103 from blueyed/lsof_check
tests: lsof_check: include exc with skip message
2019-11-06 18:44:19 +01:00
Daniel Hahler
4e45472405 Merge master into features
Conflicts:
	src/_pytest/debugging.py
2019-11-06 14:22:07 +01:00
Daniel Hahler
92b436c938 Merge pull request #6136 from blueyed/fix-rm_rf-tests
Fix rm_rf tests
2019-11-06 14:19:47 +01:00
Daniel Hahler
5f9db8a017 Merge pull request #6138 from blueyed/ci-py38
ci: Travis: remove py38 from allowed failures; do not use "-dev"
2019-11-06 14:19:14 +01:00
Daniel Hahler
01769b141a Merge pull request #6100 from blueyed/fix-skip-offset
terminal: fix line offset with skip reports
2019-11-06 13:29:40 +01:00
Daniel Hahler
0485b07ff0 Merge pull request #6071 from blueyed/tests-doctest-mock
Tests: approx: mock doctest runner's pdb usage
2019-11-06 13:27:50 +01:00
Daniel Hahler
eb4b3ce1c8 Merge pull request #6084 from blueyed/merge-rm
tests: merge/remove test_dontreadfrominput_buffer_python3
2019-11-06 13:24:47 +01:00
Daniel Hahler
9071a2a5e0 Merge pull request #6119 from blueyed/FSCollector-fspath
FSCollector: keep/use given fspath
2019-11-06 13:10:27 +01:00
Daniel Hahler
957adbbbc7 ci: Travis: remove py38 from allowed failures; do not use "-dev" 2019-11-06 13:09:11 +01:00
Daniel Hahler
ce3d431002 assert: fix _compare_eq_iterable: re-format both sides
Follow-up to 946434c61 (#5924).

Before this patch the test would look like this:

    {'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1}
    Omitting 1 identical items, use -vv to show
    Right contains 1 more item:
    {'new': 1}
    Full diff:
      {
       'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    -                  'sub1': {'long_a': 'substring '
    +                  'sub1': {'long_a': 'substring that gets wrapped'}}},
    ?                                                +++++++++++++++++ ++++
    +  'new': 1,
    -                                     'that '
    -                                     'gets '
    -                                     'wrapped'}}},
      }
2019-11-06 11:23:15 +01:00
Daniel Hahler
e7320c6b54 Merge pull request #5926 from AtakamaLLC/optional-multiline
Add log-auto-indent option to control multiline formatting
2019-11-06 00:35:24 +01:00
Daniel Hahler
00f67494e5 Merge pull request #6107 from MarcoGorelli/color-percentage-indicator
Color percentage indicator
2019-11-06 00:28:45 +01:00
Daniel Hahler
d8096925fa Fix for Python 3.5 not handling LocalPath 2019-11-06 00:22:46 +01:00
Daniel Hahler
9309ae299a Use try/finally to ensure chmod is run, filter warning 2019-11-05 22:28:32 +01:00
Daniel Hahler
dc2c51302a Revert "tests: filterwarnings: do not crash with "(rm_rf)" warning"
This reverts commit 6b2bae9392.
2019-11-05 22:11:56 +01:00
Tibor Arpas
262ed567d0 tests: clean up chmod-related tests to fix rm_rf warnings
Fixed https://github.com/pytest-dev/pytest/issues/5974#issuecomment-549822509.
2019-11-05 22:10:27 +01:00
Daniel Hahler
0794289689 Merge pull request #6129 from blueyed/typing
Typing around Node.location, reportinfo, repr_excinfo etc
2019-11-05 18:29:29 +01:00
Daniel Hahler
cab29dc861 Merge pull request #6124 from blueyed/test_group_warnings_by_message-ignore-own-warning
test_group_warnings_by_message: ignore own PytestExperimentalApiWarning
2019-11-05 16:24:10 +01:00
Daniel Hahler
741f0fedd1 typing around Node.location, reportinfo, repr_excinfo etc 2019-11-05 16:22:58 +01:00
Florian Bruhin
990d75b7e6 Merge pull request #6134 from zmhassan/small_bug1
Removing variable being reassigned
2019-11-05 10:17:04 +01:00
Zak Hassan
f9e3a5395c Removing variable being reassigned 2019-11-04 21:11:54 -05:00
MarcoGorelli
0d79061432 Color percentage indicator according to color of final line
indicate current outcome/status with color of percentage indicator

Fix type annotation, refactor _write_progress_information_filling_space

Keep code in _get_main_color as similar as possible to how it was before

Write test

Make black-compliant

Fix error in newly introduced test_collecterror

Make tests more readable by using constants and f-strings

Remove accidentally added monkeypatch

Make Python 3.5-compatible, add changelog entry

Add newline at the end of changelog file
2019-11-04 19:57:07 +00:00
Bruno Oliveira
0760406480 update chanelog link to moved pip docs page (#6127)
update chanelog link to moved pip docs page
2019-11-04 13:18:09 -03:00
Daniel Hahler
d53794f916 Merge pull request #6125 from blueyed/upstream-test_terminal-fulltrace
test_terminal: reduce number of tests (single --fulltrace param)
2019-11-04 11:50:18 +01:00
David Szotten
14580c7e31 update chanelog link to moved pip docs page 2019-11-04 10:05:05 +00:00
Ran Benita
08c25b7fe0 Merge pull request #6122 from bluetech/type-annotations-6
Add type annotations to _pytest._io.saferepr and _pytest.assertion.util._diff_text
2019-11-04 09:58:09 +02:00
Daniel Hahler
9f800b2a77 test_terminal: reduce number of tests (single --fulltrace param)
Remove the `--fulltrace` arg from the `Option` fixture used in several
tests, but not checked for.  Only use it with `test_keyboard_interrupt`.

(removes 8 tests, coverage not affected)
2019-11-03 21:23:18 +01:00
Daniel Hahler
68dbc24dcb test_group_warnings_by_message: ignore own PytestExperimentalApiWarning 2019-11-03 21:14:24 +01:00
Ran Benita
7d3ce374d2 Add type annotations to _pytest.assertion.util 2019-11-03 20:28:43 +02:00
Ran Benita
18d181fa77 Remove dead code in _pytest.assertion.util._diff_text
The function handles bytes input, however that is never used.
The function has two callers:

1)

```
            if istext(left) and istext(right):
                explanation = _diff_text(left, right, verbose
```

`istext` checks `isinstance(str)`.

2)

```
def _notin_text(term: str, text: str, verbose: int = 0) -> List[str]:
    ...
    diff = _diff_text(correct_text, text, verbose
```

and `_notin_text` is called once:

```
            if istext(left) and istext(right):
                explanation = _notin_text(left, right, verbose
```
2019-11-03 20:28:43 +02:00
Ran Benita
dc30d78845 Add type annotations to _pytest._io.saferepr 2019-11-03 20:28:43 +02:00
MarcoGorelli
9303de877a Fix error in newly introduced test_collecterror
Via https://github.com/pytest-dev/pytest/pull/6107.

(cherry picked from commit 1b9fbbfa195aa20c48574265935dc5e66b96ec16)
2019-11-03 18:16:46 +01:00
Daniel Hahler
3fb969897a Merge pull request #6059 from blueyed/collect-error-short-summary
terminal: report collection errors as "ERROR" in short summary
2019-11-02 15:34:12 +01:00
Daniel Hahler
6df4d07a57 Merge pull request #6067 from blueyed/harden-test
tests: harden test_disabled_capture_fixture
2019-11-02 15:33:55 +01:00
Bruno Oliveira
0947ecd6f0 Change 5924 and 5936 changelog entries to improvement (#6065)
Change 5924 and 5936 changelog entries to improvement
2019-11-02 11:23:06 -03:00
Daniel Hahler
0c7c26fe6e FSCollector: keep/use given fspath
Via https://github.com/blueyed/pytest/pull/42.
2019-11-02 10:02:23 +01:00
Florian Bruhin
35800a2f73 Merge pull request #6112 from gaucheph/fix-small-typo
typos
2019-11-01 11:18:06 +01:00
Patrick Harmon
abc890079f typos 2019-10-31 23:19:35 -05:00
Daniel Hahler
dc5a4fbe23 Merge pull request #6099 from davidszotten/trace_parametrize
Fix --trace for parametrized tests
2019-11-01 05:06:26 +01:00
David Szotten
285524c6cd Fix --trace for parametrized tests
Without this, the second time it tries to stop in a parametrized
function it raises instead:

`ValueError: --trace can't be used with a fixture named func!`

Implementation idea, test (and changelog tweaks) thanks to blueyed

Co-Authored-By: Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
Co-Authored-By: Daniel Hahler <git@thequod.de>
2019-10-31 21:41:33 +00:00
Daniel Hahler
7f851a215b Merge pull request #6032 from blueyed/ci-branches
ci: Travis: configure/restrict branch builds
2019-10-31 10:38:01 +01:00
Joshua Storck
f400804206 Removing pluginmanager as parameter in definition of pytest_addoption hook 2019-10-30 16:25:50 -04:00
Joshua Storck
0027908e9e Removing :py:func: and :ref: from changelog as it's not supported by towncrier 2019-10-30 15:02:18 -04:00
Joshua Storck
7a96d94fd4 Making it possible to access the pluginmanager in the pytest_addoption hook 2019-10-30 14:18:13 -04:00
Bruno Oliveira
3406857284 Introduce --report-log (#5980)
Introduce --report-log
2019-10-30 10:24:35 -03:00
Bruno Oliveira
09096f7436 Remove 'experimental' status from report serialization hooks 2019-10-30 09:43:33 -03:00
Bruno Oliveira
b99661b9d7 Introduce --report-log option
Fix #4488
2019-10-30 09:43:33 -03:00
Daniel Hahler
8c21416798 lsof_check: include exc with skip message 2019-10-29 15:25:15 +01:00
Daniel Hahler
6d2cabae57 terminal: fix line offset with skip reports
The original fix in https://github.com/pytest-dev/pytest/pull/2548 was
wrong, and was likely meant to fix the use with decorators instead,
which this does now (while reverting 869eed9898).
2019-10-29 13:11:02 +01:00
Daniel Hahler
0225cb37c0 Merge pull request #6077 from blueyed/ci-remove-single-py37-pexpect
ci: Travis: include pexpect in main py37 job
2019-10-28 17:05:31 +01:00
Daniel Hahler
cdc53da19c Merge pull request #5990 from MarcoGorelli/plurality-matching
Plurality matching
2019-10-28 17:03:15 +01:00
Daniel Hahler
e7898dedf4 Merge pull request #6093 from blueyed/fix-flaky
tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
2019-10-28 16:17:46 +01:00
Daniel Hahler
6d33f4cdce Merge pull request #6076 from blueyed/runpytest_subprocess-slowest
tests: conftest: handle tests using runpytest_subprocess as "slowest"
2019-10-28 14:49:54 +01:00
Daniel Hahler
60ceec6eb1 tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
Failed for me due to different indent (?) - not reproducible:

    >   ???
    E   Failed: nomatch: 'E           TypeError: write() argument must be str, not bytes'
    …
    E       and: '>   def mode(self):'
    E       and: 'E   TypeError: write() argument must be str, not bytes'
    …
    E   remains unmatched: 'E           TypeError: write() argument must be str, not bytes'
2019-10-28 14:37:26 +01:00
Ran Benita
7f8bf4d9f6 Merge pull request #6066 from bluetech/type-annotations-paths
Add type annotations to _pytest.pathlib and _pytest.tmpdir
2019-10-28 15:20:45 +02:00
Daniel Hahler
a4554e666a tests: speed up test_faulthandler.test_timeout 2019-10-28 13:44:06 +01:00
Daniel Hahler
d6e324a5e6 tests: conftest: handle tests using runpytest_subprocess as "slowest" 2019-10-28 13:43:42 +01:00
Daniel Hahler
023dde89e1 ci: Travis: include pexpect in main py37 job
This removes xdist there (not compatible with the pexpect tests), but it
is better to have one job less, although slower due to not using xdist.
2019-10-28 13:39:43 +01:00
Daniel Hahler
a5bd19e3b4 tests: lazily import doctest in approx tests 2019-10-28 12:55:16 +01:00
Daniel Hahler
32412532ef tests: mock doctest.DocTestRunner to not use real pdb
It is not used there anyway, and might cause false positives.
2019-10-28 12:55:16 +01:00
Daniel Hahler
ec27363748 Merge pull request #6025 from blueyed/pytester-typing
pytester: typing
2019-10-28 05:31:31 +01:00
Daniel Hahler
716f532a38 Merge pull request #6070 from blueyed/pexpect-freebsd
pytester: spawn: do not skip FreeBSD
2019-10-28 05:13:31 +01:00
Daniel Hahler
820b747e7a tests: merge/remove test_dontreadfrominput_buffer_python3 2019-10-27 19:32:06 +01:00
MarcoGorelli
d863c30c74 Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00:00
Daniel Hahler
886a3ad609 pytester: typing 2019-10-27 12:32:14 +01:00
Daniel Hahler
cbc39dd86e Merge pull request #6079 from blueyed/tryfirst
mark: move pytest_cmdline_main.tryfist into decorator
2019-10-27 07:21:31 +01:00
Daniel Hahler
a4faac6c94 mark: move pytest_cmdline_main.tryfist into decorator
Avoids comments for ignored typing.
2019-10-27 06:01:18 +01:00
Daniel Hahler
81c3bc76bc tests: harden test_disabled_capture_fixture 2019-10-27 03:02:24 +01:00
Daniel Hahler
a92f49afa7 Merge pull request #6073 from blueyed/merge-master-into-features
Merge master into features
2019-10-27 02:57:00 +01:00
Daniel Hahler
7f1af84f47 Merge master into features
Conflicts:
	src/_pytest/logging.py
2019-10-27 02:06:36 +01:00
Daniel Hahler
8e8a8fa4b9 pytester: spawn: do not skip FreeBSD
Fixes https://github.com/pytest-dev/pytest/issues/6069
2019-10-27 00:44:25 +02:00
Daniel Hahler
be514178d0 tox: remove platform restriction, only used for pexpect
This would prevent TOXENV=py37-pexpect-… from running on e.g. FreeBSD.
And even on Windows it is pytest's job of skipping the tests then.  This
was probably still from when the pexpect env was only running
pexpect-based tests.
2019-10-27 00:23:25 +02:00
Ran Benita
00a278cdb4 Add type annotations to _pytest.tmpdir
At least the ones I was able to.
2019-10-26 20:30:44 +03:00
Ran Benita
59a59f371b Add type annotations to _pytest.pathlib
At least the ones I was sure of.
2019-10-26 20:08:36 +03:00
Bruno Oliveira
928587da60 Change 5924 and 5936 changelog entries to improvement [ci skip] 2019-10-26 13:02:47 -03:00
Bruno Oliveira
cefe6bfec3 Replace a few outdated references to py.test with pytest (#6063)
Replace a few outdated references to py.test with pytest
2019-10-26 12:59:22 -03:00
Bruno Oliveira
ac633b8969 Replace py.io.TextIO with io.StringIO (#6064)
Replace py.io.TextIO with io.StringIO
2019-10-26 12:58:52 -03:00
Bruno Oliveira
1ad4ca6ac1 Support sys.pycache_prefix on py38 (#5864)
Support sys.pycache_prefix on py38
2019-10-26 11:29:09 -03:00
Bruno Oliveira
6f20b4b014 Introduce compat.fspath 2019-10-26 10:37:44 -03:00
Ran Benita
0b8c35516f Replace py.io.TextIO with io.StringIO
In Python3, py.io.TextIO is just an alias to io.StringIO. Remove the
indirection.
2019-10-26 16:33:57 +03:00
Ran Benita
96de232791 Replace a few outdated references to py.test with pytest 2019-10-26 16:28:17 +03:00
Bruno Oliveira
f93f284356 Support sys.pycache_prefix on py38
Fix #4730
2019-10-26 10:17:21 -03:00
Kale Kundert
b9df9a4761 Merge pull request #6058 from AnjoMan/6057-tolerance-on-complex-approx
6057 tolerance on complex approx
2019-10-25 15:31:47 -04:00
Bruno Oliveira
39066d5a42 Merge master into features (#6056)
Merge master into features
2019-10-25 16:27:14 -03:00
Anton Lodder
3c7fbe2d8b Document evaluating complex number for infinity 2019-10-25 12:03:03 -04:00
Michael Krebs
1f5b454355 Add log-auto-indent option to control multiline formatting 2019-10-25 11:31:33 -04:00
Daniel Hahler
82753bec50 terminal: report collection errors as "ERROR" in short summary 2019-10-25 07:03:32 +02:00
AnjoMan
34a02121ad Drop python 2 unicode tests for approx repr 2019-10-24 23:44:13 -04:00
AnjoMan
ed9fda84d3 Add tolerance to complex numbers 2019-10-24 23:44:13 -04:00
Bruno Oliveira
2fc1f7b8dc Put the 4.6 changelogs together (#5969)
Put the 4.6 changelogs together
2019-10-24 21:21:59 -03:00
Bruno Oliveira
fb0e8b99d1 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
- 	src/_pytest/cacheprovider.py
2019-10-24 21:13:43 -03:00
Bruno Oliveira
dae238c9b1 Release version 5.2.2 (#6055)
Release version 5.2.2
2019-10-24 21:09:15 -03:00
Bruno Oliveira
b27ba97721 Preparing release version 5.2.2 2019-10-24 19:24:04 -04:00
Bruno Oliveira
d1bc2601e4 pytester: align prefixes (#6026)
pytester: align prefixes
2019-10-24 18:50:29 -03:00
Bruno Oliveira
2b56c7e1ce Update Tidelift docs with latest campaign (#6053)
Update Tidelift docs with latest campaign
2019-10-24 18:46:21 -03:00
Bruno Oliveira
73a77c90ca Change #5061 changelog to 'improvement' (#6051)
Change #5061 changelog to 'improvement'
2019-10-24 18:44:48 -03:00
Daniel Hahler
8ef4287bf0 pytester: align prefixes
This is important for using another match_nickname, e.g. "re.match".

TODO:

- [ ] changelog
- [ ] test
2019-10-24 23:20:12 +02:00
Daniel Hahler
45fc0d9cd8 Merge pull request #6040 from blueyed/test_meta-slow
tests: mark test_meta as slow
2019-10-24 22:53:04 +02:00
Bruno Oliveira
2bee7d7c3e Update Tidelift docs with latest campaign
Tidelift has launched a new marketing campaign as outlined here:

* https://forum.tidelift.com/t/task-enhancement-marketing-the-tidelift-subscription-to-your-users/321

This PR splits the previous "sponsor" information into two, Open Collective
and Tidelift (as they have very different target audiences).

Also took the opportunity to reorder some items at the end of
the contents page in a manner that I believe make more sense.
2019-10-24 14:58:58 -03:00
Bruno Oliveira
92418b8d5d Change #5061 changelog to 'improvement' 2019-10-23 21:27:07 -03:00
Bruno Oliveira
432e5550e5 assertrepr_compare: use safeformat with -vv (#5936)
assertrepr_compare: use safeformat with -vv
2019-10-23 19:51:40 -03:00
Bruno Oliveira
713b9e54c3 Review rm_rf handling of FileNotFoundErrors (#6044)
Review rm_rf handling of FileNotFoundErrors
2019-10-23 19:22:26 -03:00
Daniel Hahler
8316d4392a Merge pull request #6028 from blueyed/DontReadFromInput-msg
capture: improve message with DontReadFromInput's IOError
2019-10-23 22:48:15 +02:00
Ran Benita
7a2d2d8f07 Merge pull request #5847 from bluetech/type-annotations-4
2/X Fix check_untyped_defs = True mypy errors
2019-10-23 22:52:23 +03:00
Daniel Hahler
6242777818 Merge pull request #6041 from blueyed/pytester-splitlines
pytester: runpytest_inprocess: use splitlines()
2019-10-23 21:42:21 +02:00
Bruno Oliveira
20ee883b5f Show the mnemonic of pytest.ExitCode in RunResult's repr (#6043)
Show the mnemonic of pytest.ExitCode in RunResult's repr
2019-10-23 10:46:58 -03:00
Bruno Oliveira
7beb520555 Show the mnemonic of pytest.ExitCode in RunResult's repr
Fix #4901
2019-10-23 09:16:02 -03:00
Ran Benita
1cc1ac5183 Remove some type: ignores fixed in typeshed 2019-10-23 14:47:56 +03:00
Bruno Oliveira
ba4b8c869c Review rm_rf handling of FileNotFoundErrors 2019-10-23 08:30:52 -03:00
Ran Benita
1787bffda0 Fix check_untyped_defs errors in capture 2019-10-23 14:20:15 +03:00
Ran Benita
0267b25c66 Fix some check_untyped_defs mypy errors in terminal 2019-10-23 14:20:15 +03:00
Ran Benita
5dca7a2f4f Fix check_untyped_defs errors in cacheprovider 2019-10-23 14:20:15 +03:00
Ran Benita
93c8822f26 Fix check_untyped_defs errors in warnings 2019-10-23 14:20:15 +03:00
Ran Benita
583c2a2f9b Fix check_untyped_defs errors in logging 2019-10-23 14:20:15 +03:00
Ran Benita
1984c10427 Fix check_untyped_defs errors in doctest
In order to make the LiteralOutputChecker lazy initialization more
amenable to type checking, I changed it to match the scheme already used
in this file to lazy-initialize PytestDoctestRunner.
2019-10-23 14:20:14 +03:00
Ran Benita
3246d8a6e9 Merge pull request #6048 from bluetech/mypy-0.740
Update mypy 0.720 -> 0.740
2019-10-23 12:47:21 +03:00
Daniel Hahler
b30e7bd1de Merge pull request #6045 from blueyed/minor
minor: typing for ReprFailDoctest
2019-10-23 11:44:37 +02:00
Daniel Hahler
db9e248b2e Merge pull request #6039 from blueyed/test_doctest_id
doctest: unset RUNNER_CLASS in pytest_unconfigure
2019-10-23 11:38:59 +02:00
Daniel Hahler
1371b01f78 typing for ReprFailDoctest 2019-10-23 10:52:42 +02:00
Ran Benita
52b85f6f1a Update mypy 0.720 -> 0.740
Changelogs:
http://mypy-lang.blogspot.com/2019/09/mypy-730-released.html
http://mypy-lang.blogspot.com/2019/10/mypy-0740-released.html

New errors:
src/_pytest/recwarn.py:77: error: Missing return statement
src/_pytest/recwarn.py:185: error: "bool" is invalid as return type for "__exit__" that always returns False
src/_pytest/recwarn.py:185: note: Use "typing_extensions.Literal[False]" as the return type or change it to "None"
src/_pytest/recwarn.py:185: note: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
src/_pytest/recwarn.py:185: error: Return type "bool" of "__exit__" incompatible with return type "None" in supertype "catch_warnings"
src/_pytest/recwarn.py:230: error: "bool" is invalid as return type for "__exit__" that always returns False
src/_pytest/recwarn.py:230: note: Use "typing_extensions.Literal[False]" as the return type or change it to "None"
src/_pytest/recwarn.py:230: note: If return type of "__exit__" implies that it may return True, the context manager may swallow exceptions
src/_pytest/recwarn.py:230: error: Return type "bool" of "__exit__" incompatible with return type "None" in supertype "catch_warnings"

The errors are due to this new error:
https://mypy.readthedocs.io/en/latest/error_code_list.html#check-the-return-type-of-exit-exit-return
2019-10-23 10:34:14 +03:00
Daniel Hahler
c71a2c9f80 Merge pull request #6023 from blueyed/main-exitcode
pytest.main: return ExitCode
2019-10-23 07:48:17 +02:00
Daniel Hahler
2f589a9769 pytester: runpytest_inprocess: use splitlines()
This avoids having a trailing empty lines always.
2019-10-23 04:34:29 +02:00
Daniel Hahler
046aa0b6e9 pytest.main: return ExitCode 2019-10-23 04:33:05 +02:00
Daniel Hahler
f0c2b070c5 Merge pull request #6046 from blueyed/fix-features
Fix test_doctest_set_trace_quit on features
2019-10-23 04:32:10 +02:00
Daniel Hahler
b079dc2dbe Fix test_doctest_set_trace_quit on features 2019-10-23 04:13:37 +02:00
Daniel Hahler
4af89bba9d Merge pull request #5061 from blueyed/summary_stats-multi-color
Multiple colors with terminal summary_stats
2019-10-23 03:21:39 +02:00
Daniel Hahler
5e7b2ae704 doctest: pytest_unconfigure: reset RUNNER_CLASS
This is important when used with ``pytester``'s ``runpytest_inprocess``.

Since 07f20ccab `pytest testing/acceptance_test.py -k test_doctest_id`
would fail, since the second run would not consider the exception to be
an instance of `doctest.DocTestFailure` anymore, since the module was
re-imported, and use another failure message then in the short test
summary info (and in the report itself):

> FAILED test_doctest_id.txt::test_doctest_id.txt - doctest.DocTestFailure: <Do...

while it should be:

> FAILED test_doctest_id.txt::test_doctest_id.txt
2019-10-23 03:09:41 +02:00
Daniel Hahler
bae22e1fdd Merge pull request #6016 from blueyed/pytest-_ensure_unconfigure-twice
pytester: parseconfigure: remove duplicate config._ensure_unconfigure
2019-10-23 01:39:23 +02:00
Bruno Oliveira
215be88fed Minor: help / direct usage of config (#6011)
Minor: help / direct usage of config
2019-10-22 20:24:08 -03:00
Daniel Hahler
98fc9377d9 Merge pull request #5630 from blueyed/pdb-doctest-bdbquit
doctest: handle BdbQuit
2019-10-23 01:10:19 +02:00
Daniel Hahler
8683293031 Merge pull request #6017 from blueyed/DontReadFromInput-remove-comment
Remove (rejected) comment from DontReadFromInput
2019-10-23 01:07:12 +02:00
Daniel Hahler
bdadf12af1 Merge pull request #6030 from blueyed/tox-vv
ci: use tox -vv
2019-10-23 01:05:21 +02:00
Daniel Hahler
82e9013e73 Merge pull request #6004 from blueyed/fix-nf
cache: NFPlugin: keep known nodeids
2019-10-23 01:04:48 +02:00
Bruno Oliveira
a51bb3eedb Add CHANGELOG for #5630 2019-10-22 19:43:42 -03:00
Bruno Oliveira
f4734213e5 Merge remote-tracking branch 'upstream/features' into blueyed/pdb-doctest-bdbquit 2019-10-22 19:43:35 -03:00
Daniel Hahler
0dd68ba0b6 tests: mark test_meta as slow
This moves it to the end of tests during collection.  Takes ~7s for me.
2019-10-22 23:44:52 +02:00
Daniel Hahler
851fc0280f ci: Travis: configure/restrict branch builds [ci skip] 2019-10-22 23:03:31 +02:00
Daniel Hahler
56cec5fa79 ci: use tox -vv
This will display durations, and is useful in logs in general.
2019-10-22 05:46:52 +02:00
Daniel Hahler
3c14dd7f55 capture: improve message with DontReadFromInput's IOError
Ref: https://github.com/pytest-dev/pytest/pull/4996#issuecomment-479686487
2019-10-22 02:03:18 +02:00
Daniel Hahler
978c7ae1b7 Merge pull request #6015 from blueyed/merge-master-into-features
Merge master into features
2019-10-21 21:59:09 +02:00
Daniel Hahler
554dba391c Multiple colors with terminal summary_stats
Ref: https://github.com/pytest-dev/pytest/issues/5060
2019-10-21 04:35:45 +02:00
Daniel Hahler
995990c61b Remove (rejected) comment from DontReadFromInput
Ref: https://github.com/pytest-dev/pytest/pull/4996#issuecomment-479686487
2019-10-21 02:26:29 +02:00
Daniel Hahler
b47f57a08a pytester: parseconfigure: remove duplicate config._ensure_unconfigure
This gets done in `parseconfig` already.
2019-10-21 01:15:27 +02:00
Daniil Galiev
5cefcb2052 refactor disabling markers 2019-10-21 00:11:24 +02:00
Daniil Galiev
b94eb4cb7b disable _ALLOW_MARKERS in module __init__.py 2019-10-21 00:11:24 +02:00
Daniil Galiev
9275012ef7 fix bug with nonskipped first test in package 2019-10-21 00:11:24 +02:00
Daniel Hahler
803cc1f294 Merge master into features 2019-10-21 00:08:03 +02:00
Bruno Oliveira
14142b9113 tests: remove unnecessary test, clarify (#6013)
tests: remove unnecessary test, clarify
2019-10-20 18:36:27 -03:00
Daniel Hahler
46fbf22524 ci: Travis: cover verbose=1 2019-10-20 20:51:03 +02:00
Daniel Hahler
d91ff0af8a assertrepr_compare: use safeformat with -vv 2019-10-20 20:51:03 +02:00
Daniel Hahler
0123b29ed7 tests: remove unnecessary test, clarify
Follow-up to https://github.com/pytest-dev/pytest/pull/6009.
2019-10-20 20:40:13 +02:00
Bruno Oliveira
16efa1bfef Merge pull request #6009 from yoavcaspi/fix_keyboardInterrupt_on_setup_show
setuponly: remove printing out/err from capman
2019-10-20 14:00:06 -03:00
Daniel Hahler
a6152db84a setuponly: pytest_fixture_setup: use option directly 2019-10-20 17:57:25 +02:00
Daniel Hahler
83351a3368 doc: improve help for filterwarnings 2019-10-20 17:56:59 +02:00
Daniel Hahler
fbb7f663be Merge pull request #6005 from blueyed/harden-trial
tests: harden/fix test_trial_error
2019-10-20 17:35:15 +02:00
Yoav Caspi
5624e366c1 add more indications to the result of the tests 2019-10-20 09:54:23 +03:00
Anthony Sottile
b88f5df4ce Merge pull request #6010 from pytest-dev/asottile-patch-2
Ensure .pytest_cache file has a newline at the end
2019-10-19 16:21:21 -07:00
Anthony Sottile
3a402811de Ensure .pytest_cache file has a newline at the end 2019-10-19 14:42:06 -07:00
Bruno Oliveira
b5579d2cf2 Make InvocationParams.args a tuple (#6008)
Make InvocationParams.args a tuple
2019-10-19 17:36:42 -03:00
Daniel Hahler
9b673bcc44 Improve/revisit CallInfo.__repr__ (#6007) 2019-10-19 21:45:27 +02:00
Bruno Oliveira
d12cdd3127 Make InvocationParams.args a tuple
This avoids mutating the original list to reflect on InvocationParams,
which is supposed to be an immutable snapshot of the state of pytest.main()
at the moment of invocation (see pytest-dev/pytest-xdist#478).
2019-10-19 16:42:58 -03:00
Yoav Caspi
e05b33ed16 setuponly: remove printing out/err from capman 2019-10-19 22:33:19 +03:00
Daniel Hahler
119bf66d7a ExceptionInfo.from_current: pass through exprinfo (#6002) 2019-10-19 19:20:55 +02:00
Daniel Hahler
15f9568694 Improve/revisit CallInfo.__repr__ 2019-10-19 19:07:11 +02:00
Florian Bruhin
2e11ea6108 Merge pull request #6006 from atugushev/update-doc-contextlib2
Update doc to use contextlib2.nullcontext
2019-10-19 14:29:16 +02:00
Albert Tugushev
18786992bb Update doc to use contextlib2.nullcontext
nullcontext has been backported in contextlib2==0.6.0
2019-10-19 15:09:37 +07:00
Daniel Hahler
5b88612e5b tests: harden/fix test_trial_error 2019-10-19 09:03:26 +02:00
Daniel Hahler
3173a26388 cache: NFPlugin: keep known nodeids
Caveat: does not forget about old nodeids

Fixes https://github.com/pytest-dev/pytest/issues/5206
2019-10-19 04:53:01 +02:00
Daniel Hahler
cd753aa4ab ExceptionInfo.from_current: pass through exprinfo
This was lost in 11f1f79222.
2019-10-19 03:02:47 +02:00
Daniel Hahler
5e7b8d813b Remove unreachable code from config._prepareconfig (#6001) 2019-10-18 23:47:09 +02:00
Daniel Hahler
94c4dd6ad7 help: display default verbosity (#5998) 2019-10-18 23:34:38 +02:00
Daniel Hahler
de7c1aa0b7 Merge pull request #5999 from blueyed/passenv-TERM
tox: pass $TERM
2019-10-18 23:34:03 +02:00
Philipp Loose
afac1f0021 Remove unreachable code from config._prepareconfig
The code that could trigger the execution of the removed lines was
removed with a7e4016.
2019-10-18 23:11:41 +02:00
Daniel Hahler
ab245ccdc3 help: display default verbosity 2019-10-18 22:11:54 +02:00
Daniel Hahler
9da73541b7 tox: pass TERM
Ref: https://github.com/tox-dev/tox/issues/1441
2019-10-18 22:11:00 +02:00
Daniel Hahler
c9524af5ae Merge master into features (#5995) 2019-10-18 21:23:28 +02:00
Daniel Hahler
0976e2f50d Merge master into features 2019-10-18 17:51:42 +02:00
Daniel Hahler
0783030357 Merge pull request #5992 from blueyed/tests-PDBPP_HIJACK_PDB
tests: debugging: disable pdb++ within inner tests
2019-10-18 17:50:03 +02:00
Daniel Hahler
d910175b9f Merge pull request #5993 from blueyed/filterwarnings-error-removing
tests: filterwarnings: do not crash with "(rm_rf)" warning
2019-10-18 17:38:40 +02:00
Daniel Hahler
6b2bae9392 tests: filterwarnings: do not crash with "(rm_rf)" warning
Ref: https://github.com/pytest-dev/pytest/issues/5974
2019-10-18 17:22:56 +02:00
Daniel Hahler
7ef44913a1 tests: debugging: disable pdb++ within inner tests
Ref: https://github.com/pytest-dev/pytest/pull/5306#issuecomment-495690643
2019-10-18 17:08:39 +02:00
Daniel Hahler
813ef9e88f Merge pull request #5983 from aklajnert/fix_5.2.0_announce
Remove redundant mention from 5.2.0 release notes.
2019-10-17 15:33:53 +02:00
Andrzej Klajnert
f2dd9cc63e Remove redundant mention from 5.2.0 release notes. 2019-10-17 13:17:34 +02:00
Daniel Hahler
ce8b1dfa04 ci: Travis: move py37-pexpect to another job (#5979) 2019-10-17 07:54:04 +02:00
Daniel Hahler
a73d0151a6 ci: Travis: move py37-pexpect to another job
It does not have to run all tests again by itself.
2019-10-17 02:19:46 +02:00
Bruno Oliveira
3cb1457e6d Merge pull request #5977 from blueyed/numpy
tests: keep numpy being optional
2019-10-16 20:13:29 -03:00
Daniel Hahler
90dfee5da5 tests: keep numpy being optional
Ref: https://github.com/pytest-dev/pytest/pull/5950#discussion_r335254774
2019-10-16 23:50:23 +02:00
Bruno Oliveira
77a995ffad Add missing version added/changed markers to docs (#5966)
Add missing version added/changed markers to docs
2019-10-16 10:43:45 -03:00
Anthony Sottile
810db2726d Put the 4.6 changelogs together 2019-10-15 18:57:59 -07:00
Bruno Oliveira
914a9465ab tests: move tests for setuponly/setupplan (#5961)
tests: move tests for setuponly/setupplan
2019-10-15 19:49:26 -03:00
Bruno Oliveira
f739d511b0 minor: test_failure_function: use vars (#5958)
minor: test_failure_function: use vars
2019-10-15 19:48:41 -03:00
Bruno Oliveira
0383d43645 Add missing version added/changed markers to docs
Notice some features since 5.0 were not being properly
marked in which version they have been added/changed.
2019-10-15 19:45:58 -03:00
Bruno Oliveira
76c2a8ebbe doc: caplog: add caplog.messages (#5963)
doc: caplog: add caplog.messages
2019-10-15 19:42:15 -03:00
Daniel Hahler
71a7fd02a5 doc: caplog: add caplog.messages 2019-10-15 16:18:50 +02:00
Daniel Hahler
c2ae0e0dc6 tests: move tests for setuponly/setupplan
Forgotten in 032ce8baf.
2019-10-15 00:41:05 +02:00
Anthony Sottile
7bc8cb8e2b Merge pull request #5954 from blueyed/changelog-remove-dupe
changelog: #5523 was fixed in 5.0.1 already
2019-10-14 15:37:21 -07:00
Daniel Hahler
361f0e6ba7 minor: test_failure_function: use vars 2019-10-14 22:45:25 +02:00
Daniel Hahler
dee8d94876 changelog: #5523 was fixed in 5.0.1 already
Ref: https://github.com/pytest-dev/pytest/pull/5952#issuecomment-541801883
2019-10-14 19:20:57 +02:00
Anthony Sottile
a20880cca2 Merge pull request #5952 from nicoddemus/port-changelog
Port CHANGELOG from 4.6.6 release
2019-10-13 10:20:34 -07:00
Bruno Oliveira
ae9465215e Port CHANGELOG from 4.6.6 release 2019-10-13 11:54:02 -03:00
Bruno Oliveira
1555973487 Workaround curl bug which makes retries of fetching codecov.io/… (#5951)
Workaround curl bug which makes retries of fetching codecov.io/bash not work
2019-10-12 17:08:47 -03:00
Bruno Oliveira
3322c1e033 Casting fixture parameter to list at the beginning of parameter… (#5950)
Casting fixture parameter to list at the beginning of parameter parsing.
2019-10-12 17:02:48 -03:00
Ran Benita
7678f891f9 Workaround curl bug which makes retries of fetching codecov.io/bash not work 2019-10-12 21:52:01 +03:00
Florian Bruhin
4f2abd7ae0 Merge pull request #5948 from attomos/update-projects-doc
Documentation update to project examples
2019-10-12 17:31:24 +02:00
Victor Maryama
122cf60b27 Always creating list for consistency.
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-10-12 15:46:28 +02:00
Victor Maryama
63e3d89647 Fixed linting. 2019-10-12 15:08:47 +02:00
Victor Maryama
122748a6cf Added changelog file. 2019-10-12 14:38:58 +02:00
Victor Maryama
1f639e2c22 Casting fixture parameter to list at the beginning of parameter parsing. 2019-10-12 14:33:43 +02:00
Nattaphoom Chaipreecha
83ba5eb58a Add pudb to project examples 2019-10-12 08:10:04 +07:00
Nattaphoom Chaipreecha
d07c5ba4ae Update pdb++ link (moved to GitHub) 2019-10-12 08:09:49 +07:00
Anthony Sottile
b162ab6a45 Merge pull request #5943 from nicoddemus/py2-py37-tech-docs
Add link to technical aspects issue to the py27-py34 docs
2019-10-11 11:07:58 -07:00
Bruno Oliveira
57141dc708 Add link to technical aspects issue to the py27-py34 docs 2019-10-11 08:50:38 -03:00
Bruno Oliveira
afabbb6346 minor: test_assertion: improve mock_config (#5940)
minor: test_assertion: improve mock_config
2019-10-11 08:28:42 -03:00
Daniel Hahler
fb90259460 test_assertion: improve mock_config 2019-10-11 04:19:07 +02:00
Bruno Oliveira
bad4ffc3a7 remove cancelled training sidebar (#5938)
remove cancelled training sidebar
2019-10-10 07:45:26 -03:00
Oliver Bestwalter
71ad5b0fbb remove cancelled training sidebar 2019-10-10 12:11:16 +02:00
Bruno Oliveira
db6653ce3b Improve ExceptionInfo.__repr__ (#5934)
Improve ExceptionInfo.__repr__
2019-10-09 17:08:55 -03:00
Daniel Hahler
2a2fe7d3db Improve ExceptionInfo.__repr__ 2019-10-09 19:27:46 +02:00
Bruno Oliveira
5c92a0f695 Merge master into features (#5930)
Merge master into features
2019-10-08 17:39:49 -03:00
Daniel Hahler
21c038f304 Merge master into features 2019-10-08 18:57:15 +02:00
Daniel Hahler
fca462cf7d Merge pull request #5924 from blueyed/improve-list-diff
Improve full diff output for lists
2019-10-08 17:58:25 +02:00
Daniel Hahler
946434c610 Improve full diff output for lists
Massage text input for difflib when comparing pformat output of
different line lengths.

Also do not strip ndiff output on the left, which currently already
removes indenting for lines with no differences.

Before:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E     - ['version', 'version_info', 'sys.version', 'sys.version_info']
    E     + ['version',
    E     +  'version_info',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info']

After:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E       [
    E        'version',
    E        'version_info',
    E        'sys.version',
    E        'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E       ]
2019-10-08 15:27:51 +02:00
Anthony Sottile
3fada8c8ee Merge pull request #5925 from asottile/fix_resource_warning_again_5088
Fix spurious ResourceWarning stderr in testsuite again
2019-10-07 16:26:38 -07:00
Anthony Sottile
271dc7f17a Merge pull request #5904 from asottile/warnings_v2
Add test to ensure _pytest is warning-clean on import
2019-10-06 19:24:07 -07:00
Anthony Sottile
19eb0590f1 Fix spurious ResourceWarning stderr in testsuite again 2019-10-06 19:11:33 -07:00
Bruno Oliveira
5186635387 Introduce no_fnmatch_line/no_re_match_line in pytester (#5914)
Introduce no_fnmatch_line/no_re_match_line in pytester
2019-10-06 20:27:20 -03:00
Daniel Hahler
cd398e289f Merge pull request #5920 from blueyed/lazy-import-pdb
Allow for "pdb" module to be rewritten
2019-10-06 23:46:11 +02:00
Anthony Sottile
eaa05531ed Add test to ensure _pytest is warning-clean on import 2019-10-06 14:11:08 -07:00
Bruno Oliveira
47c2091ecd Use new no-match functions to replace previous idiom 2019-10-06 18:05:24 -03:00
Bruno Oliveira
0c18e24433 Introduce no_fnmatch_line/no_re_match_line in pytester
The current idiom is to use:

  assert re.match(pat, result.stdout.str())

Or

  assert line in result.stdout.str()

But this does not really give good results when it fails.

Those new functions produce similar output to ther other match lines functions.
2019-10-06 18:05:24 -03:00
Daniel Hahler
07f20ccab6 Allow for "pdb" module to be rewritten 2019-10-06 23:02:24 +02:00
Daniel Hahler
b847d5712b Merge pull request #5923 from nicoddemus/mm
Merge master into features
2019-10-06 23:01:19 +02:00
Bruno Oliveira
74aed6ea4c Release 5.2.1 (#5917)
Release 5.2.1
2019-10-06 12:55:15 -03:00
Bruno Oliveira
cfa9ebc91f ci: test oldest supported attrs (#5922)
ci: test oldest supported attrs
2019-10-06 12:55:03 -03:00
Daniel Hahler
b0fd8742da ci: test oldest supported attrs 2019-10-06 16:12:56 +02:00
Bruno Oliveira
12cc729f6b Preparing release version 5.2.1 2019-10-06 08:00:49 -04:00
Bruno Oliveira
1c5efffd90 Add changelog entry for #5902 2019-10-06 07:58:23 -04:00
Bruno Oliveira
8c9ea5e055 Fix warnings with attrs 19.2 and fix object assertions (#5902)
Fix warnings with attrs 19.2 and fix object assertions
2019-10-06 08:47:17 -03:00
Anthony Sottile
c58b0fb4ac Use ATTRS_EQ_FIELD for attrs 19.2 compat 2019-10-05 18:16:35 -07:00
Anthony Sottile
4011af68cd Merge pull request #5910 from pytest-dev/asottile-patch-1
Fix dynamic scoping changelog link
2019-10-03 09:39:12 -07:00
Anthony Sottile
9637b3e376 Fix dynamic scoping changelog link 2019-10-03 09:01:08 -07:00
Anthony Sottile
33c3ec66b7 Merge pull request #5898 from kevinjfoley/doc-typo-fix
Fix doc typo
2019-10-01 12:58:54 -07:00
Hynek Schlawack
a79acf279a Fix warnings with attrs 19.2 and fix object assertions
attrs 19.2 deprecated cmp in favor of the dataclass-ish eq/order duo.

This causes deprecation warnings that in turn break some of the cool new deep
object comparisons. Since we at attrs expected this to be a problem, it shipped
with helpers to write backward and forward compatible code.

This PR uses that and avoids changed to minimal versions.
2019-10-01 20:47:59 +02:00
Bruno Oliveira
9a4c0b991b Update doc: pytest section in setup.cfg (#5894)
Update doc: pytest section in setup.cfg
2019-10-01 11:45:01 -03:00
Kevin J. Foley
b490f5f979 Fix doc typo 2019-10-01 10:17:26 -04:00
tadashigaki
acfd0fd9d6 Update doc: pytest section in setup.cfg 2019-10-01 02:44:07 +09:00
Bruno Oliveira
88434f1f42 Release 5.2.0 (#5885)
Release 5.2.0
2019-09-29 10:26:06 -03:00
Florian Bruhin
4d01740be3 Merge pull request #5887 from asottile/fix_attributes_docs_pytester
Fix attribute docs in _pytest.pytester
2019-09-29 14:22:54 +02:00
Anthony Sottile
07792c7113 Fix attribute docs in _pytest.pytester 2019-09-28 18:19:53 -07:00
Bruno Oliveira
068ef90b92 Preparing release version 5.2.0 2019-09-28 21:18:37 -04:00
Bruno Oliveira
065773aa97 Use 'python3' instead of 'python3.6' on tox
This allows us to use python3.7+ to use tox
2019-09-28 21:16:20 -04:00
Anthony Sottile
b62276826c Merge pull request #5886 from nicoddemus/setup-plan-custom-items-5884
Fix --setup-only and --setup-show for custom pytest items
2019-09-28 18:08:36 -07:00
Bruno Oliveira
7bdfba3578 Fix --setup-only and --setup-show for custom pytest items
Fix #5884
2019-09-28 11:52:09 -03:00
Daniel Hahler
6bfd30d169 Merge pull request #5878 from blueyed/codecov-retry-6
ci: codecov: use 6 retries with curl
2019-09-24 10:30:23 +02:00
Daniel Hahler
7731e45615 ci: codecov: use 6 retries with curl
This should result in retries of 1+2+4+8+16+32 = 63s.

Ref: https://github.com/pytest-dev/pytest/pull/5869#issuecomment-534235437
2019-09-23 20:58:52 +02:00
Anthony Sottile
8806b1f531 Merge pull request #5875 from asottile/patch-1
Make sure to quote `sys.executable` as we're running a shell
2019-09-23 18:55:33 +02:00
Anthony Sottile
19c9e53604 Make sure to quote sys.executable as we're running a shell 2019-09-23 08:58:56 -07:00
Bruno Oliveira
c28b63135f Merge master into features (#5874)
Merge master into features
2019-09-23 12:44:20 -03:00
Bruno Oliveira
7c64d5d882 Do not call python directly but use sys.executable. Fixes #5872 (#5873)
Do not call python directly but use sys.executable. Fixes #5872
2019-09-23 12:28:00 -03:00
Bruno Oliveira
d3d9f9f668 Merge remote-tracking branch 'upstream/master' into mm 2019-09-23 12:09:01 -03:00
Bruno Oliveira
018edf2a0e Change report-coverage.sh in attempt to fix Azure (#5869)
Change report-coverage.sh in attempt to fix Azure
2019-09-23 12:01:19 -03:00
Tomáš Chvátal
04c01fb606 test_argcomplete do not call python directly #5872
Use sys.executable to detect which python we should actually be testing.
2019-09-23 16:38:15 +02:00
Daniel Hahler
ea0c7e43b6 Remove unneeded codecov options (implied with "-f") 2019-09-23 02:26:53 +02:00
Bruno Oliveira
de8fdab7a9 Change report-coverage.sh in attempt to fix Azure
Recently sometimes Azure has failed with:

++ curl -s https://codecov.io/bash
bash: /dev/fd/63: No such file or directory

This attempts to fix this by modifying report-coverage.sh slightly.
2019-09-21 16:02:48 -03:00
Daniel Hahler
c1361b48f8 Merge pull request #5868 from blueyed/mm
Merge master into features
2019-09-21 16:29:49 +02:00
Bruno Oliveira
1b4ad7774b Fix logging doc: change x.level to x.levelno (#5866)
Fix logging doc: change x.level to x.levelno
2019-09-21 11:28:40 -03:00
Daniel Hahler
409cc2946a Merge master into features 2019-09-21 16:22:48 +02:00
Bruno Oliveira
3114be9181 Revert "Show banner/full page for the Digital Climate Strike (#… (#5867)
Revert "Show banner/full page for the Digital Climate Strike (#5861)"
2019-09-21 11:09:34 -03:00
Bruno Oliveira
e4103cb02c Release version 5.1.3 (#5859)
Release version 5.1.3
2019-09-21 10:56:16 -03:00
Bruno Oliveira
217605c217 Revert "Show banner/full page for the Digital Climate Strike (#5861)"
This reverts commit c8cf748c49, reversing
changes made to 702acdba46.
2019-09-21 10:38:10 -03:00
James Cooke
2fcf21a6c7 Fix logging doc: change x.level to x.levelno 2019-09-20 18:38:47 +01:00
Bruno Oliveira
c8cf748c49 Show banner/full page for the Digital Climate Strike (#5861)
Show banner/full page for the Digital Climate Strike
2019-09-19 10:49:10 -03:00
Bruno Oliveira
249b53e623 Show banner/full page for the Ditigal Climate Strike
As discussed in the mailing list, pytest will join the
digital strike for the climate on Sep 20th. This will show
a closable banner on the docs until the date, and when the date
comes the banner will become a (closable) full page.

I will also pin an issue saying that the developers won't be
available on Sep 20th.
2019-09-19 08:26:25 -03:00
Bruno Oliveira
9669413b1f Merge pull request #5776 from aklajnert/1682-dynamic-scope
Implemented the dynamic scope feature.
2019-09-19 08:22:45 -03:00
Andrzej Klajnert
e2382e96ed Minor cleanup in tests. 2019-09-19 11:13:22 +02:00
Bruno Oliveira
1a9f4a51cb Preparing release version 5.1.3 2019-09-18 10:11:59 -03:00
Bruno Oliveira
892bdd59dc Normalize all summary durations, including quiet ones 2019-09-18 10:10:25 -03:00
Bruno Oliveira
df46afc96d Change fixture argument handling tests to unit-tests 2019-09-18 07:50:35 -03:00
Bruno Oliveira
6918d07560 Merge remote-tracking branch 'upstream/features' into aklajnert/1682-dynamic-scope 2019-09-18 07:44:18 -03:00
Daniel Hahler
c997c32004 Merge pull request #5856 from blueyed/mm
Merge master into features
2019-09-17 21:47:40 +02:00
Daniel Hahler
450409d123 Merge master into features
Conflicts:
	src/_pytest/reports.py
        (via 7259c453d, moved the type annotation; setting it to `None`
        was removed in 3c82b1cb9 already)
2019-09-17 12:46:36 +02:00
Daniel Hahler
702acdba46 Merge pull request #5811 from blueyed/fulltrace-pytest-raises
Handle --fulltrace with pytest.raises
2019-09-14 02:09:36 +02:00
Daniel Hahler
f832ac3316 Handle --fulltrace with pytest.raises
This changes `_repr_failure_py` to use `tbfilter=False` always.
2019-09-14 01:41:43 +02:00
Bruno Oliveira
9422e10322 Fix regression due to different cases on Windows (#5840)
Fix regression due to different cases on Windows
2019-09-13 18:11:12 -03:00
Bruno Oliveira
5c3b4a6f52 Add CHANGELOG entry for #5792 2019-09-12 08:05:50 -03:00
Christian Neumüller
05850d73bd Re-introduce Christian Neumüller to AUTHORS
The introduction was reverted by cd29d56
2019-09-12 08:05:50 -03:00
Bruno Oliveira
b48f51eb03 Use Path() objects to store conftest files
Using Path().resolve() is better than py.path.realpath because
it resolves to the correct path/drive in case-insensitive file systems (#5792):

>>> from py.path import local
>>> from pathlib import Path
>>>
>>> local('d:\\projects').realpath()
local('d:\\projects')
>>> Path('d:\\projects').resolve()
WindowsPath('D:/projects')

Fix #5819
2019-09-12 08:05:50 -03:00
Bruno Oliveira
cf5b544db3 Revert "Merge pull request #5792 from dynatrace-oss-contrib/bugfix/badcase"
This reverts commit 955e542210, reversing
changes made to 0215bcd84e.

Will attempt a simpler approach
2019-09-12 08:05:43 -03:00
Bruno Oliveira
73c5b7f4b1 Clarify docs by showing tox.ini considered before setup.cfg (#5839)
Clarify docs by showing tox.ini considered before setup.cfg
2019-09-11 22:14:31 -03:00
Anthony Sottile
8f2f51be6d Clarify docs by showing tox.ini considered before setup.cfg 2019-09-11 14:07:06 -07:00
Andrzej Klajnert
f2f3ced508 Fixed the fixture function signature. 2019-09-10 16:20:44 +02:00
Bruno Oliveira
23102a7d84 Update doc regarding pytest.raises (#5834)
Update doc regarding pytest.raises
2019-09-09 16:18:58 -03:00
Gene Wood
f0d538329c Update doc regarding pytest.raises
Remove reference to the `message` argument in the docs as it was deprecated in #4539
2019-09-09 12:14:09 -07:00
Bruno Oliveira
6c8bcf601c Fix pypy3.6 on windows (#5828)
Fix pypy3.6 on windows
2019-09-08 12:11:28 -03:00
Anthony Sottile
9d7b919c7d Fix pypy3.6 on windows 2019-09-07 16:49:05 -07:00
Bruno Oliveira
333e9d5c10 Merge pull request #5824 from blueyed/revert-py350
ci: Travis: do not test with 3.5.0
2019-09-06 08:05:51 -03:00
Daniel Hahler
f1b605c95e ci: Travis: do not test with 3.5.0
This causes flaky test failures (crashes).

Closes https://github.com/pytest-dev/pytest/issues/5795.
2019-09-06 12:29:17 +02:00
Bruno Oliveira
2bb8d93001 Fix for Python 4: replace unsafe PY3 with PY2 (#5820)
Fix for Python 4: replace unsafe PY3 with PY2
2019-09-05 12:39:06 -03:00
Hugo
d049b35397 Fix for Python 4: replace unsafe PY3 with PY2 2019-09-05 18:06:47 +03:00
Bruno Oliveira
8ee557f7ae Fix pythonpath anchor (#5817)
Fix pythonpath anchor
2019-09-04 22:19:57 -03:00
Gene Wood
ca3884d9bb Add Gene Wood to authors 2019-09-04 09:21:10 -07:00
Gene Wood
bc163605ab Fix anchor link from Good Practices to Pythonpath doc 2019-09-04 09:18:10 -07:00
Bruno Oliveira
1675048b35 Merge pull request #5808 from goerz/pastebin
Fix "lexer" being used when uploading to bpaste.net
2019-08-31 16:11:39 -03:00
aklajnert
10bf6aac76 Implemented the dynamic scope feature. 2019-08-31 18:12:24 +02:00
Michael Goerz
f8dd6349c1 Fix "lexer" being used when uploading to bpaste.net
Closes #5806.
2019-08-30 15:34:03 -04:00
Bruno Oliveira
8c8809e1aa Merge pull request #5805 from nicoddemus/release-5.1.2
Release 5.1.2
2019-08-30 16:05:14 -03:00
Bruno Oliveira
e56544cb58 Preparing release version 5.1.2 2019-08-30 12:43:47 -03:00
Bruno Oliveira
f9cc704b1a Replace session duration to a fix value in regendoc 2019-08-30 12:42:14 -03:00
Bruno Oliveira
bd57307a39 Merge pull request #5768 from robholt/fixture-class-instance
Fix self reference in function scoped fixtures
2019-08-30 12:31:16 -03:00
Bruno Oliveira
667c6463ab Merge pull request #5803 from nicoddemus/flaky-5795
Mark flaky test as xfail on Python 3.5.0
2019-08-30 12:30:11 -03:00
Bruno Oliveira
4e594552eb Merge pull request #5798 from aklajnert/570-indirect-fixtures
Fix the scope behavior with indirect fixtures
2019-08-30 12:29:03 -03:00
Bruno Oliveira
955dc6d18a Merge remote-tracking branch 'upstream/master' into robholt/fixture-class-instance 2019-08-30 11:21:33 -03:00
Bruno Oliveira
3ddbc7fb2a Improve CHANGELOG and add some comments
Ref: #5768
2019-08-30 11:20:19 -03:00
Bruno Oliveira
bb60736a6f Run py35 without xdist on Travis
Due to the flaky tests in 3.5.0, drop running
py35 with xdist for now in the hope we get better error
messages.

Ref: #5795
2019-08-30 10:59:50 -03:00
Bruno Oliveira
35b3b1097f Improve CHANGELOG and make test easier to understand for #570 2019-08-30 10:54:58 -03:00
Bruno Oliveira
01082fea12 Serialize/deserialize chained exceptions (#5787)
Serialize/deserialize chained exceptions
2019-08-30 07:29:48 -03:00
Bruno Oliveira
404cf0c872 Merge pull request #5764 from goerz/pastebin
Gracefully handle HTTP errors from pastebin
2019-08-30 07:29:14 -03:00
Bruno Oliveira
a511b98da9 Serialize/deserialize chained exceptions
Fix #5786
2019-08-29 20:23:44 -03:00
Andrzej Klajnert
487659d8b1 Fix the scope behavior with indirect fixtures. 2019-08-29 07:23:08 +02:00
Bruno Oliveira
955e542210 Merge pull request #5792 from dynatrace-oss-contrib/bugfix/badcase
Fix pytest with mixed up filename casing.
2019-08-28 08:44:16 -03:00
Christian Neumüller
29bb0eda27 Move _uniquepath to pathlib as unique_path.
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-28 12:29:41 +02:00
Christian Neumüller
a98270eac0 Document the bugfix. 2019-08-27 16:36:40 +02:00
Christian Neumüller
1aac64573f black formatting. 2019-08-27 16:16:45 +02:00
Michael Goerz
d47b9d04d4 Gracefully handle HTTP errors from pastebin
We find that the --pastebin option to pytest sometimes fails with "HTTP
Error 400: Bad Request". We're still investigating the exact cause of
these errors, but in the meantime, a failure to upload to the pastebin
service should probably not crash pytest and cause a test failure in the
continuous-integration.

This patch catches exceptions like HTTPError that may be thrown while
trying to communicate with the pastebin service, and reports them as a
"bad response", without crashing with a backtrace or failing the entire
test suite.
2019-08-26 23:50:46 -04:00
Anthony Sottile
5bf9f9a711 Merge pull request #5788 from nicoddemus/mm
Merge master into features
2019-08-26 18:20:07 -07:00
Bruno Oliveira
c28e428249 Merge remote-tracking branch 'upstream/master' into mm 2019-08-26 20:00:30 -03:00
Christian Neumüller
505c3340bf Fix pytest with mixed up filename casing. 2019-08-26 17:18:46 +02:00
Bruno Oliveira
7a69365486 Move TWMock class to a fixture
Using a relative import like before was not very nice
2019-08-26 11:32:57 -03:00
Bruno Oliveira
3c82b1cb97 Refactor report serialization/deserialization code
Refactoring this in order to support chained exceptions
more easily.

Related to #5786
2019-08-26 10:54:25 -03:00
Bruno Oliveira
0215bcd84e update doc (#5784)
update doc
2019-08-25 13:41:17 -03:00
linchiwei123
01b9774e3b update doc 2019-08-25 23:50:41 +08:00
Bruno Oliveira
9859d37cf6 Merge pull request #5782 from linchiwei123/patch-1
Fix TypeError
2019-08-24 15:40:49 -03:00
Bruno Oliveira
1c7aeb670a Fix linting 2019-08-24 15:01:48 -03:00
Bruno Oliveira
691c706fcc Add test for #5782 2019-08-24 14:41:06 -03:00
linchiwei123
a4adf511fc Fix TypeError
can only concatenate str (not "bytes") to str
2019-08-24 23:10:17 +08:00
Anthony Sottile
4265ab3a41 Merge pull request #5773 from asottile/release-5.1.1
Preparing release version 5.1.1
2019-08-20 14:45:46 -07:00
Anthony Sottile
b135f5af8d Preparing release version 5.1.1 2019-08-20 11:30:36 -07:00
Anthony Sottile
daff9066c0 Merge pull request #5752 from bluetech/typing-py350-fix
Fix TypeError when importing pytest on Python 3.5.0 and 3.5.1
2019-08-20 08:04:58 -07:00
Ran Benita
c2f762460f Merge pull request #5673 from bluetech/type-annotations-3
1/X Fix check_untyped_defs = True mypy errors
2019-08-20 17:20:40 +03:00
Ran Benita
43eab917a1 Fix coverage 2019-08-20 15:41:32 +03:00
Ronny Pfannschmidt
0e569faca2 Merge pull request #5769 from The-Compiler/remove-training
Remove cancelled training
2019-08-20 11:48:36 +02:00
Ran Benita
a7c235732a Pypy doesn't have sys.getrefcount(), so go back to gc 2019-08-20 11:47:22 +03:00
Ran Benita
cec2183aeb Add workaround for test_raises_cyclic_reference in Python 3.5.{0,1} 2019-08-20 11:19:25 +03:00
Florian Bruhin
c049fd85ab Remove cancelled training 2019-08-19 22:07:53 +02:00
Robert Holt
62381125e7 Fix self reference in function scoped fixtures 2019-08-19 15:57:39 -04:00
Anthony Sottile
a7ede64f42 Move @overload to compat 2019-08-18 14:54:52 -07:00
Bruno Oliveira
307652202c Merge pull request #5762 from pytest-dev/hugovk-patch-1
Docs: update tense
2019-08-18 10:20:45 -03:00
Hugo van Kemenade
a287aea00e Docs: update tense
pytest 4.6.0 was released in June 2019

https://pypi.org/project/pytest/#history
2019-08-18 13:34:59 +03:00
Anthony Sottile
6bf6265c59 Merge pull request #5760 from blueyed/F401
minor: make noqa comment more specific
2019-08-17 19:54:04 -07:00
Daniel Hahler
7c26a65865 minor: make noqa comment more specific 2019-08-17 23:48:55 +02:00
Daniel Hahler
1e3205e7cf ci: Travis: use 3.5.0
Ref: https://github.com/pytest-dev/pytest/pull/5752#issuecomment-522241225
2019-08-17 23:10:01 +02:00
Daniel Hahler
32dac18f38 Merge pull request #5755 from blueyed/fix-assert-location-with-coverage
Fix wrong location of assertion error with Coverage.py .

Reverts using-constant part from 39ba996.

Fixes https://github.com/pytest-dev/pytest/issues/5754.
2019-08-17 22:49:00 +02:00
Daniel Hahler
f05ca74d27 Merge pull request #5056 from blueyed/argparsing-width
Inject width via pylib to argparse formatter
2019-08-17 21:46:02 +02:00
Daniel Hahler
e5f4c47cd5 test_assertion: minor cleanup 2019-08-17 21:38:52 +02:00
Daniel Hahler
05bfe73cf9 Fix wrong location of assertion error with coverage.py
Reverts using-constant part from 39ba99613.

Fixes https://github.com/pytest-dev/pytest/issues/5754.
2019-08-17 21:34:13 +02:00
Daniel Hahler
2a6a1ca07d Inject width via pylib to argparse formatter
`argparse.HelpFormatter` looks at `$COLUMNS` only, falling back to a
default of 80.

`py.io.get_terminal_width()` is smarter there, and could even work
better with https://github.com/pytest-dev/py/pull/219.

This ensures to use a consistent value for formatting the ini values etc.
2019-08-17 16:51:02 +02:00
Ran Benita
9f3bfe82cf Fix TypeError when importing pytest on Python 3.5.0 and 3.5.1
The typing module on these versions have these issues:

- `typing.Pattern` cannot appear in a Union since it is not considered a
  class.

- `@overload` is not supported in runtime. (On the other hand, mypy
  doesn't support putting it under `if False`, so we need some runtime
  hack).

Refs #5751.
2019-08-17 15:41:59 +03:00
Bruno Oliveira
c3a8e609f9 Merge pull request #5750 from nicoddemus/fix-gh-publish-notes
Forward $TRAVIS_REPO_SLUG for GH publish notes
2019-08-16 15:57:01 -03:00
Ran Benita
7259c453d6 Fix some check_untyped_defs = True mypy warnings 2019-08-16 10:41:57 +03:00
Ran Benita
28761c8da1 Have AssertionRewritingHook derive from importlib.abc.MetaPathFinder
This is nice for self-documentation, and is the type required by mypy
for adding to sys.meta_path.
2019-08-16 10:41:52 +03:00
Bruno Oliveira
d9c4e646c4 Forward TRAVIS_REPO_SLUG env var for GH publish notes
Fix #5749
2019-08-15 22:50:55 -03:00
Bruno Oliveira
8ccc0177c8 Release 5.1.0 (#5748)
Release 5.1.0
2019-08-15 22:35:59 -03:00
Bruno Oliveira
eaf7ce9a99 Preparing release version 5.1.0 2019-08-15 20:00:09 -04:00
Anthony Sottile
ac3056c5a2 Merge pull request #5747 from blueyed/coveragerc-report
.coveragerc: add report section
2019-08-15 16:52:43 -07:00
Bruno Oliveira
409d61b972 Merge remote-tracking branch 'upstream/master' into release-5.1.0 2019-08-15 19:46:46 -04:00
Daniel Hahler
6ead01aacd testing/python/fixtures.py: use NotImplementedError pattern 2019-08-16 01:14:19 +02:00
Daniel Hahler
4c37dca011 .coveragerc: add report section
This will allow for "raise NotImplementedError" to indicate code not to
be covered in tests etc.
2019-08-16 01:14:19 +02:00
Daniel Hahler
44c10dbd5f Merge pull request #5746 from blueyed/codecov-comment-off
ci: add codecov.yml to turn comments off
2019-08-16 01:13:19 +02:00
Bruno Oliveira
0f11a7a73d Merge master into features (#5744)
Merge master into features
2019-08-15 19:12:37 -03:00
Daniel Hahler
d50198a3ff ci: add codecov.yml to turn comments off
The only benefit for me is to get notified about finished builds, but
that might happen to early anyway.  Apart from that they are rather big
and distract from actual comments.
2019-08-15 23:54:03 +02:00
Bruno Oliveira
ac052a98ad reword a parametrize example sentence (#5745)
reword a parametrize example sentence
2019-08-15 14:00:30 -03:00
mei-li
f4a84a8dfd reword a parametrize example sentence 2019-08-15 18:12:18 +02:00
Bruno Oliveira
1049a38cee Fix wording as suggested in review of #5741 2019-08-15 10:05:42 -03:00
Bruno Oliveira
d7f082519a Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
	src/_pytest/outcomes.py
2019-08-15 10:03:52 -03:00
Bruno Oliveira
2d613a03b3 Async result warn (#5742)
Async result warn
2019-08-15 09:47:56 -03:00
Bruno Oliveira
28c6c5bb71 check that tests that are partial staticmethods are supported (#5701)
check that tests that are partial staticmethods are supported
2019-08-15 09:12:01 -03:00
Thomas Grainger
6b9d729ed3 also warn on awaitable or async iterable test results 2019-08-15 12:30:44 +01:00
Bruno Oliveira
0ba774a7c3 warn for async generator functions (#5734)
warn for async generator functions
2019-08-15 08:17:12 -03:00
Bruno Oliveira
0a62c4ac04 Merge pull request #5729 from Stranger6667/issue-5115
Do not treat warnings as errors during ``pytest_configure``.
2019-08-15 08:05:15 -03:00
Thomas Grainger
137255816e Fix collection of staticmethods defined with functools.partial
Related to #5701
2019-08-15 08:04:05 -03:00
Thomas Grainger
2f1b192fe6 Issue a warning for async gen functions
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-15 07:54:10 -03:00
dmitry.dygalo
7183335e62 Capture warnings during `pytest_configure`
Fix #5115
2019-08-15 07:50:27 -03:00
Bruno Oliveira
0822a1e53a Merge pull request #5740 from nicoddemus/use-repo-env-var
Use TRAVIS_REPO_SLUG instead of hard-coding pytest-dev/pytest
2019-08-14 21:46:57 -03:00
Bruno Oliveira
cb94fd31c8 Use TRAVIS_REPO_SLUG instead of hard-coding pytest-dev/pytest
I was doing final tests on the script today, and forgot to change
the hardecoded "pytest-dev/pytest", which ended up publishing a
`4.99.10` release to the main repository by mistake, as my token
has access to both my fork and main repository.

I deleted the tag immeditely just a few seconds later, so hopefully
this won't cause major problems.

This change makes it safer to test this in the future, never publishing
to the main repository by mistake (as long as the tags are pushed to the
right repositories of course).
2019-08-14 20:29:16 -03:00
Bruno Oliveira
fa75d818cf pytester: spawn: skip without pexpect.spawn (#5736)
pytester: spawn: skip without pexpect.spawn
2019-08-14 18:06:06 -03:00
Daniel Hahler
1434b66c35 pytester: spawn: skip without pexpect.spawn
"pexpect" can be imported on Windows, but does not have "pexpect.spawn"
then.

Ref: https://github.com/pexpect/pexpect/blob/a803933ed53/pexpect/__init__.py#L73-L76
2019-08-13 17:54:40 +02:00
Bruno Oliveira
a24132ddc5 Publish GitHub release notes after deployment (#5723)
Publish GitHub release notes after deployment
2019-08-12 13:20:16 -03:00
Daniel Hahler
ed2425119f Merge pull request #5731 from blueyed/assert-compare-maxsize
assertrepr_compare: prefer same maxsize
2019-08-12 16:02:41 +02:00
Bruno Oliveira
a295a3ddaf test_non_ascii_paste_text: mock call to urlopen (#5728)
test_non_ascii_paste_text: mock call to urlopen
2019-08-12 10:56:38 -03:00
Bruno Oliveira
3b3ce0e799 remove %s formatting from docs (#5733)
remove %s formatting from docs
2019-08-12 10:21:31 -03:00
Bruno Oliveira
1a61265b1e Publish GitHub release notes after deployment
Fix #2933
2019-08-12 10:18:43 -03:00
Ran Benita
67ac878ccf Merge pull request #5732 from blueyed/drop-py2
assertion.rewrite: use ast.NameConstant(None) directly
2019-08-12 12:19:40 +03:00
boris
3eb4973065 remove %s formatting from docs 2019-08-12 00:09:53 -06:00
Daniel Hahler
39ba996133 assertion.rewrite: use ast.NameConstant(None) directly
`ast.parse("None")` was added/used in 3e6f1fa2d for differences between
Python 2/3, but we do not support py2 anymore.
2019-08-12 07:50:52 +02:00
Daniel Hahler
cb481a354a assertrepr_compare: prefer same maxsize
Previously it would say:

    > assert '123456789012...901234567890A' == '1234567890123...901234567890B'"

This makes it look like the "3" might be different already.

This is clearer, and it is OK to have potentially one less char in the
right one:

    > assert '123456789012...901234567890A' == '123456789012...901234567890B'"
2019-08-12 03:41:14 +02:00
Bruno Oliveira
300f78556f Show session duration in human-readable format (#5721)
Show session duration in human-readable format
2019-08-10 23:05:34 -03:00
Daniel Hahler
0db9dade65 test_non_ascii_paste_text: mock call to urlopen
Likely to fix flaky coverage due to requests failing sometimes.
Ref: f7e81dab9a...83a1f4bd66/changes
2019-08-10 23:30:49 +02:00
Daniel Hahler
a77c83a4c3 Merge pull request #5726 from jdufresne/black
Update URL: python/black → psf/black
2019-08-10 22:25:38 +02:00
Jon Dufresne
0767f080a4 Update URL: python/black → psf/black 2019-08-10 12:38:13 -07:00
Bruno Oliveira
2498aeaaa5 Merge master into features (#5717)
Merge master into features
2019-08-10 11:16:40 -03:00
Bruno Oliveira
345df99db7 Show session duration in human-readable format
Fix #5707
2019-08-10 10:45:53 -03:00
Anthony Sottile
8665f5652a Merge pull request #5722 from nicoddemus/improvements-changelog
Add new 'improvement' changelog category
2019-08-10 06:31:39 -07:00
Bruno Oliveira
beb457c75e Add new 'improvement' changelog category
This creates a separate section from 'features' for small changes which
don't usually require user intervention, such as:

* Human readable session duration
* New junitxml fields
* Improved colors in terminal
* etc.

The idea is to better match user expectations about new actual
features in the "Features" section of the changelog.
2019-08-10 09:33:51 -03:00
Bruno Oliveira
f7e81dab9a 5669: pytester: add docstrings for Testdir.copy_example (#5719)
5669: pytester: add docstrings for Testdir.copy_example
2019-08-10 09:00:42 -03:00
Ilya Stepin
ee936b27a8 pytester: fix docstrings
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-08-10 09:12:04 +03:00
martbln
e0ce8b79d5 pytester: add docstrings for Testdir.copy_example 2019-08-10 00:59:14 +03:00
Bruno Oliveira
8ffa3aa65d Improve docs of pytest.importorskip (#5718)
Improve docs of pytest.importorskip
2019-08-09 18:28:44 -03:00
Tim Hoffmann
b095e0de47 Improve docs of pytest.importorskip 2019-08-09 21:35:03 +02:00
Bruno Oliveira
2f065a555f Merge remote-tracking branch 'upstream/master' into release-5.1.0 2019-08-09 12:36:19 -03:00
Bruno Oliveira
ec76f70d71 Remove unused function CallSpec2.setall (#5716)
Remove unused function CallSpec2.setall
2019-08-09 12:35:07 -03:00
Bruno Oliveira
65e6038111 Validate xunit2 files against the schema (#5605)
Validate xunit2 files against the schema
2019-08-09 12:34:21 -03:00
Daniel Hahler
9f6da8cbeb Remove unused function CallSpec2.setall
Fixes https://github.com/pytest-dev/pytest/issues/5253.
2019-08-09 16:34:48 +02:00
Bruno Oliveira
ba72b480b9 Remove xfail marker from test_runs_twice_xdist
Apperently it does not hang, let's see how it fares on CI
2019-08-09 10:55:06 -03:00
Bruno Oliveira
ba76080b59 Validate xunit2 files against the schema
Fix #5095
2019-08-09 10:55:06 -03:00
Bruno Oliveira
5ecac3c861 Add a code of conduct (#5711)
Add a code of conduct
2019-08-08 12:37:14 -03:00
Florian Bruhin
0a19439677 Add a code of conduct
See #5709 and the mails linked from there
2019-08-08 14:01:29 +02:00
Bruno Oliveira
e772bb6480 trivial doc change (#5708)
trivial doc change
2019-08-08 08:10:36 -03:00
boris
7560a7b808 trivial doc change 2019-08-07 21:49:30 -06:00
Bruno Oliveira
6c8d8a99f4 pyupgrade docs to Python 3 (#5705)
pyupgrade docs to Python 3
2019-08-07 07:27:34 -03:00
boris
78de9d4677 replace implicit code tag with colon .replace("::\n\n.. code-block", ":\n\n.. code-block") 2019-08-06 16:20:06 -07:00
boris
23a0b532db Revert "remove implicit code tags .replace("::\n\n.. code-block", "\n\n.. code-block")"
This reverts commit 9fce0bdd88.
2019-08-06 16:18:06 -07:00
boris
9fce0bdd88 remove implicit code tags .replace("::\n\n.. code-block", "\n\n.. code-block") 2019-08-06 15:46:57 -07:00
Bruno Oliveira
28fabc52bd fix grammar in test_collect_functools_partial docstr (#5703)
fix grammar in test_collect_functools_partial docstr
2019-08-06 19:24:24 -03:00
boris
5f95dce956 ran blacken-docs 2019-08-06 13:34:58 -07:00
boris
75d0b899bb ran pyupgrade-docs again 2019-08-06 13:33:21 -07:00
boris
7f90e74e02 label code blocks 2019-08-06 13:25:54 -07:00
boris
cf7761f91f ran pyupgrade-docs 2019-08-06 12:40:27 -07:00
Thomas Grainger
ef0915e1db fix grammar in test_collect_functools_partial docstr 2019-08-06 15:27:36 +01:00
Bruno Oliveira
68c486a25f Add CHANGELOG for 4.6.5 (#5696) (#5699)
Add CHANGELOG for 4.6.5 (#5696)
2019-08-05 16:25:24 -03:00
Bruno Oliveira
f5fab2bfa1 Merge master into features (#5698)
Merge master into features
2019-08-05 15:20:54 -03:00
Bruno Oliveira
f43b54aaeb Add CHANGELOG for 4.6.5 (#5696) 2019-08-05 15:09:31 -03:00
Daniel Hahler
aa06e6c8f3 Merge master into features 2019-08-05 19:12:32 +02:00
Daniel Hahler
bf3aa72a29 Merge pull request #5697 from blueyed/fix-collect-pkg-init
Fix RuntimeError when trying to collect package with "__init__.py" only
2019-08-05 18:20:28 +02:00
Daniel Hahler
198fcd8a6f Fix RuntimeError when trying to collect package with "__init__.py" only
Fixes https://github.com/pytest-dev/pytest/issues/4344.
2019-08-05 17:52:21 +02:00
Bruno Oliveira
f7e925dcc1 Add hostname and timestamp to JUnit XML testsuite tag (#5692)
Add hostname and timestamp to JUnit XML testsuite tag
2019-08-05 10:19:15 -03:00
Bruno Oliveira
cf6632a57a Rename 5471.trivial.rst to 5471.feature.rst 2019-08-05 10:19:05 -03:00
Anthony Sottile
1a66a503b6 Merge pull request #5690 from nicoddemus/custom-exit-code-docs
Mention pytest-custom_exit_code in the docs
2019-08-04 19:10:36 -07:00
Anthony Sottile
82763a293a Merge pull request #5684 from nicoddemus/errno-nomore
Use OSError subclasses instead of handling errno
2019-08-04 14:50:12 -07:00
Anthony Sottile
73e0bf92f7 Merge pull request #5694 from yashtodi94/public_access_to_exitcode_doc_change
Added info to access exitcodes directly
2019-08-04 14:48:23 -07:00
Yash Todi
0d5ed57b40 Added info to access exitcodes directly 2019-08-04 22:35:51 +05:30
Samuel Searles-Bryant
1ce45a6f67 Add hostname and timestamp to JUnit XML testsuite tag
Fix #5471
2019-08-03 15:54:39 +01:00
Bruno Oliveira
8db6642515 Mention pytest-custom_exit_code in the docs
Related to #5689
2019-08-03 10:15:56 -03:00
Daniel Hahler
29e336bd9b Merge pull request #5687 from blueyed/merge-master
Merge master into features
2019-08-03 14:12:02 +02:00
Bruno Oliveira
d3e1907899 Use OSError subclasses instead of handling errno 2019-08-02 14:17:46 -03:00
Daniel Hahler
b5b710b3ae Merge master into features
Several conflicts, mostly due to 2c402f4bd.

Conflicts:
	.pre-commit-config.yaml
	src/_pytest/outcomes.py
	src/_pytest/python_api.py
	tox.ini
2019-08-02 16:52:51 +02:00
Bruno Oliveira
0d3958e8de Handle only known functions in rm_rf (#5627)
Handle only known functions in rm_rf
2019-08-02 10:23:12 -03:00
Daniel Hahler
9064eea216 Improve rm_rf to handle only known functions
Warnings are emitted if we cannot safely remove
paths.

Fix #5626
2019-08-02 08:18:11 -03:00
Bruno Oliveira
dc6e7b9fcf Cache splitnode results to improve tests collection time (#5681)
Cache splitnode results to improve tests collection time
2019-08-01 22:32:19 -03:00
Alexey Zankevich
b43ebb7d65 Cache split nodes results to reduce long tests collection time on large test suites 2019-08-01 20:46:27 -04:00
Anthony Sottile
8a5e72c936 Merge pull request #5682 from nicoddemus/disable-shallow-copy
Disable shallow cloning because of setuptools-scm
2019-08-01 09:28:26 -07:00
Bruno Oliveira
cd924b66ca Disable shallow cloning because of setuptools-scm
setuptools-scm needs all tags to guess the version correctly
2019-08-01 12:29:39 -03:00
Anthony Sottile
1076a7e61d Merge pull request #5680 from ss18/ss18/pr0
Fix some typos
2019-08-01 08:18:48 -07:00
Bruno Oliveira
cff58457dd Fix the confusing different names of fulltrace (#5668)
Fix the confusing different names of `fulltrace`
2019-08-01 10:30:17 -03:00
Semen Zhydenko
b3f4398d64 surpressing -> suppressing 2019-08-01 15:11:38 +02:00
Semen Zhydenko
2ca47cb3f5 programatically -> programmatically 2019-08-01 15:11:26 +02:00
Semen Zhydenko
d19fe3c410 didnt -> didn't 2019-08-01 15:10:39 +02:00
Semen Zhydenko
2de145f372 wasnt -> wasn't 2019-08-01 15:10:06 +02:00
Semen Zhydenko
942fd91995 shouldnt -> shouldn't 2019-08-01 15:09:14 +02:00
Florian Bruhin
cb15e7c700 Merge pull request #5674 from helloocc/master
Doc fix: remove redundant parentheses.
2019-07-30 10:46:29 +02:00
Xixi Zhao
2959fb3198 Doc fix: remove redundant parentheses. 2019-07-30 16:18:22 +08:00
Kaiqi
aa13c625da Change the warning message 2019-07-27 21:06:29 +02:00
Kaiqi
958374addb Remove name from author 2019-07-27 17:26:52 +02:00
Kaiqi
6c2f673daf Have same name for fulltrace 2019-07-27 17:25:23 +02:00
Anthony Sottile
fd2fb36eac Merge pull request #5665 from hroncok/i5664
In test_xfail_handling, only remove __pycache__ if it exists
2019-07-25 18:35:35 -07:00
Miro Hrončok
ab39502c98 In test_xfail_handling, only remove __pycache__ if it exists
Previously, the test failed when the directory was not present,
which could have been caused for example by invoking the tests
with PYTHONDONTWRITEBYTECODE=1.

Fixes https://github.com/pytest-dev/pytest/issues/5664
2019-07-26 02:23:14 +02:00
Bruno Oliveira
50c7b5d2b5 fix setenv prepend docs (#5658)
fix setenv prepend docs
2019-07-24 20:11:05 -03:00
Thomas Grainger
3bdcd6b4f3 Update doc/en/monkeypatch.rst 2019-07-24 20:49:31 +01:00
Bruno Oliveira
d89c88478d Merge pull request #5657 from helloocc/master
Doc fix: delete useless.
2019-07-24 15:22:58 -03:00
Thomas Grainger
635916052c fix setenv prepend docs 2019-07-24 17:23:48 +01:00
Bruno Oliveira
bd34bd872a fix docs about syspath_prepend (#5656)
fix docs about syspath_prepend
2019-07-24 13:19:05 -03:00
helloocc
1d8f668e10 Add author. 2019-07-24 23:44:37 +08:00
helloocc
28343bdcbd Merge remote-tracking branch 'upstream/master' 2019-07-24 23:35:22 +08:00
Thomas Grainger
ebfe8eabf5 Update doc/en/monkeypatch.rst 2019-07-24 14:27:51 +01:00
Thomas Grainger
829cc5a242 fix docs about syspath_prepend
eg it does not modify $PATH
2019-07-24 14:27:05 +01:00
Bruno Oliveira
7fa27485df Merge pull request #5648 from nicoddemus/improve-exc-info-changelog
Make ExceptionInfo.repr change more prominent
2019-07-23 21:24:48 -03:00
Bruno Oliveira
b2839c4084 Merge pull request #5646 from nicoddemus/mark-info-docs
Update MarkDecorator docs
2019-07-23 16:42:11 -03:00
Bruno Oliveira
880e368607 Merge pull request #5653 from blueyed/fix-test
Followup: unittest: handle outcomes.Exit
2019-07-23 15:09:24 -03:00
Daniel Hahler
b9111fe677 Fix changelog 2019-07-23 19:38:33 +02:00
Daniel Hahler
401c3d1109 tests: unittest: fix/harden "test_exit_outcome"
Ref: https://github.com/pytest-dev/pytest/pull/5634#pullrequestreview-265565917
2019-07-23 19:35:51 +02:00
Bruno Oliveira
2a724a1c81 Fix fixture example and regendocs (#5651)
Fix fixture example and regendocs
2019-07-23 11:53:13 -03:00
Bruno Oliveira
52ad5a1591 Improve output when parsing an ini configuration fails (#5650)
Improve output when parsing an ini configuration fails
2019-07-23 11:17:42 -03:00
Bruno Oliveira
4abf95ba4f Merge pull request #5644 from blueyed/rm-_orig_args
Replace internal config._origargs with invocation_params.args
2019-07-23 11:03:52 -03:00
Bruno Oliveira
f163b37f6a Run regen 2019-07-23 10:00:35 -04:00
Bruno Oliveira
a82dd2f064 Fix linting 2019-07-23 10:55:22 -03:00
Bruno Oliveira
1873dc6a8a Fix fixture example in docs 2019-07-23 09:48:22 -04:00
Florian Bruhin
8c47db724c Improve output when parsing an ini configuration fails 2019-07-23 15:27:27 +02:00
Bruno Oliveira
693e9d0733 Merge pull request #5634 from blueyed/fix-unittest-exit
unittest: handle outcomes.Exit
2019-07-23 10:08:43 -03:00
Bruno Oliveira
5c09cc16f2 Add changelog entry for #5634 2019-07-23 08:55:14 -03:00
Bruno Oliveira
0824789459 Improve test for pytest.exit handling 2019-07-23 08:53:38 -03:00
Bruno Oliveira
ec4ca59bf0 Merge pull request #5631 from RonnyPfannschmidt/fix-5606
use identity checks for the mock sentinels
2019-07-23 08:48:58 -03:00
Bruno Oliveira
3c94f32e77 Make ExceptionInfo.repr change more prominent
Related to #5579
2019-07-23 08:42:03 -03:00
Bruno Oliveira
d66b6c8371 Update MarkDecorator docs
The MarkInfo class no longer exists
2019-07-23 08:07:38 -03:00
Xixi Zhao
6e687c4354 Doc fix: m1 isn't a dependency of f1.
According to the file in `example/fixtures/test_fixtures_order.py`, m1 isn't a dependency of f1.
2019-07-23 15:09:32 +08:00
William Woodall
13d8577451 README: fix typo
Closes https://github.com/pytest-dev/pytest/pull/5643.
2019-07-23 06:50:51 +02:00
Daniel Hahler
3c7438969a Replace internal config._origargs with invocation_params.args
Added in https://github.com/pytest-dev/pytest/pull/5564.
2019-07-23 06:46:56 +02:00
Xixi Zhao
66cfc66d63 Update index.rst 2019-07-22 16:01:56 +08:00
Anthony Sottile
13c4b7d212 Merge pull request #5636 from asottile/fixup_sysmodules_test
Fix ordering of sys modules snapshot
2019-07-20 12:30:18 -07:00
Ronny Pfannschmidt
8c7d9124ba switch num_mock_patch_args to do identity checks for the sentinels 2019-07-20 20:21:27 +02:00
Bruno Oliveira
240d314f36 copy test and changelog from #5607 by @niccodemus 2019-07-20 20:21:27 +02:00
Anthony Sottile
27c9d80a7e Fix ordering of sys modules snapshot 2019-07-20 11:17:30 -07:00
Bruno Oliveira
cb828ebe70 tox.ini: clean up filterwarnings (#5633)
tox.ini: clean up filterwarnings
2019-07-20 11:59:23 -03:00
Daniel Hahler
d35d09f82d unittest: handle outcomes.Exit
This is required for pytest to stop when using "quit" in pdb, and should
get honored/handled in general.
2019-07-20 07:11:49 +02:00
Daniel Hahler
f0feb6c83a fixup! tox.ini: clean up filterwarnings 2019-07-20 01:54:04 +02:00
Daniel Hahler
dcbb9c1f5a tox.ini: clean up filterwarnings
- path.local/path.readlines is not used anymore
- enhance doc for "invalid escape sequence" filter
2019-07-20 01:24:04 +02:00
Anthony Sottile
c05fcc8641 Merge pull request #5615 from bluetech/type-annotations-2
Improve mypy setup + a few minor type fixes and removals
2019-07-19 06:48:24 -07:00
Florian Bruhin
c98e7aed94 Merge pull request #5628 from pytest-dev/leipzig-training-info-1
Add info about open training in Leipzig
2019-07-19 14:57:47 +02:00
Daniel Hahler
63d517645c doctest: handle BdbQuit
Map `BdbQuit` exception to `outcomes.Exit`.

This is necessary since we are not wrapping `pdb.set_trace` there, and
therefore our `do_quit` is not called.
2019-07-19 02:57:25 +02:00
Oliver Bestwalter
c0231ae780 Add info about open training in Leipzig 2019-07-18 21:06:53 +02:00
Ran Benita
675e9507d8 Don't accept bytes message in pytest.{fail,xfail,skip}
It seems to have been added in #1439 to fix #1178.

This was only relevant for Python 2 where it was tempting to use str (==
bytes) literals instead of unicode literals. In Python 3, it is unlikely
that anyone passes bytes to these functions.
2019-07-17 22:39:10 +03:00
Ran Benita
0b532fda76 Remove unnecessary checks from SetupState
Since 4622c28ffd, _finalizers cannot
contain Nones or tuples, so these checks are not longer needed.
2019-07-17 22:39:10 +03:00
Ran Benita
7d1c697c30 Remove a no-longer-needed check if enum is available
Not needed since 4d49ba6529.
2019-07-17 22:39:10 +03:00
Ran Benita
65aee1e0c8 Allow bytes for OutcomeException(msg=...)
It's __repr__ explicitly handles it so allow it.
2019-07-17 22:39:10 +03:00
Ran Benita
8d413c1926 Allow tuple of exceptions in ExceptionInfo.errisinstance
isinstance() accepts it and some code does pass a tuple.

Fixup for commit 55a570e513.
2019-07-17 22:39:10 +03:00
Ran Benita
104f8fc836 Update mypy from 0.711 to 0.720
Release notes: http://mypy-lang.blogspot.com/2019/07/mypy-0720-released.html
2019-07-17 22:39:10 +03:00
Bruno Oliveira
157515f3c5 Fix/Remove broken links (#5613)
Fix/Remove broken links
2019-07-17 13:52:05 -03:00
Bruno Oliveira
183750fa86 CSS changes to the API reference (#5609)
CSS changes to the API reference
2019-07-17 06:24:31 -03:00
Ran Benita
fd8f92d0e7 Run mypy on src/ and testing/ together
This makes testing/ actually pick up the pytest imports -- otherwise
they are opaque and we don't actually test the types.

A single run is also a bit faster and simpler. The original reason why
we split it is no longer relevant (we fixed the problems).
2019-07-16 23:29:02 +03:00
Steffen Schroeder
1e34734f8f Fixed link to Python Classifiers 2019-07-16 21:56:04 +02:00
Steffen Schroeder
7c2e843358 Fixed link to correct anchor of Python's -w postion 2019-07-16 21:56:04 +02:00
Steffen Schroeder
79414164c2 Fixed broken links in adopt.rst 2019-07-16 21:56:03 +02:00
Steffen Schroeder
0cca7f831a Fixed broken links and non-existing anchors in release announcements 2019-07-16 21:56:03 +02:00
Steffen Schroeder
1f4ae789b8 Change link to "Where do Google's flaky tests come from?"
Although it's available, linkchecker complained about it.
It was changed to the permanent redirect.
2019-07-16 21:56:03 +02:00
Steffen Schroeder
3f46315a9d Remove link to non-existing anchor 2019-07-16 21:56:03 +02:00
Steffen Schroeder
e03b8b9e95 Update/Fix links to using projects 2019-07-16 21:56:03 +02:00
Steffen Schroeder
eb7f950e20 Fixed broken link to virtualenv 2019-07-16 21:56:03 +02:00
Steffen Schroeder
848b735a06 Fixed links to non existing GitHub users and py 2019-07-16 21:56:03 +02:00
Steffen Schroeder
7337cce332 Fixed links were content was from 'writing_plugins' to 'reference' 2019-07-16 21:56:02 +02:00
Steffen Schroeder
7a5c0a01bc Fixed links were content was moved to 'historical' 2019-07-16 21:56:02 +02:00
Ran Benita
faf222f8fb Merge pull request #5593 from bluetech/type-annotations-1
Type-annotate pytest.{exit,skip,fail,xfail,importorskip,warns,raises}
2019-07-16 22:38:20 +03:00
Ran Benita
9258fd1296 Merge pull request #5603 from bluetech/saferepr-simplify
Simplify SafeRepr a bit
2019-07-16 22:37:02 +03:00
Thomas Grainger
7440cece59 Merge pull request #5589 from graingert/fixture-yield-exit-stack
de-emphasize request.addfinalizer Fixes #5587
2019-07-16 18:33:59 +01:00
Anthony Sottile
f1332872a6 Merge pull request #5611 from mxr/patch-1
Remove language_version specification in black hooks
2019-07-16 10:15:28 -07:00
Bruno Oliveira
ac12245f5f Merge pull request #5612 from The-Compiler/new-trainings-2
Remove Europython training
2019-07-16 14:00:04 -03:00
Florian Bruhin
d9eab12ee0 Remove Europython training 2019-07-16 15:03:54 +02:00
Max R
2e756d698b Remove language_version specification in black hooks
Resolves #3840
2019-07-16 08:32:24 -04:00
Bruno Oliveira
15e235c63e Remove obsolete "importorskip('unittest.mock')" calls (#5608)
Remove obsolete "importorskip('unittest.mock')" calls
2019-07-16 04:41:58 -03:00
Bruno Oliveira
65c23017c7 Update test_getfuncargnames_patching to work with modern mock 2019-07-15 12:23:59 -03:00
Tim Hoffmann
bb7608c56f Change section titles in docs 2019-07-15 16:25:33 +02:00
Bruno Oliveira
8a3f40996a Remove obsolete "importorskip('unittest.mock')" calls 2019-07-15 11:18:05 -03:00
Tim Hoffmann
6f1d358a0c Fix some ReST indentation issues in docstrings 2019-07-15 16:16:44 +02:00
Tim Hoffmann
3ad315bcee Improve CSS layout of API reference 2019-07-15 16:15:59 +02:00
Ran Benita
129600d698 saferepr: Avoid indirect function calls
The DRY savings they provide are rather small, while they make it harder
to type-check, and IMO harder to understand.
2019-07-15 17:07:58 +03:00
Thomas Grainger
a96710dd8a demonstrate ExitStack assuming connect returns a context manager 2019-07-15 14:05:19 +01:00
Bruno Oliveira
54e08b729f More CSS fine-tuning (#5604)
More CSS fine-tuning
2019-07-15 09:42:18 -03:00
Tim Hoffmann
01606315aa More CSS fine-tuning 2019-07-15 13:40:30 +02:00
Bruno Oliveira
8f2f3bb1fa Improve CSS layout (#5602)
Improve CSS layout
2019-07-14 19:02:58 -03:00
Bruno Oliveira
499fda2349 Various cleanups in src/_pytest/python.py (#5599)
Various cleanups in src/_pytest/python.py
2019-07-14 19:00:35 -03:00
Ran Benita
c7aacc96bb saferepr: Remove unused setting of max_other
max_other is used by the superclass repr_instance, but we override it
and use maxsize instead.
2019-07-14 22:50:14 +03:00
Ran Benita
0394ebffee saferepr: Use an __init__ instead of setting attributes after construction
This will be easier to type-check, and also somewhat clearer.
2019-07-14 22:50:14 +03:00
Ran Benita
0225be53a2 saferepr: Remove dead SafeRepr.repr_unicode
This function is not called anywhere directly, and cannot be called by
the dynamic `repr_<type>()` dispatch mechanism because unicode is no
longer a type in Python 3.
2019-07-14 22:13:57 +03:00
Tim Hoffmann
da5add1294 Improve CSS layout 2019-07-14 18:58:07 +02:00
Ran Benita
11f1f79222 Allow creating ExceptionInfo from existing exc_info for better typing
This way the ExceptionInfo generic parameter can be inferred from the
passed-in exc_info. See for example the replaced cast().
2019-07-14 14:28:24 +03:00
Ran Benita
3f1fb62584 Rework ExceptionInfo to not require manual __init__ call
Mypy doesn't like calling __init__() in this way.
2019-07-14 14:28:24 +03:00
Ran Benita
14bf4cdf44 Make ExceptionInfo generic in the exception type
This way, in

    with pytest.raises(ValueError) as cm:
        ...

cm.value is a ValueError and not a BaseException.
2019-07-14 14:28:24 +03:00
Ran Benita
56dcc9e1f8 Type-annotate pytest.raises 2019-07-14 14:28:24 +03:00
Ran Benita
55a570e513 Type-annotate ExceptionInfo 2019-07-14 14:28:24 +03:00
Ran Benita
2dca68b863 Type-annotate pytest.warns 2019-07-14 14:28:24 +03:00
Ran Benita
d7ee3dac2c Type-annotate pytest.{exit,skip,fail,xfail,importorskip} 2019-07-14 14:28:24 +03:00
Ran Benita
866904ab80 Revert "Let context-managers for raises and warns handle unknown keyword arguments"
This reverts commit dfe54cd82f.

The idea in the commit was to simplify the code by removing the check
and instead letting it TypeError which has the same effect.

However this type error is caught by mypy, and rather than ignoring the
error we think it's better and clearer to go back to the previous
explicit check.
2019-07-14 14:28:21 +03:00
Ran Benita
35a57a0dfb Use flake8's extend-ignore instead of ignore
extend-ignore adds ignores in addition to flake8's existing ignores.

The default ignores currently are:
E121,E123,E126,E226,E24,E704,W503,W504
2019-07-14 11:12:47 +03:00
Florian Bruhin
6afbac29a3 Merge pull request #5600 from wojtekerbetowski/issues/3404
Add autouse fixture order information (#3404).
2019-07-13 03:22:15 -07:00
Wojtek Erbetowski
d23fbab188 Add autouse fixture order information (#3404).
A case with a fixture use both as an autouse and explititly
was raised. This case sounds too narrow to add to documentation
(and could be misleading for people learning pytest with explicitely
using an autouse fixture). At the same time there was no documentation
on the autouse vs regular fixture order, therefore this commit adds
such an information. Code sample grew and it was extracted to the file.
2019-07-13 11:43:47 +02:00
Ronny Pfannschmidt
374c4325a8 refactor finding xunit setup/teardown functions
s/_get_non_fixture_func(obj, name: str)/_get_first_non_fixture_func(obj, names: List[str])/
2019-07-13 08:13:46 +02:00
Ronny Pfannschmidt
2c071a060e refactor resolve_arg_value_types
* more explicit type checks
* expand from list+tuple to sequence
2019-07-13 08:13:46 +02:00
Bruno Oliveira
0f8b462677 Include <testsuites> root tag in generated XML (#5550)
Include <testsuites> root tag in generated XML
2019-07-12 14:35:34 -03:00
Ronny Pfannschmidt
898028cb22 remove unused _get_xunit_setup_teardown 2019-07-12 17:45:23 +02:00
Ronny Pfannschmidt
4480d3e518 generate_tests: always use call_extra
- its a noop addition in the methods is empty list
2019-07-12 17:44:17 +02:00
Bruno Oliveira
4868d0d97a Drop unittest2 support (#5565)
Drop unittest2 support
2019-07-12 11:13:51 -03:00
Bruno Oliveira
8052c7c5c6 Fix typos in a docstring (#5598)
Fix typos in a docstring
2019-07-12 07:37:50 -03:00
Ronny Pfannschmidt
13d750db20 simplify the expression which transfers mark names to keywords 2019-07-12 06:16:06 +02:00
Ronny Pfannschmidt
e98627223f remove the noop init of PyobjMixin 2019-07-12 06:14:36 +02:00
Albert Tugushev
c89e379f49 Fix typos 2019-07-12 02:35:44 +03:00
Bruno Oliveira
24a66db8d3 Remove support code for unittest 2
Also moved a pytest_runtest_makereport hook implemented in
nose.py, but nowadays makes more sense to be implemented in
unittest.py
2019-07-11 20:11:06 -03:00
Bruno Oliveira
4027254a4b Fix rmtree to remove directories with read-only files (#5588)
Fix rmtree to remove directories with read-only files
2019-07-11 18:57:03 -03:00
Bruno Oliveira
37c37963c4 Fix rmtree to remove directories with read-only files
Fix #5524
2019-07-11 18:24:53 -03:00
Bruno Oliveira
666acc9b7a doctest: Add +NUMBER option to ignore irrelevant floating-point… (#5576)
doctest: Add +NUMBER option to ignore irrelevant floating-point differences
2019-07-11 07:25:37 -03:00
David Röthlisberger
a740ef2036 docs: Document doctest +NUMBER limitation with strings
Also added an "xfail" testcase for the same.
2019-07-11 10:06:57 +01:00
David Röthlisberger
4c590e002f Fix test_doctest.test_number_non_matches
These doctests were expected to fail, but they were failing because of a
silly bug (I forgot to replace "{expression}" with the actual expression
to be tested), not because of the thing they were meant to be testing.

Then I had to fix one of the testcases because it was actually matching:

    >>> 3.0 #doctest: +NUMBER
    2.99

The doctest is saying that the actual output should match to 2 decimal
places, i.e. within 0.01 -- which it is, so it passes. I changed the
expected output to 2.98 and now it doesn't match (as we expect).
2019-07-11 09:57:44 +01:00
Anthony Sottile
26b06bdb45 Merge pull request #5595 from blueyed/typos
doc: fix typos in OPENCOLLECTIVE.rst  [ci skip]
2019-07-10 14:01:16 -07:00
Daniel Hahler
d5f1d7aebe doc: fix typos in OPENCOLLECTIVE.rst [ci skip] 2019-07-10 20:15:22 +02:00
Ran Benita
f7747f5dd6 Remove references to old-style classes in a couple error messages
These don't exist in Python 3.
2019-07-10 20:25:45 +03:00
Thomas Grainger
c224c4f1d6 de-emphasize request.addfinalizer 2019-07-10 14:52:40 +01:00
Bruno Oliveira
2c402f4bd9 [cherry-pick to master] Add rudimentary mypy type checking (#5583)
[cherry-pick to master] Add rudimentary mypy type checking
2019-07-10 07:52:32 -03:00
Bruno Oliveira
602cd5e21f Introduce Config.invocation_params (#5564)
Introduce Config.invocation_params
2019-07-10 07:46:34 -03:00
Bruno Oliveira
57e5bd0664 Improve type-checking in OutcomeException (#5580)
Improve type-checking in OutcomeException
2019-07-09 19:12:05 -03:00
Bruno Oliveira
31738155b5 Remove deprecated features (#5529)
Remove deprecated features
2019-07-09 19:04:06 -03:00
Bruno Oliveira
9db1823707 Improve type-checking in OutcomeException
Fix #5578
2019-07-09 18:26:57 -03:00
Ran Benita
89dfde9535 Add rudimentary mypy type checking
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.

This enables:

- Progressively adding type annotations and enabling more strict
  options, which will improve the codebase (IMO).

- Annotating the public API in-line, and eventually exposing it to
  library users who use type checkers (with a py.typed file).

Though, none of this is done yet.

Refs https://github.com/pytest-dev/pytest/issues/3342.
2019-07-09 12:12:07 -07:00
Anthony Sottile
39a43dbae1 Merge pull request #5575 from bluetech/mypy-initial
Add rudimentary mypy type checking
2019-07-09 08:05:14 -07:00
Ran Benita
c1167ac552 Add rudimentary mypy type checking
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.

This enables:

- Progressively adding type annotations and enabling more strict
  options, which will improve the codebase (IMO).

- Annotating the public API in-line, and eventually exposing it to
  library users who use type checkers (with a py.typed file).

Though, none of this is done yet.

Refs https://github.com/pytest-dev/pytest/issues/3342.
2019-07-09 10:49:17 +03:00
Bruno Oliveira
628ff4d619 Improve docs sidebar layout (#5568)
Improve docs sidebar layout
2019-07-08 19:24:48 -03:00
Bruno Oliveira
add912ff68 Update doc footer/copyright (#5569)
Update doc footer/copyright
2019-07-08 19:21:38 -03:00
Bruno Oliveira
b77c876481 Merge pull request #5563 from nicoddemus/sort-fix
Sort parametrize params to test_external_plugins_integrated
2019-07-08 19:10:45 -03:00
Bruno Oliveira
9b78a216a2 Remove unused import 2019-07-08 19:08:09 -03:00
Bruno Oliveira
7aff51ee83 Show warning about importing abcs from collections once
This is being raised by `unittest2.compatibility`:

DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
2019-07-08 17:30:15 -03:00
Bruno Oliveira
e33736c791 Merge master into features (#5559)
Merge master into features
2019-07-08 17:26:49 -03:00
David Röthlisberger
d5cc0f2a62 changelog for new NUMBERS doctest option 2019-07-08 17:16:35 +01:00
David Röthlisberger
2a23fdab9f docs: Tidy up doctest options section
* Move the parts about "how to configure it" (pytest.ini vs. inline
  comment) together.
* Move `--doctest-continue-on-failure` into its own sub-heading, as it
  isn't related to the doctest optionflags.
2019-07-08 17:07:58 +01:00
David Röthlisberger
aaa7e837cc doctest: Add +NUMBER option to ignore irrelevant floating-point differences
When enabled, floating-point numbers only need to match as far as the
precision you have written in the expected doctest output. This avoids
false positives caused by limited floating-point precision, like this:

    Expected:
        0.233
    Got:
        0.23300000000000001

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

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

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

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

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

Advantages of this implementation compared to numtest:

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

[numtest]: https://github.com/boisgera/numtest
2019-07-08 17:07:58 +01:00
Tim Hoffmann
71c8ca7d3d Improve sidebar layout 2019-07-07 20:32:09 +02:00
Tim Hoffmann
56a0dd7658 Update doc footer/copyright 2019-07-07 20:23:56 +02:00
Bruno Oliveira
7a82285b03 Update CHANGELOG 2019-07-06 17:29:35 -03:00
Bruno Oliveira
4cda7093f6 Add note about PYTEST_ADDOPTS 2019-07-06 17:27:54 -03:00
Bruno Oliveira
6a9bf2852a Apply review suggestions: use a simple struct for invocation params 2019-07-06 12:22:19 -03:00
Bruno Oliveira
3e669a262a Introduce Config.invocation_args and Config.invocation_plugins
These attributes can be used to access the unchanged arguments passed
to pytest.main().

The intention is to use these attributes to initialize workers in
the same manner as the master node is initialized in pytest-xdist.
2019-07-05 19:45:23 -03:00
Bruno Oliveira
f1b8431d99 Sort parametrize params to test_external_plugins_integrated
This might cause problems during collection with pytest-xdist; we
didn't see any so far mostly by luck I think.

Shame on me for letting that slip in.
2019-07-05 19:05:55 -03:00
Bruno Oliveira
a43ba78d3b Include <testsuites> root tag in generated XML
Fix #5477
2019-07-05 11:29:35 -03:00
Bruno Oliveira
2180d9ef6d Fix comment in stepwise (follow up to #5555) [skip ci] (#5560)
Fix comment in stepwise (follow up to #5555) [skip ci]
2019-07-05 10:26:37 -03:00
Bruno Oliveira
0371a3023a Fix comment in stepwise (follow up to #5555) [skip ci] 2019-07-05 09:57:10 -03:00
Bruno Oliveira
d7588b8d40 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2019-07-05 08:14:18 -03:00
Bruno Oliveira
b62b549f5f Preparing release version 5.0.1 (#5557)
Preparing release version 5.0.1
2019-07-05 08:13:37 -03:00
Bruno Oliveira
60a358fa2d Replace importlib_metadata with importlib.metadata on Python 3.… (#5539)
Replace importlib_metadata with importlib.metadata on Python 3.8+
2019-07-04 21:46:43 -03:00
Bruno Oliveira
bb29f31d22 Preparing release version 5.0.1 2019-07-04 20:01:16 -04:00
Bruno Oliveira
b1928f878d Handle xfail(strict=True) properly in --step-wise mode (#5555)
Handle xfail(strict=True) properly in --step-wise mode
2019-07-04 20:50:33 -03:00
Bruno Oliveira
8651d880a0 Handle xfail(strict=True) properly in --step-wise mode
Fix #5547
2019-07-04 20:28:37 -03:00
Bruno Oliveira
95824c588a Improve quoting in raises match failure message (#5553)
Improve quoting in raises match failure message
2019-07-04 10:25:27 -03:00
Miro Hrončok
c54cbd63c8 Replace importlib_metadata with importlib.metadata on Python 3.8+
Fixes https://github.com/pytest-dev/pytest/issues/5537
2019-07-04 15:00:10 +02:00
Bruno Oliveira
1db132290f Apply workaround for multiple short options for Python <= 3.8
Hopefully by Python 3.9 this will be fixed upstream, if not we will
need to bump the version again.

Fix #5523
2019-07-04 14:59:40 +02:00
Anthony Sottile
caa08ebd45 Improve quoting in raises match failure message 2019-07-04 05:55:26 -07:00
Bruno Oliveira
b08ae4449b Add docs about Tidelift and OpenCollective (#5527)
Add docs about Tidelift and OpenCollective
2019-07-04 07:38:17 -03:00
Anthony Sottile
776a632170 Merge pull request #5540 from bazcrown/yml2yaml
Substituted 'yml' to '.yaml' in relevant files
2019-07-03 18:47:26 -04:00
Bruno Oliveira
d74a975f82 remove documentation about setuptools integration Refs #5534 Fi… (#5546)
remove documentation about setuptools integration Refs #5534 Fixes #3814
2019-07-03 16:01:30 -03:00
Bruno Oliveira
dfe54cd82f Let context-managers for raises and warns handle unknown keyword arguments
As suggested during review
2019-07-03 13:57:28 -03:00
Thomas Grainger
2b9522e9da remove documentation about setuptools integration Refs #5534
integrating with `python setup.py test` is not good practice!
2019-07-03 16:42:53 +01:00
Bruno Oliveira
528ee3e1c5 Add upcoming trainings (#5544)
Add upcoming trainings
2019-07-03 10:45:14 -03:00
Florian Bruhin
9677099acf Add upcoming trainings 2019-07-03 14:50:32 +02:00
Michael Moore
1b0e8d73d5 Substituted 'yml' to '.yaml' in relevant files 2019-07-02 23:49:06 -07:00
Bruno Oliveira
50b846e9d3 Merge pull request #5538 from avallbona/patch-2
Added talk about pytest in PyBCN June 2019
2019-07-02 19:46:10 -03:00
Andreu Vallbona Plazas
fa9791127a Added talk about pytest in PyBCN June 2019
Added talk about pytest in PyBCN June 2019
2019-07-02 23:18:52 +02:00
Bruno Oliveira
2d9b432613 Add docs about Tidelift and OpenCollective
Give an overview of how we as an organization will use the donated money,
as well as show this information more prominently in the docs.
2019-06-30 14:13:30 -03:00
Bruno Oliveira
5d8da88e9e Merge pull request #5530 from AmirElkess/patch-1
update CONTRIBUTING.rst
2019-06-30 14:07:27 -03:00
Bruno Oliveira
0da690c8e9 Update AUTHORS (#5531)
Update AUTHORS
2019-06-30 14:07:10 -03:00
AmirElkess
e32c903fb6 Update AUTHORS 2019-06-30 18:32:07 +02:00
Bruno Oliveira
0ed7aa2db6 Make 'request' a reserved name for fixtures 2019-06-30 13:31:39 -03:00
Bruno Oliveira
85cc12e328 Move FIXTURE_FUNCTION_CALL constant to the point of error
This is no longer a deprecation so it makes sense to move it
to the place where it is needed instead of leaving it in deprecated.py
2019-06-30 13:31:39 -03:00
Bruno Oliveira
c470ade0a5 Remove 'RemovedInPytest4Warning' 2019-06-30 13:31:39 -03:00
AmirElkess
9972c78cfa update CONTRIBUTING.rst
The following edits are for the "Preparing pull requests" section only.
1. remove Python2-related commands.
2. clarifying some details for beginners. Such as that pre-commit must to be installed as admin to function properly.
3. Added "You may not create a changelog entry if the change doesn't affect the documented behaviour of Pytest." on line 270.
2019-06-30 18:29:37 +02:00
Bruno Oliveira
3a17c1b30b Remove 'pytest_logwarning' hook 2019-06-30 13:18:07 -03:00
Bruno Oliveira
7b35405033 Remove YIELD_TESTS from deprecated module as it is now an error 2019-06-30 13:18:07 -03:00
Bruno Oliveira
aa1955de72 Remove 'tmpdir_factory.ensuretemp' 2019-06-30 13:18:07 -03:00
Bruno Oliveira
7e58defc15 Remove 'pytest.config' 2019-06-30 13:18:07 -03:00
Bruno Oliveira
f2b7809d5d Move setup.cfg error message and tests to an appropriate location
Those are not really deprecated anymore and are part of the normal
code for config
2019-06-30 13:18:07 -03:00
Bruno Oliveira
647d89c444 Move code about 'pytest_plugins' error to a more appropriate place
It is no longer deprecated, but part of the normal code for 'config'
2019-06-30 13:18:07 -03:00
Bruno Oliveira
683b2632b4 Remove explicit kwargs handling from raises, warns and ParameterSet.param 2019-06-30 13:18:06 -03:00
Bruno Oliveira
13f7f27fd2 Remove 'message' parameter from pytest.raises 2019-06-30 13:18:06 -03:00
Bruno Oliveira
279733a30b Remove support for 'code as string' from pytest.raises and pytest.warns 2019-06-30 11:40:24 -03:00
Bruno Oliveira
be91c4d932 Remove Request.getfuncargvalue 2019-06-30 11:02:46 -03:00
Bruno Oliveira
497cd87fdd Apply workaround for multiple short options for Python <= 3.8 (#5526)
Apply workaround for multiple short options for Python <= 3.8
2019-06-29 12:33:00 -03:00
Bruno Oliveira
94a05e513e Run py38-xdist as part of the build instead of cron 2019-06-29 11:19:50 -03:00
Bruno Oliveira
9021194efd Apply workaround for multiple short options for Python <= 3.8
Hopefully by Python 3.9 this will be fixed upstream, if not we will
need to bump the version again.

Fix #5523
2019-06-29 11:15:28 -03:00
Bruno Oliveira
d4a76a0b99 doc(plugin_hooks): Improve documentation for writing plugin hoo… (#5517)
doc(plugin_hooks): Improve documentation for writing plugin hooks.
2019-06-29 09:39:49 -03:00
Bruno Oliveira
789a3662ce Fix linting 2019-06-29 09:11:09 -03:00
Niklas Meinzer
93a68cdfb4 doc(plugin_hooks): Improve documentation for writing plugin hooks. 2019-06-29 14:02:53 +02:00
Anthony Sottile
4f9bf028f5 Merge pull request #5522 from nicoddemus/merge-master-into-features
Merge master into features
2019-06-28 20:22:56 -07:00
Anthony Sottile
4bc0415720 Merge pull request #5521 from asottile/cherry-pick-maintenance-release
4.6.4 changelog notes
2019-06-28 19:28:44 -07:00
Anthony Sottile
844d660d5c Merge pull request #5520 from asottile/release-4.6.4
Preparing release version 4.6.4
2019-06-28 19:09:10 -07:00
Anthony Sottile
2c6453c72d Merge pull request #5509 from asottile/release-5.0.0
Preparing release version 5.0.0
2019-06-28 18:12:16 -07:00
Bruno Oliveira
e6ffa78e59 Refactoring doctests (#5518)
Refactoring doctests
2019-06-28 19:15:02 -03:00
Anthony Sottile
58bfc7736f Use shutil.which to avoid distutils+imp warning 2019-06-28 14:44:49 -07:00
Anthony Sottile
97f0a20ca9 Add notice about py35+ and move ExitCode changelog entry 2019-06-28 14:40:10 -07:00
Anthony Sottile
55d2fe076f Use importlib instead of imp in demo 2019-06-28 14:40:10 -07:00
Anthony Sottile
5e39eb91bb Correct Zac-HD's name in changelogs 2019-06-28 14:40:10 -07:00
Anthony Sottile
fd2f320485 Preparing release version 5.0.0 2019-06-28 14:39:53 -07:00
Bruno Oliveira
73d918db55 Remove astor and reproduce the original assertion expression (#5512)
Remove astor and reproduce the original assertion expression
2019-06-28 18:36:11 -03:00
Anthony Sottile
7ee244476a Remove astor and reproduce the original assertion expression 2019-06-28 13:38:52 -07:00
AmirElkess
bf39e89946 Refactoring doctests 2019-06-28 21:16:17 +02:00
Bruno Oliveira
3c9b46f781 Remove stray comment from tox.ini (#5507)
Remove stray comment from tox.ini
2019-06-27 15:12:57 -03:00
Anthony Sottile
f7bfbb557e Merge pull request #5506 from asottile/fix_no_terminal
Fix crash when discovery fails while using `-p no:terminal`
2019-06-27 10:46:43 -07:00
Anthony Sottile
45af361a67 Remove stray comment from tox.ini 2019-06-27 10:46:08 -07:00
Anthony Sottile
4e723d6750 Fix crash when discovery fails while using -p no:terminal 2019-06-27 10:24:29 -07:00
Bruno Oliveira
65fbdf2568 Don't crash with --pyargs and a filename that looks like a modu… (#5503)
Don't crash with --pyargs and a filename that looks like a module
2019-06-27 13:53:02 -03:00
Bruno Oliveira
5ef507982c Add Open Collective to FUNDING.yml (#5504)
Add Open Collective to FUNDING.yml
2019-06-27 13:49:58 -03:00
Florian Bruhin
2479a91e92 Add Open Collective to FUNDING.yml 2019-06-27 17:53:03 +02:00
Anthony Sottile
3e0e31a364 Don't crash with --pyargs and a filename that looks like a module 2019-06-27 08:32:32 -07:00
Anthony Sottile
c9923a3a5c Merge pull request #5499 from nicoddemus/cleanup-py35-rewrite
Remove py<35 compatibility code from rewrite.py
2019-06-26 21:31:54 -07:00
Bruno Oliveira
1be49e713a Remove py<35 compatibility code from rewrite.py 2019-06-26 21:44:10 -03:00
Bruno Oliveira
37fb50a3ed Features assertion pass hook (#3479)
Features assertion pass hook
2019-06-26 21:14:19 -03:00
Bruno Oliveira
790806e865 Merge pull request #5494 from Zac-HD/funcargnames-to-fixturenames
Deprecate funcargnames alias for fixturenames
2019-06-26 21:13:59 -03:00
Bruno Oliveira
2ea22218ff Cover assertions with messages when enable_assertion_pass_hook is enabled 2019-06-26 20:46:31 -03:00
Bruno Oliveira
629eb3ec6a Move formatting variables under the "has impls" if
Small optimization, move the generation of the intermediate
formatting variables inside the 'if _check_if_assertion_pass_impl():'
block.
2019-06-26 19:26:12 -03:00
Bruno Oliveira
8edf68f3c0 Add a trivial note about astor 2019-06-26 19:21:12 -03:00
Bruno Oliveira
3afee36ebb Improve docs and reference 2019-06-26 19:15:00 -03:00
Bruno Oliveira
fcbe66feba Restore proper handling of '%' in assertion messages 2019-06-26 18:51:27 -03:00
Bruno Oliveira
eb90f3d1c8 Fix default value of 'enable_assertion_pass_hook' 2019-06-26 17:54:24 -03:00
Victor Maryama
6854ff2acc Fixed import order pep8. 2019-06-26 19:05:17 +02:00
Victor Maryama
53234bf613 Added config back to AssertionWriter and fixed typo in check_if_assertion_pass_impl function call. 2019-06-26 19:00:31 +02:00
Victor Maryama
6f851e6cbb Merge remote-tracking branch 'upstream/master' into features-assertion-pass-hook-master
# Conflicts:
#	src/_pytest/assertion/rewrite.py
2019-06-26 18:12:56 +02:00
Victor Maryama
9a34d88c8d Explanation variables only defined if failed or passed with plugins implementing the hook. 2019-06-26 18:10:16 +02:00
Victor Maryama
d91a5d3cd7 Further reverting changes. 2019-06-26 18:10:16 +02:00
Victor Maryama
f755ff6af1 Black formatting. 2019-06-26 18:10:16 +02:00
Victor Maryama
d638da5821 Using ini-file option instead of cmd option. 2019-06-26 18:10:16 +02:00
Victor Maryama
0fb52416b1 Reverted changes. 2019-06-26 18:10:15 +02:00
Bruno Oliveira
6a2d844c5d Fix typo replace circuting with circuiting. (#5497)
Fix typo replace `circuting` with `circuiting`.
2019-06-26 11:09:22 -03:00
Bruno Oliveira
a48feb3261 Delete 5497.trivial.rst
Just a typo, no need for a changelog entry. :)
2019-06-26 11:09:04 -03:00
Anthony Sottile
6cf8e71dca Merge pull request #5496 from pytest-dev/stray_comment
Delete stray comment
2019-06-26 05:59:38 -07:00
Tim Gates
994c32235c Fix rst support 2019-06-26 20:46:09 +10:00
Tim Gates
d81f758285 Update changelog with trivial as per ./CONTRIBUTING.rst 2019-06-26 20:31:45 +10:00
Tim Gates
fdb6e35b1b Fix typo replace circuting with circuiting. 2019-06-26 20:23:35 +10:00
Victor Maryama
7efdd5063b Update src/_pytest/assertion/rewrite.py
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-06-26 10:50:27 +02:00
Anthony Sottile
bfba33ec9e Delete stray comment 2019-06-25 20:24:13 -07:00
Anthony Sottile
3f3f3e7a29 Merge pull request #5495 from nicoddemus/blueyed/cmp-bytes
Improve comparison of byte strings (supersedes #5267)
2019-06-25 19:16:24 -07:00
Bruno Oliveira
aaf40314d1 Do not attempt to rewrite non-source files (#5490)
Do not attempt to rewrite non-source files
2019-06-25 20:43:23 -03:00
Bruno Oliveira
3f2344e8f7 Show bytes ascii representation instead of numeric value 2019-06-25 20:40:25 -03:00
Daniel Hahler
8c7eb82363 Fix/improve comparison of byte strings
Fixes https://github.com/pytest-dev/pytest/issues/5260.
2019-06-25 20:15:45 -03:00
Bruno Oliveira
1aefb24b37 Merge features into master (#5491)
Merge features into master
2019-06-25 20:02:02 -03:00
Zac Hatfield-Dodds
ed85c83154 Deprecate funcargnames alias 2019-06-26 08:53:17 +10:00
Anthony Sottile
bd647fdd8b Revert allow_abbrev=False in helper scripts 2019-06-25 14:50:07 -07:00
Victor Maryama
80ac910a24 Added msg to docstring for cleaning pyc. 2019-06-25 19:49:57 +02:00
Victor Maryama
4db5488ed8 Now dependent on command line option. 2019-06-25 19:49:05 +02:00
Victor Maryama
cfbfa53f2b Using pytester subprocess to avoid keeping references in the HookRecorder. 2019-06-25 17:46:56 +02:00
Victor Maryama
db50a975fd Reverted leak fixture test. 2019-06-25 17:23:14 +02:00
Bruno Oliveira
019455298b Merge remote-tracking branch 'upstream/features' into merge-features-into-master 2019-06-25 12:07:54 -03:00
Bruno Oliveira
64a6365227 Include pytest version in the cached pyc tags (#5484)
Include pytest version in the cached pyc tags
2019-06-25 12:07:01 -03:00
Anthony Sottile
b991810f32 Do not attempt to rewrite non-source files 2019-06-25 08:00:20 -07:00
Zac Hatfield-Dodds
4d5780facf Merge pull request #5469 from Zac-HD/disallow-abbrev
Disallow abbreviated command-line options
2019-06-25 22:38:52 +10:00
Victor Maryama
81e3f3cf95 Black formatting 2019-06-25 10:41:11 +02:00
Victor Maryama
2280f28596 Black formatting. 2019-06-25 10:36:01 +02:00
Victor Maryama
f8c9a7b86d Formatting and removed py2 support. 2019-06-25 10:35:42 +02:00
Victor Maryama
98b212cbfb Added "experimental" note. 2019-06-25 10:35:09 +02:00
Zac Hatfield-Dodds
d72fb73fa0 Do not allow abbreviated arguments 2019-06-25 13:51:33 +10:00
Bruno Oliveira
a54e2e19f5 Clarify changelog entries should be rst files (#5485)
Clarify changelog entries should be rst files
2019-06-24 22:33:40 -03:00
Bruno Oliveira
37fce6c6e5 Pickup addition positional args passed to _parse_parametrize_ar… (#5483)
Pickup addition positional args passed to _parse_parametrize_args
2019-06-24 22:05:19 -03:00
Kevin J. Foley
23aa3bb0ae Clarify changelog entries should be rst files 2019-06-24 20:55:51 -04:00
Kevin J. Foley
95714436a1 Pickup additional positional args passed to _parse_parametrize_args 2019-06-24 20:43:52 -04:00
Bruno Oliveira
f43fb13179 Include pytest version in the cached pyc tags
Fix #1671
2019-06-24 20:37:07 -03:00
Bruno Oliveira
3f5b078462 Merge pull request #5441 from nicoddemus/faulthandler-5440
Integrate pytest-faulthandler into the core
2019-06-24 20:01:15 -03:00
Bruno Oliveira
63c4802be0 minor: clarify help with reportchars (#5475)
minor: clarify help with reportchars
2019-06-24 19:59:15 -03:00
Anthony Sottile
a24933b0a6 Merge pull request #5481 from asottile/minor_py3_cleanup
Use new raise syntax in one case
2019-06-24 12:06:53 -07:00
Anthony Sottile
380ca8f880 Use new raise syntax in one case 2019-06-24 11:24:03 -07:00
Anthony Sottile
61dcb84f0d Merge pull request #5468 from asottile/switch_importlib_to_imp
Switch from deprecated imp to importlib
2019-06-24 11:22:01 -07:00
Anthony Sottile
4cd08f9b52 Switch from deprecated imp to importlib 2019-06-24 09:48:38 -07:00
Victor Maryama
52e695b329 Removed debug code. 2019-06-24 17:47:48 +02:00
Victor Maryama
9a89783fbb Assertion passed hook 2019-06-24 16:09:39 +02:00
Daniel Hahler
01a094cc43 minor: clarify help with reportchars
`-ra` / `-rA` will include "w" also.  This does not explicitly mention
it (allowing for change the behavior), but makes it a) clearer that "w"
is a recognized reportchar, and b) less confusing that `-ra
--disable-warnings` still displays them.
2019-06-24 06:07:52 +02:00
Bruno Oliveira
3ce31b6370 Change pytest-faulthandler for simplification
* The --no-faulthandler option is not necessary given that we can use
  `-p no:faulthandler`.

* The `--faulthandler-timeout` command-line option has become an ini
  option, for the reasons described in
  https://github.com/pytest-dev/pytest-faulthandler/issues/34 and
  users can still set it from the command-line.

Fix pytest-dev/pytest-faulthandler#34
2019-06-22 19:22:43 -03:00
Bruno Oliveira
3d01dd3adf Update cache.rst (#5465)
Update cache.rst
2019-06-21 21:12:30 -03:00
Bruno Oliveira
a37b902afe Integrate pytest-faulthandler into the core
* Add pytest-faulthandler files unchanged
* Adapt imports and tests
* Add code to skip registration of the external `pytest_faulthandler`
  to avoid conflicts

Fix #5440
2019-06-21 21:02:24 -03:00
curiousjazz77
12b76b6261 Update cache.rst 2019-06-21 15:48:59 -07:00
Bruno Oliveira
b713460cc7 fix typos in the resolution of #5125 (#5458)
fix typos in the resolution of #5125
2019-06-17 16:55:26 -03:00
Ronny Pfannschmidt
0627d92df2 fix typos in the resolution of #5125 2019-06-17 20:35:23 +02:00
Bruno Oliveira
b38a4e8e11 Fix stepwise crash when first collected module fails (#5446)
Fix stepwise crash when first collected module fails
2019-06-16 10:43:18 -03:00
Bruno Oliveira
689ce112e7 Small cleanups on _pytest.compat (#5451)
Small cleanups on _pytest.compat
2019-06-16 10:42:07 -03:00
Bruno Oliveira
87fc5a5455 Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types' (#5452)
Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types'
2019-06-16 10:41:40 -03:00
Bruno Oliveira
bbfc8d1501 conversion of exit codes to enum + exposure (#5420)
conversion of exit codes to enum  + exposure
2019-06-16 10:41:18 -03:00
Bruno Oliveira
ab6ed381ac Improve ExitCode docstring 2019-06-15 20:53:46 -03:00
Ronny Pfannschmidt
1cfea5f1b3 add ExitCode reference in usage 2019-06-15 21:41:55 +02:00
Daniel Hahler
cf27af734e Merge pull request #5404 from Zac-HD/helpful-mock-unwrapper
Emit warning for broken object
2019-06-15 18:54:03 +02:00
Ronny Pfannschmidt
8b3b10b14b pre-commit 2019-06-15 17:41:13 +02:00
Ronny Pfannschmidt
103d6146b0 document exitcode members 2019-06-15 17:18:21 +02:00
Ronny Pfannschmidt
065fa17124 update cangelog to fit review suggestion 2019-06-15 17:03:40 +02:00
Bruno Oliveira
43e8576ca3 Make pytest warnings show as from 'pytest' module instead of '_pytest.warning_types'
When we configure warnings as errors, users see error messages like this:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       _pytest.warning_types.PytestWarning: some warning

This is a problem because suggests the user should use `_pytest.warning_types.PytestWarning` to configure
their warning filters, which is not nice.

This commit changes the message to:

        def test():
    >       warnings.warn(pytest.PytestWarning("some warning"))
    E       pytest.PytestWarning: some warning
2019-06-15 11:48:34 -03:00
Bruno Oliveira
d8fa434d39 Remove Python 2-only workaround 2019-06-15 10:45:16 -03:00
Bruno Oliveira
177af032d2 Remove unused/unneeded code 2019-06-15 10:45:16 -03:00
Bruno Oliveira
355eb5adfb Small cleanups on _pytest.compat
Small improvements and cleanups
2019-06-15 10:06:37 -03:00
Ronny Pfannschmidt
2bd619ecb0 add changelog 2019-06-15 07:05:18 +02:00
Ronny Pfannschmidt
2b92fee1c3 initial conversion of exit codes to enum 2019-06-15 06:48:00 +02:00
Anthony Sottile
240828d912 Merge pull request #5448 from nicoddemus/add-hooks
Remove broken/unused PytestPluginManager.addhooks
2019-06-14 21:45:11 -07:00
Bruno Oliveira
c94e9b6145 Fix test docstring 2019-06-13 23:10:13 -03:00
Bruno Oliveira
7513d87b15 Remove broken/unused PytestPluginManager.addhooks
The function has been deprecated for ages and
the PLUGIN_MANAGER_ADDHOOKS constant doesn't even exist since 3.0.

Because the function is clearly broken, this change doesn't even
require a CHANGELOG.
2019-06-13 19:55:13 -03:00
Bruno Oliveira
bc345ac980 Remove handling of collection errors by --sw
Since then pytest itself adopted the behavior of interrupting
the test session on collection errors, so --sw no longer needs
to handle this.

The --sw behavior seems have been implemented when pytest
would continue execution even if there were collection errors.
2019-06-13 17:19:36 -03:00
Bruno Oliveira
4cc05a657d Fix --sw crash when first file in cmdline fails to collect
Fix #5444
2019-06-13 16:47:01 -03:00
Thomas Grainger
ad15efc7ea add test for stepwise attribute error Refs: #5444 2019-06-13 12:39:49 +01:00
Bruno Oliveira
e3dcf1f39d Merge pull request #5442 from patriksevallius/master
Add missing 'e' to test_mod(e).
2019-06-13 08:23:53 -03:00
patriksevallius
701d0351a6 Add missing 'e' to test_mod(e). 2019-06-13 06:01:30 +02:00
Bruno Oliveira
bad7ab721a Minor: tox: coverage: use -m with coverage-report (#5427)
Minor:  tox: coverage: use -m with coverage-report
2019-06-12 19:44:15 -03:00
Anthony Sottile
ede8b87560 Merge pull request #5438 from nicoddemus/result-log-deprecation
Postpone removal of --result-log to pytest 6.0
2019-06-12 10:45:02 -07:00
Bruno Oliveira
52780f39ce Postpone removal of --result-log to pytest 6.0
As we did not provide an alternative yet, it is better to postpone
the actual removal until we have provided a suitable and stable
alternative.

Related to #4488
2019-06-12 08:26:11 -03:00
Bruno Oliveira
d637d1b2ac Merge pull request #5435 from asottile/release-4.6.3 (#5436)
Merge pull request #5435 from asottile/release-4.6.3
2019-06-11 21:24:45 -03:00
Anthony Sottile
47447963b7 Merge pull request #5437 from asottile/reenable_pypy3
re-enable pypy3
2019-06-11 12:21:53 -07:00
Anthony Sottile
f586d627b3 re-enable pypy3 now that importlib-metadata 0.18 is released 2019-06-11 10:54:16 -07:00
Anthony Sottile
108fad1ac0 Revert "ci: Travis: remove pypy3 job for now"
This reverts commit 47022b36cb.
2019-06-11 10:53:32 -07:00
Anthony Sottile
18c2ff6625 Merge pull request #5435 from asottile/release-4.6.3
Preparing release version 4.6.3
2019-06-11 09:59:05 -07:00
Zac-HD
c5a549b5bb Emit warning for broken object 2019-06-09 22:17:40 +10:00
Daniel Hahler
75cda6de53 tox: coverage: use -m with coverage-report 2019-06-09 12:51:32 +02:00
Daniel Hahler
e868bb647d remove commented code 2019-06-09 12:51:32 +02:00
Daniel Hahler
40c5a9d9f2 Merge pull request #5409 from blueyed/twisted
ci: optimize twisted/numpy related jobs
2019-06-09 12:49:41 +02:00
Anthony Sottile
83d18096d4 Merge pull request #5421 from nicoddemus/raises-warning-message
Link deprecation docs pytest.raises 'message' warning
2019-06-08 12:44:40 -07:00
Daniel Hahler
28aa38ece6 ci: optimize twisted/pexpect related jobs
- tox: use twisted as dep only
- Azure: move twisted/numpy to main py37 job
- Travis: move twisted to main py37 build
2019-06-08 19:21:56 +02:00
Bruno Oliveira
f0cee593f2 Link deprecation docs pytest.raises 'message' warning
As commented in https://github.com/pytest-dev/pytest/issues/3974#issuecomment-499870914
2019-06-07 14:14:46 -03:00
Daniel Hahler
4f597f011d Merge pull request #5419 from blueyed/remove-pypy3
ci: Travis: remove pypy3 job for now
2019-06-07 18:05:59 +02:00
Bruno Oliveira
9f5c356784 Remove ExceptionInfo.__str__, falling back to __repr__ (#5413)
Remove ExceptionInfo.__str__, falling back to __repr__
2019-06-07 08:48:03 -03:00
Daniel Hahler
47022b36cb ci: Travis: remove pypy3 job for now
Ref: https://github.com/pytest-dev/pytest/issues/5317#issuecomment-499019928
2019-06-07 11:01:23 +02:00
Bruno Oliveira
042a10f2e2 Add slow marker in run/skip option example. (#5416)
Add `slow` marker in run/skip option example.
2019-06-06 15:00:04 -03:00
Anthony Sottile
0405697a78 Merge pull request #5415 from asottile/small_mypy_fixes
small mypy fixes
2019-06-06 10:47:58 -07:00
Ralph Giles
918268774b Add slow marker in run/skip option example.
The example implementation of a `--runslow` option results in
a `PytestUnknownMarkWarning`. Include registering the custom
mark in the example, based on the documentation in markers.rst.
2019-06-06 10:15:43 -07:00
Anthony Sottile
ccd87f9e80 small mypy fixes 2019-06-06 09:13:02 -07:00
Bruno Oliveira
65c2a81924 Remove ExceptionInfo.__str__, falling back to __repr__
Fix #5412
2019-06-06 12:20:32 -03:00
Bruno Oliveira
450d264623 ci: move coverage reporting to shared script (#5403)
ci: move coverage reporting to shared script
2019-06-06 12:04:32 -03:00
Daniel Hahler
0fd1f3038c ci: move coverage reporting to shared script 2019-06-06 16:31:39 +02:00
Bruno Oliveira
9f8b566ea9 Turn PytestDeprecationWarning into error (#5410)
Turn PytestDeprecationWarning into error
2019-06-05 22:20:14 -03:00
Bruno Oliveira
3656885d0d Fix verbosity bug in --collect-only (#5391)
Fix verbosity bug in --collect-only
2019-06-05 20:47:59 -03:00
Thomas Hisch
577b0dffe7 Fix verbosity bug in --collect-only 2019-06-05 20:10:16 -03:00
Bruno Oliveira
8f5cb461a8 Turn PytestDeprecationWarning into error
Fix #5402
2019-06-05 19:02:52 -03:00
Daniel Hahler
be84ba8a33 Merge pull request #5396 from blueyed/travis-py37-nocov
Revert "Enable coverage for 'py37' environment"
2019-06-05 12:40:46 +02:00
Daniel Hahler
d9eafbdee3 Revert "Enable coverage for 'py37' environment"
This reverts commit 6d393c5dc8.

It should not be necessary, because we have it via other jobs already.
2019-06-05 12:12:58 +02:00
Daniel Hahler
190456aeda Merge pull request #5406 from blueyed/restore-tracing
tests: restore tracing function
2019-06-05 11:50:56 +02:00
Daniel Hahler
aab5687093 tests: restore tracing function
Without this, `testing/test_pdb.py` (already without pexpect) will cause
missing test coverage afterwards (for the same process).
2019-06-05 11:26:48 +02:00
Anthony Sottile
5fdc2d7744 Merge pull request #5400 from asottile/prefixes
Clean up u' prefixes and py2 bytes conversions
2019-06-04 19:03:12 -07:00
Anthony Sottile
25cef55e4a Merge pull request #5398 from nicoddemus/kwargs-refactoring
Use keyword-only arguments in a few places
2019-06-04 18:21:44 -07:00
Anthony Sottile
be2be040f9 Clean up u' prefixes and py2 bytes conversions 2019-06-04 17:50:34 -07:00
Anthony Sottile
0f4992c223 Merge pull request #5393 from nicoddemus/unittest-self-5390
item.obj is again a bound method on TestCase function items
2019-06-04 17:48:48 -07:00
Bruno Oliveira
23cd68b667 Use keyword-only arguments in a few places 2019-06-04 21:10:59 -03:00
Bruno Oliveira
79ef04888e Merge pull request #5389 from dirk-thomas/patch-1
fix logic if importlib_metadata.PathDistribution.files is None [breaks pytest 4.6.0|1|2]
2019-06-04 20:25:21 -03:00
Bruno Oliveira
1f8fd421c4 item.obj is again a bound method on TestCase function items
Fix #5390
2019-06-04 20:22:49 -03:00
Bruno Oliveira
76d50801fd Allow pypy3 failures again (#5394)
Allow pypy3 failures again
2019-06-04 20:22:25 -03:00
Bruno Oliveira
9349c72cac Allow pypy3 failures again
Related to #5317
2019-06-04 20:17:51 -03:00
Bruno Oliveira
883db6a216 Add test for packages with broken metadata
Related to #5389
2019-06-04 17:04:15 -03:00
Dirk Thomas
898e869bcd add changelog file for #5389 2019-06-04 10:55:38 -07:00
Dirk Thomas
0a91e181af fix logic if importlib_metadata.PathDistribution.files is None 2019-06-04 10:41:58 -07:00
Bruno Oliveira
6a6b6d8195 Remove --recreate from .travis.yml (#5384)
Remove --recreate from .travis.yml
2019-06-03 22:18:17 -03:00
Anthony Sottile
b95bb29fc2 Remove --recreate from .travis.yml
Looks like this has been in the history since the beginning of time, but we should always get a blank slate anyway

Noticed this in https://github.com/crsmithdev/arrow/pull/597
2019-06-03 16:31:06 -07:00
Bruno Oliveira
2a3d643bdf Documentation: expansion of Monkeypatch to include mocked classes and dictionaries (#5315)
Documentation: expansion of Monkeypatch to include mocked classes and dictionaries
2019-06-03 19:30:29 -03:00
Bruno Oliveira
2cfd9c259f Revert "ci: Travis: add pypy3 to allowed failures temporarily" (#5378)
Revert "ci: Travis: add pypy3 to allowed failures temporarily"
2019-06-03 17:59:24 -03:00
Bruno Oliveira
927e95c65a [release notes] Merge pull request #5379 from asottile/release-4.6.2 (#5380)
[release notes] Merge pull request #5379 from asottile/release-4.6.2
2019-06-03 16:35:21 -03:00
Anthony Sottile
9657166a22 Merge pull request #5379 from asottile/release-4.6.2
Preparing release version 4.6.2
2019-06-03 12:19:42 -07:00
Bruno Oliveira
f223d26111 Add a new Exceptions section in documentation and document UsageError (#5231)
Add a new Exceptions section in documentation and document UsageError
2019-06-03 14:41:04 -03:00
Pulkit Goyal
1d6bbab2b0 Add a new Exceptions section in documentation and document UsageError 2019-06-03 14:23:56 -03:00
Daniel Hahler
606d728697 Revert "Revert "Revert "ci: Travis: add pypy3 to allowed failures temporarily""" 2019-06-03 18:54:40 +02:00
Daniel Hahler
3a8b08275d Merge pull request #5377 from blueyed/pypy3
Revert "Revert "ci: Travis: add pypy3 to allowed failures temporarily""
2019-06-03 18:33:57 +02:00
Daniel Hahler
e770db4c91 Revert "Revert "ci: Travis: add pypy3 to allowed failures temporarily""
This reverts commit a6dc283133.
2019-06-03 18:30:50 +02:00
Anthony Sottile
63099bc282 Merge pull request #5373 from asottile/revert_all_handling
Revert unrolling of `all()`
2019-06-03 09:18:47 -07:00
Bruno Oliveira
4f57d40a43 Merge master into features (#5374)
Merge master into features
2019-06-03 13:14:31 -03:00
Anthony Sottile
230f736fcd Add changelog entries for reverting all() handling 2019-06-03 08:42:03 -07:00
Anthony Sottile
1b381d5277 Revert "Unroll calls to any #5062 (#5103)"
This reverts commit 2b9ca34280, reversing
changes made to 0a57124063.
2019-06-03 08:42:03 -07:00
Anthony Sottile
2125d04501 Revert "Fix all() unroll for non-generators/non-list comprehensions (#5360)"
This reverts commit 733f43b02e, reversing
changes made to e4fe41ebb7.
2019-06-03 08:42:03 -07:00
Anthony Sottile
5976f36240 Merge pull request #5368 from asottile/pyupgrade
Automated / semi-automated python3 upgrades
2019-06-03 08:41:37 -07:00
Bruno Oliveira
ce78c9adef Fix linting 2019-06-03 12:08:50 -03:00
Bruno Oliveira
6d393c5dc8 Enable coverage for 'py37' environment 2019-06-03 12:08:02 -03:00
Anthony Sottile
8292644015 Allow multiple positions for the SyntaxError in pypy3.6 2019-06-03 12:08:02 -03:00
Anthony Sottile
96fd44e040 Update line number for warning 2019-06-03 12:08:02 -03:00
Anthony Sottile
5dcf85c17e manual: remove dependence on six 2019-06-03 12:08:02 -03:00
Anthony Sottile
ca1efd57bd git rm src/_pytest/_code/_py2traceback.py 2019-06-03 12:08:02 -03:00
Anthony Sottile
c63320cc31 codecs.open / io.open 2019-06-03 12:08:02 -03:00
Anthony Sottile
4df529e5b9 Clean up __future__ and coding: in tests 2019-06-03 12:08:02 -03:00
Anthony Sottile
a91fe1fedd pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
Anthony Sottile
3f1ec520fc pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
Anthony Sottile
5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
Anthony Sottile
99057555e1 manual changes to .pre-commit-config.yaml 2019-06-03 12:08:01 -03:00
Thomas Hisch
b8781ff868 Merge pull request #5335 from thisch/fmtregex
logging: Extend LEVELNAME_FMT_REGEX
2019-06-03 05:55:36 +02:00
Thomas Hisch
ef053193b5 logging: Extend LEVELNAME_FMT_REGEX 2019-06-03 05:53:19 +02:00
Bruno Oliveira
28ac469eaa Merge pull request #5367 from apollovy/master
Fix typo about interpreters count in doc/en/example/parametrize.html
2019-06-02 20:43:53 -03:00
Bruno Oliveira
5999782768 Use python 3 interpreters in example 2019-06-02 19:20:00 -03:00
Bruno Oliveira
6e68532bb3 Merge pull request #5362 from asottile/release-4.6.1 (#5365)
Merge pull request #5362 from asottile/release-4.6.1
2019-06-02 19:17:29 -03:00
Bruno Oliveira
602a290fcc Drop py27 and py34 support (#5318)
Drop py27 and py34 support
2019-06-02 19:14:54 -03:00
Bruno Oliveira
876df87672 Update release instructions for 4.6-maintenance (#5363)
Update release instructions for 4.6-maintenance
2019-06-02 19:14:26 -03:00
Bruno Oliveira
b7f8f53127 Revert "ci: Travis: add pypy3 to allowed failures temporarily" (#5364)
Revert "ci: Travis: add pypy3 to allowed failures temporarily"
2019-06-02 19:12:39 -03:00
Yuri Apollov
5c016d1021 Fix typo about interpreters count in doc/en/example/parametrize.html 2019-06-02 23:57:22 +03:00
Anthony Sottile
25e728c78b Update release instructions for 4.6-maintenance 2019-06-02 11:50:07 -07:00
Anthony Sottile
642ef6dc1b Merge pull request #5362 from asottile/release-4.6.1
Preparing release version 4.6.1
2019-06-02 11:47:26 -07:00
Daniel Hahler
a6dc283133 Revert "ci: Travis: add pypy3 to allowed failures temporarily"
This reverts commit 5ac498ea96.

The idea is that maybe https://github.com/pytest-dev/pytest/pull/5360
fixes the failures here also.
2019-06-02 20:19:34 +02:00
Bruno Oliveira
4d49ba6529 Drop Python 2.7 and 3.4 support
* Update setup.py requires and classifiers
* Drop Python 2.7 and 3.4 from CI
* Update docs dropping 2.7 and 3.4 support
* Fix mock imports and remove tests related to pypi's mock module
* Add py27 and 34 support docs to the sidebar
* Remove usage of six from tmpdir
* Remove six.PY* code blocks
* Remove sys.version_info related code
* Cleanup compat
* Remove obsolete safe_str
* Remove obsolete __unicode__ methods
* Remove compat.PY35 and compat.PY36: not really needed anymore
* Remove unused UNICODE_TYPES
* Remove Jython specific code
* Remove some Python 2 references from docs

Related to #5275
2019-06-02 14:39:11 -03:00
Bruno Oliveira
733f43b02e Fix all() unroll for non-generators/non-list comprehensions (#5360)
Fix all() unroll for non-generators/non-list comprehensions
2019-06-02 12:51:43 -03:00
Bruno Oliveira
acdf30a523 Fix all() unroll for non-generators/non-list comprehensions
Fix #5358
2019-06-02 12:12:14 -03:00
Anthony Sottile
e4fe41ebb7 Merge pull request #5356 from asottile/fix_parametrize_iterator
Fix `pytest.mark.parametrize` when the argvalue is an iterator
2019-06-01 15:09:43 -07:00
Anthony Sottile
cafb13c95f Fix pytest.mark.parametrize when the argvalue is an iterator 2019-06-01 15:09:17 -07:00
Bruno Oliveira
a8f4e56d8c Docs: Fix link anchor (#5355)
Docs: Fix link anchor
2019-06-01 19:09:04 -03:00
Hugo
e2ac4b782a Fix link anchor 2019-06-01 23:27:20 +03:00
Evan Kepner
2dfbed11b4 fix path expansion example 2019-05-27 23:23:18 -04:00
Evan Kepner
24c95c78e7 add updated monkeypatch examples 2019-05-27 20:55:15 -04:00
326 changed files with 20795 additions and 14619 deletions

View File

@@ -16,3 +16,13 @@ source = src/
*/lib/python*/site-packages/
*/pypy*/site-packages/
*\Lib\site-packages\
[report]
skip_covered = True
show_missing = True
exclude_lines =
\#\s*pragma: no cover
^\s*raise NotImplementedError\b
^\s*return NotImplemented\b
^\s*if TYPE_CHECKING:

1
.github/FUNDING.yml vendored
View File

@@ -2,3 +2,4 @@
# * https://help.github.com/en/articles/displaying-a-sponsor-button-in-your-repository
# * https://tidelift.com/subscription/how-to-connect-tidelift-with-github
tidelift: pypi/pytest
open_collective: pytest

View File

@@ -2,15 +2,22 @@
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
(please delete this text from the final description, this is just a guideline)
-->
- [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
- [ ] Target the `features` branch for new features and removals/deprecations.
- [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
- [ ] Include documentation when adding new features.
- [ ] Include new tests or update existing tests when applicable.
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
- [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
- [ ] Add yourself to `AUTHORS` in alphabetical order;
Write sentences in the **past or present tense**, examples:
* *Improved verbose diff output with sequences.*
* *Terminal summary statistics now use multiple colors.*
Also make sure to end the sentence with a `.`.
- [ ] Add yourself to `AUTHORS` in alphabetical order.
-->

191
.github/workflows/main.yml vendored Normal file
View File

@@ -0,0 +1,191 @@
# evaluating GitHub actions for CI, disregard failures when evaluating PRs
#
# this is still missing:
# - deploy
# - upload github notes
#
name: main
on:
push:
branches:
- master
tags:
- "*"
pull_request:
branches:
- master
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
name: [
"windows-py35",
"windows-py36",
"windows-py37",
"windows-py37-pluggy",
"windows-py38",
"ubuntu-py35",
"ubuntu-py36",
"ubuntu-py37",
"ubuntu-py37-pluggy",
"ubuntu-py37-freeze",
"ubuntu-py38",
"ubuntu-pypy3",
"macos-py37",
"macos-py38",
"linting",
]
include:
- name: "windows-py35"
python: "3.5"
os: windows-latest
tox_env: "py35-xdist"
- name: "windows-py36"
python: "3.6"
os: windows-latest
tox_env: "py36-xdist"
- name: "windows-py37"
python: "3.7"
os: windows-latest
tox_env: "py37-twisted-numpy"
- name: "windows-py37-pluggy"
python: "3.7"
os: windows-latest
tox_env: "py37-pluggymaster-xdist"
- name: "windows-py38"
python: "3.8"
os: windows-latest
tox_env: "py38"
- name: "ubuntu-py35"
python: "3.5"
os: ubuntu-latest
tox_env: "py35-xdist"
- name: "ubuntu-py36"
python: "3.6"
os: ubuntu-latest
tox_env: "py36-xdist"
- name: "ubuntu-py37"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-lsof-numpy-oldattrs-pexpect-twisted"
- name: "ubuntu-py37-pluggy"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-pluggymaster-xdist"
- name: "ubuntu-py37-freeze"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-freeze"
# coverage does not apply for freeze test, skip it
skip_coverage: true
- name: "ubuntu-py38"
python: "3.8"
os: ubuntu-latest
tox_env: "py38-xdist"
- name: "ubuntu-pypy3"
python: "pypy3"
os: ubuntu-latest
tox_env: "pypy3-xdist"
# coverage too slow with pypy3, skip it
skip_coverage: true
- name: "macos-py37"
python: "3.7"
os: macos-latest
tox_env: "py37-xdist"
- name: "macos-py38"
python: "3.8"
os: macos-latest
tox_env: "py38-xdist"
- name: "linting"
python: "3.7"
os: ubuntu-latest
tox_env: "linting,docs,doctesting"
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox coverage
- name: Test without coverage
if: "matrix.skip_coverage"
run: "tox -e ${{ matrix.tox_env }}"
- name: Test with coverage
if: "! matrix.skip_coverage"
env:
_PYTEST_TOX_COVERAGE_RUN: "coverage run -m"
COVERAGE_PROCESS_START: ".coveragerc"
_PYTEST_TOX_EXTRA_DEP: "coverage-enable-subprocess"
run: "tox -e ${{ matrix.tox_env }}"
- name: Prepare coverage token
if: success() && !matrix.skip_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' )
run: |
python scripts/append_codecov_token.py
- name: Combine coverage
if: success() && !matrix.skip_coverage
run: |
python -m coverage combine
python -m coverage xml
- name: Codecov upload
if: success() && !matrix.skip_coverage
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.codecov }}
file: ./coverage.xml
flags: ${{ runner.os }}
fail_ci_if_error: false
name: ${{ matrix.name }}
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest'
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v1
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools tox
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_token }}
- name: Publish GitHub release notes
env:
GH_RELEASE_NOTES_TOKEN: ${{ secrets.release_notes }}
run: |
sudo apt-get install pandoc
tox -e publish-gh-release-notes

3
.gitignore vendored
View File

@@ -25,16 +25,19 @@ src/_pytest/_version.py
doc/*/_build
doc/*/.doctrees
doc/*/_changelog_towncrier_draft.rst
build/
dist/
*.egg-info
issue/
env/
.env/
.venv/
3rdparty/
.tox
.cache
.pytest_cache
.mypy_cache
.coverage
.coverage.*
coverage.xml

View File

@@ -1,23 +1,21 @@
exclude: doc/en/example/py2py3/test_py2.py
repos:
- repo: https://github.com/python/black
rev: 19.3b0
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
language_version: python3
- repo: https://github.com/asottile/blacken-docs
rev: v0.5.0
rev: v1.0.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.3b0]
language_version: python3
additional_dependencies: [black==19.10b0]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.2
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: check-yaml
- id: debug-statements
exclude: _pytest/debugging.py
@@ -27,33 +25,36 @@ repos:
hooks:
- id: flake8
language_version: python3
additional_dependencies: [flake8-typing-imports==1.3.0]
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.4.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src']
args: ['--application-directories=.:src', --py3-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v1.15.0
rev: v1.18.0
hooks:
- id: pyupgrade
args: [--keep-percent-format]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.3.0
args: [--py3-plus]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.761 # NOTE: keep this in sync with setup.py.
hooks:
- id: rst-backticks
- id: mypy
files: ^(src/|testing/)
args: []
- repo: local
hooks:
- id: rst
name: rst
entry: rst-lint --encoding utf-8
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|TIDELIFT.rst|changelog/.*)$
files: ^(HOWTORELEASE.rst|README.rst|TIDELIFT.rst)$
language: python
additional_dependencies: [pygments, restructuredtext_lint]
- id: changelogs-rst
name: changelog filenames
language: fail
entry: 'changelog files must be named ####.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst'
exclude: changelog/(\d+\.(feature|bugfix|doc|deprecation|removal|vendor|trivial).rst|README.rst|_template.rst)
exclude: changelog/(\d+\.(feature|improvement|bugfix|doc|deprecation|removal|vendor|trivial).rst|README.rst|_template.rst)
files: ^changelog/
- id: py-deprecated
name: py library is deprecated

View File

@@ -2,10 +2,8 @@ language: python
dist: xenial
stages:
- baseline
- name: test
if: repo = pytest-dev/pytest AND tag IS NOT present
- name: deploy
if: repo = pytest-dev/pytest AND tag IS present
- test
python: '3.7'
cache: false
@@ -13,24 +11,23 @@ env:
global:
- PYTEST_ADDOPTS=-vv
# setuptools-scm needs all tags in order to obtain a proper version
git:
depth: false
install:
- python -m pip install --upgrade --pre tox
jobs:
include:
# OSX tests - first (in test stage), since they are the slower ones.
- &test-macos
os: osx
# Coverage for:
# - osx
# - verbose=1
- os: osx
osx_image: xcode10.1
language: generic
# Coverage for:
# - py2 with symlink in test_cmdline_python_package_symlink.
env: TOXENV=py27-xdist PYTEST_COVERAGE=1
before_install:
- python -V
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 27
- <<: *test-macos
env: TOXENV=py37-pexpect,py37-xdist PYTEST_COVERAGE=1
env: TOXENV=py37-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=-v
before_install:
- which python3
- python3 -V
@@ -38,84 +35,41 @@ jobs:
- python -V
- test $(python -c 'import sys; print("%d%d" % sys.version_info[0:2])') = 37
# Full run of latest (major) supported versions, without xdist.
- env: TOXENV=py27
python: '2.7'
- env: TOXENV=py37
python: '3.7'
# Coverage tracking is slow with pypy, skip it.
- env: TOXENV=pypy-xdist
python: 'pypy'
- env: TOXENV=pypy3-xdist
python: 'pypy3'
- env: TOXENV=py34-xdist
python: '3.4'
- env: TOXENV=py35-xdist
python: '3.5'
# Full run of latest supported version, without xdist.
# Coverage for:
# - pytester's LsofFdLeakChecker
# - TestArgComplete (linux only)
# - numpy
# Empty PYTEST_ADDOPTS to run this non-verbose.
- env: TOXENV=py37-lsof-numpy-xdist PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
# - old attrs
# - verbose=0
# - test_sys_breakpoint_interception (via pexpect).
- env: TOXENV=py37-lsof-numpy-oldattrs-pexpect-twisted PYTEST_COVERAGE=1 PYTEST_ADDOPTS=
python: '3.7'
# Specialized factors for py27.
- env: TOXENV=py27-nobyte-numpy-xdist
python: '2.7'
- env: TOXENV=py27-pluggymaster-xdist
python: '2.7'
# Coverage tracking is slow with pypy, skip it.
- env: TOXENV=pypy3-xdist
python: 'pypy3'
# Coverage for Python 3.5.{0,1} specific code, mostly typing related.
- env: TOXENV=py35 PYTEST_COVERAGE=1 PYTEST_ADDOPTS="-k test_raises_cyclic_reference"
python: '3.5.1'
dist: trusty
# Specialized factors for py37.
# Coverage for:
# - test_sys_breakpoint_interception (via pexpect).
- env: TOXENV=py37-pexpect,py37-twisted PYTEST_COVERAGE=1
- env: TOXENV=py37-pluggymaster-xdist
- env: TOXENV=py37-freeze
# Jobs only run via Travis cron jobs (currently daily).
- env: TOXENV=py38-xdist
python: '3.8-dev'
if: type = cron
python: '3.8'
- stage: baseline
# Coverage for:
# - _pytest.unittest._handle_skip (via pexpect).
env: TOXENV=py27-pexpect,py27-twisted PYTEST_COVERAGE=1
python: '2.7'
# Use py36 here for faster baseline.
- env: TOXENV=py36-xdist
env: TOXENV=py36-xdist
python: '3.6'
- env: TOXENV=linting,docs,doctesting PYTEST_COVERAGE=1
cache:
directories:
- $HOME/.cache/pre-commit
- stage: deploy
python: '3.6'
install: pip install -U setuptools setuptools_scm
script: skip
deploy:
provider: pypi
user: nicoddemus
distributions: sdist bdist_wheel
skip_upload_docs: true
password:
secure: xanTgTUu6XDQVqB/0bwJQXoDMnU5tkwZc5koz6mBkkqZhKdNOi2CLoC1XhiSZ+ah24l4V1E0GAqY5kBBcy9d7NVe4WNg4tD095LsHw+CRU6/HCVIFfyk2IZ+FPAlguesCcUiJSXOrlBF+Wj68wEvLoK7EoRFbJeiZ/f91Ww1sbtDlqXABWGHrmhPJL5Wva7o7+wG7JwJowqdZg1pbQExsCc7b53w4v2RBu3D6TJaTAzHiVsW+nUSI67vKI/uf+cR/OixsTfy37wlHgSwihYmrYLFls3V0bSpahCim3bCgMaFZx8S8xrdgJ++PzBCof2HeflFKvW+VCkoYzGEG4NrTWJoNz6ni4red9GdvfjGH3YCjAKS56h9x58zp2E5rpsb/kVq5/45xzV+dq6JRuhQ1nJWjBC6fSKAc/bfwnuFK3EBxNLkvBssLHvsNjj5XG++cB8DdS9wVGUqjpoK4puaXUWFqy4q3S9F86HEsKNgExtieA9qNx+pCIZVs6JCXZNjr0I5eVNzqJIyggNgJG6RyravsU35t9Zd9doL5g4Y7UKmAGTn1Sz24HQ4sMQgXdm2SyD8gEK5je4tlhUvfGtDvMSlstq71kIn9nRpFnqB6MFlbYSEAZmo8dGbCquoUc++6Rum208wcVbrzzVtGlXB/Ow9AbFMYeAGA0+N/K1e59c=
on:
tags: true
repo: pytest-dev/pytest
matrix:
allow_failures:
- python: '3.8-dev'
env: TOXENV=py38-xdist
# Temporary (https://github.com/pytest-dev/pytest/pull/5334).
- env: TOXENV=pypy3-xdist
python: 'pypy3'
before_script:
- |
# Do not (re-)upload coverage with cron runs.
@@ -130,18 +84,12 @@ before_script:
export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
fi
script: tox --recreate
script: tox
after_success:
- |
if [[ "$PYTEST_COVERAGE" = 1 ]]; then
set -e
# Add last TOXENV to $PATH.
PATH="$PWD/.tox/${TOXENV##*,}/bin:$PATH"
coverage combine
coverage xml
coverage report -m
bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -n $TOXENV-$TRAVIS_OS_NAME
env CODECOV_NAME="$TOXENV-$TRAVIS_OS_NAME" scripts/report-coverage.sh
fi
notifications:
@@ -153,3 +101,10 @@ notifications:
skip_join: true
email:
- pytest-commit@python.org
branches:
only:
- master
- features
- 4.6-maintenance
- /^\d+(\.\d+)+$/

22
AUTHORS
View File

@@ -15,6 +15,7 @@ Alexander Johnson
Alexei Kozlenok
Allan Feldman
Aly Sivji
Amir Elkess
Anatoly Bubenkoff
Anders Hovmöller
Andras Mitzki
@@ -22,6 +23,7 @@ Andras Tim
Andrea Cimatoribus
Andreas Zeidler
Andrey Paramonov
Andrzej Klajnert
Andrzej Ostrowski
Andy Freeland
Anthon van der Neut
@@ -52,12 +54,15 @@ Ceridwen
Charles Cloud
Charnjit SiNGH (CCSJ)
Chris Lamb
Chris NeJame
Christian Boelsen
Christian Fetzer
Christian Neumüller
Christian Theunert
Christian Tismer
Christopher Gilling
Christopher Dignam
Claudio Madotto
CrazyMerlyn
Cyrus Maden
Damian Skrzypczak
@@ -67,9 +72,11 @@ Daniel Hahler
Daniel Nuri
Daniel Wandschneider
Danielle Jenkins
Daniil Galiev
Dave Hunt
David Díaz-Barquero
David Mohr
David Paul Röthlisberger
David Szotten
David Vierra
Daw-Ran Liou
@@ -94,10 +101,12 @@ Feng Ma
Florian Bruhin
Floris Bruynooghe
Gabriel Reis
Gene Wood
George Kussumoto
Georgy Dyuldin
Graham Horler
Greg Price
Gregory Lee
Grig Gheorghiu
Grigorii Eremeev (budulianin)
Guido Wesdorp
@@ -128,6 +137,7 @@ Jordan Guymon
Jordan Moldow
Jordan Speicher
Joseph Hunkeler
Josh Karpel
Joshua Bronson
Jurko Gospodnetić
Justyna Janczyszyn
@@ -135,6 +145,7 @@ Kale Kundert
Katarzyna Jachim
Katerina Koukiou
Kevin Cox
Kevin J. Foley
Kodi B. Arfer
Kostis Anagnostopoulos
Kristoffer Nordström
@@ -154,7 +165,9 @@ Manuel Krebber
Marc Schlaich
Marcelo Duarte Trevisani
Marcin Bachry
Marco Gorelli
Mark Abramowitz
Mark Dickinson
Markus Unterwaditzer
Martijn Faassen
Martin Altmayer
@@ -170,6 +183,8 @@ mbyt
Michael Aquilina
Michael Birtwell
Michael Droettboom
Michael Goerz
Michael Krebs
Michael Seifert
Michal Wajszczuk
Mihai Capotă
@@ -200,11 +215,13 @@ Pulkit Goyal
Punyashloka Biswal
Quentin Pradet
Ralf Schmitt
Ralph Giles
Ran Benita
Raphael Castaneda
Raphael Pierzina
Raquel Alegre
Ravi Chandra
Robert Holt
Roberto Polli
Roland Puntaier
Romain Dorgueil
@@ -219,6 +236,7 @@ Samuele Pedroni
Sankt Petersbug
Segev Finer
Serhii Mozghovyi
Seth Junot
Simon Gomizelj
Skylar Downes
Srinivas Reddy Thatiparthy
@@ -235,6 +253,7 @@ Tareq Alayan
Ted Xiao
Thomas Grainger
Thomas Hisch
Tim Hoffmann
Tim Strazny
Tom Dalton
Tom Viner
@@ -250,11 +269,14 @@ Virgil Dupras
Vitaly Lashmanov
Vlad Dragos
Volodymyr Piskun
Wei Lin
Wil Cooley
William Lee
Wim Glenn
Wouter van Ackooy
Xixi Zhao
Xuan Luong
Xuecong Liao
Yoav Caspi
Zac Hatfield-Dodds
Zoltán Máté

File diff suppressed because it is too large Load Diff

84
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,84 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at coc@pytest.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
The coc@pytest.org address is routed to the following people who can also be
contacted individually:
- Brianna Laugher ([@pfctdayelise](https://github.com/pfctdayelise)): brianna@laugher.id.au
- Bruno Oliveira ([@nicoddemus](https://github.com/nicoddemus)): nicoddemus@gmail.com
- Florian Bruhin ([@the-compiler](https://github.com/the-compiler)): pytest@the-compiler.org
- Ronny Pfannschmidt ([@RonnyPfannschmidt](https://github.com/RonnyPfannschmidt)): ich@ronnypfannschmidt.de
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

View File

@@ -5,8 +5,9 @@ Contribution getting started
Contributions are highly welcomed and appreciated. Every little help counts,
so do not hesitate!
.. contents:: Contribution links
.. contents::
:depth: 2
:backlinks: none
.. _submitfeedback:
@@ -50,7 +51,8 @@ Fix bugs
Look through the `GitHub issues for bugs <https://github.com/pytest-dev/pytest/labels/type:%20bug>`_.
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs.
:ref:`Talk <contact>` to developers to find out how you can fix specific bugs. To indicate that you are going
to work on a particular issue, add a comment to that effect on the specific issue.
Don't forget to check the issue trackers of your favourite plugins, too!
@@ -166,14 +168,14 @@ Short version
#. Enable and install `pre-commit <https://pre-commit.com>`_ to ensure style-guides and code checks are followed.
#. Target ``master`` for bugfixes and doc changes.
#. Target ``features`` for new features or functionality changes.
#. Follow **PEP-8** for naming and `black <https://github.com/python/black>`_ for formatting.
#. Follow **PEP-8** for naming and `black <https://github.com/psf/black>`_ for formatting.
#. Tests are run using ``tox``::
tox -e linting,py27,py37
tox -e linting,py37
The test environments above are usually enough to cover most cases locally.
#. Write a ``changelog`` entry: ``changelog/2574.bugfix``, use issue id number
#. Write a ``changelog`` entry: ``changelog/2574.bugfix.rst``, use issue id number
and one of ``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or
``trivial`` for the issue type.
#. Unless your change is a trivial or a documentation fix (e.g., a typo or reword of a small section) please
@@ -217,7 +219,9 @@ Here is a simple overview, with pytest-specific bits:
If you need some help with Git, follow this quick start
guide: https://git.wiki.kernel.org/index.php/QuickStart
#. Install `pre-commit <https://pre-commit.com>`_ and its hook on the pytest repo::
#. Install `pre-commit <https://pre-commit.com>`_ and its hook on the pytest repo:
**Note: pre-commit must be installed as admin, as it will not function otherwise**::
$ pip install --user pre-commit
$ pre-commit install
@@ -237,20 +241,20 @@ Here is a simple overview, with pytest-specific bits:
#. Run all the tests
You need to have Python 2.7 and 3.7 available in your system. Now
You need to have Python 3.7 available in your system. Now
running tests is as simple as issuing this command::
$ tox -e linting,py27,py37
$ tox -e linting,py37
This command will run tests via the "tox" tool against Python 2.7 and 3.7
This command will run tests via the "tox" tool against Python 3.7
and also perform "lint" coding-style checks.
#. You can now edit your local working copy and run the tests again as necessary. Please follow PEP-8 for naming.
You can pass different options to ``tox``. For example, to run tests on Python 2.7 and pass options to pytest
You can pass different options to ``tox``. For example, to run tests on Python 3.7 and pass options to pytest
(e.g. enter pdb on failure) to pytest you can do::
$ tox -e py27 -- --pdb
$ tox -e py37 -- --pdb
Or to only run tests in a particular test module on Python 3.7::
@@ -259,14 +263,28 @@ Here is a simple overview, with pytest-specific bits:
When committing, ``pre-commit`` will re-format the files if necessary.
#. If instead of using ``tox`` you prefer to run the tests directly, then we suggest to create a virtual environment and use
an editable install with the ``testing`` extra::
$ python3 -m venv .venv
$ source .venv/bin/activate # Linux
$ .venv/Scripts/activate.bat # Windows
$ pip install -e ".[testing]"
Afterwards, you can edit the files and run pytest normally::
$ pytest testing/test_config.py
#. Commit and push once your tests pass and you are happy with your change(s)::
$ git commit -a -m "<commit message>"
$ git push -u
#. Create a new changelog entry in ``changelog``. The file should be named ``<issueid>.<type>``,
#. Create a new changelog entry in ``changelog``. The file should be named ``<issueid>.<type>.rst``,
where *issueid* is the number of the issue related to the change and *type* is one of
``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or ``trivial``.
``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or ``trivial``. You may not create a
changelog entry if the change doesn't affect the documented behaviour of Pytest.
#. Add yourself to ``AUTHORS`` file if not there yet, in alphabetical order.

View File

@@ -12,6 +12,8 @@ taking a lot of time to make a new one.
#. Create a branch ``release-X.Y.Z`` with the version for the release.
* **maintenance releases**: from ``4.6-maintenance``;
* **patch releases**: from the latest ``master``;
* **minor releases**: from the latest ``features``; then merge with the latest ``master``;
@@ -24,7 +26,8 @@ taking a lot of time to make a new one.
This will generate a commit with all the changes ready for pushing.
#. Open a PR for this branch targeting ``master``.
#. Open a PR for this branch targeting ``master`` (or ``4.6-maintenance`` for
maintenance releases).
#. After all tests pass and the PR has been approved, publish to PyPI by pushing the tag::
@@ -33,7 +36,16 @@ taking a lot of time to make a new one.
Wait for the deploy to complete, then make sure it is `available on PyPI <https://pypi.org/project/pytest>`_.
#. Merge the PR into ``master``.
#. Merge the PR.
#. If this is a maintenance release, cherry-pick the CHANGELOG / announce
files to the ``master`` branch::
git fetch --all --prune
git checkout origin/master -b cherry-pick-maintenance-release
git cherry-pick --no-commit -m1 origin/4.6-maintenance
git checkout origin/master -- changelog
git commit # no arguments
#. Send an email announcement with the contents from::

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2004-2019 Holger Krekel and others
Copyright (c) 2004-2020 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

44
OPENCOLLECTIVE.rst Normal file
View File

@@ -0,0 +1,44 @@
==============
OpenCollective
==============
pytest has a collective setup at `OpenCollective`_. This document describes how the core team manages
OpenCollective-related activities.
What is it
==========
Open Collective is an online funding platform for open and transparent communities.
It provides tools to raise money and share your finances in full transparency.
It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.
Funds
=====
The OpenCollective funds donated to pytest will be used to fund overall maintenance,
local sprints, merchandising (stickers to distribute in conferences for example), and future
gatherings of pytest developers (sprints).
`Core contributors`_ which are contributing on a continuous basis are free to submit invoices
to bill maintenance hours using the platform. How much each contributor should request is still an
open question, but we should use common sense and trust in the contributors, most of which know
themselves in-person. A good rule of thumb is to bill the same amount as monthly payments
contributors which participate in the `Tidelift`_ subscription. If in doubt, just ask.
Admins
======
A few people have admin access to the OpenCollective dashboard to make changes. Those people
are part of the `@pytest-dev/opencollective-admins`_ team.
`Core contributors`_ interested in helping out with OpenCollective maintenance are welcome! We don't
expect much work here other than the occasional approval of expenses from other core contributors.
Just drop a line to one of the `@pytest-dev/opencollective-admins`_ or use the mailing list.
.. _`OpenCollective`: https://opencollective.com/pytest
.. _`Tidelift`: https://tidelift.com
.. _`core contributors`: https://github.com/orgs/pytest-dev/teams/core/members
.. _`@pytest-dev/opencollective-admins`: https://github.com/orgs/pytest-dev/teams/opencollective-admins/members

View File

@@ -26,7 +26,7 @@
:target: https://dev.azure.com/pytest-dev/pytest
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/python/black
:target: https://github.com/psf/black
.. image:: https://www.codetriage.com/pytest-dev/pytest/badges/users.svg
:target: https://www.codetriage.com/pytest-dev/pytest
@@ -85,7 +85,7 @@ Features
- Can run `unittest <https://docs.pytest.org/en/latest/unittest.html>`_ (or trial),
`nose <https://docs.pytest.org/en/latest/nose.html>`_ test suites out of the box;
- Python 2.7, Python 3.4+, PyPy 2.3, Jython 2.5 (untested);
- Python 3.5+ and PyPy3;
- Rich plugin architecture, with over 315+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community;
@@ -111,19 +111,33 @@ Consult the `Changelog <https://docs.pytest.org/en/latest/changelog.html>`__ pag
Support pytest
--------------
You can support pytest by obtaining a `Tideflift subscription`_.
`Open Collective`_ is an online funding platform for open and transparent communities.
It provides tools to raise money and share your finances in full transparency.
Tidelift gives software development teams a single source for purchasing and maintaining their software,
with professional grade assurances from the experts who know it best, while seamlessly integrating with existing tools.
It is the platform of choice for individuals and companies that want to make one-time or
monthly donations directly to the project.
See more details in the `pytest collective`_.
.. _Open Collective: https://opencollective.com
.. _pytest collective: https://opencollective.com/pytest
.. _`Tideflift subscription`: https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=readme
pytest for enterprise
---------------------
Available as part of the Tidelift Subscription.
The maintainers of pytest and thousands of other packages are working with Tidelift to deliver commercial support and
maintenance for the open source dependencies you use to build your applications.
Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.
`Learn more. <https://tidelift.com/subscription/pkg/pypi-pytest?utm_source=pypi-pytest&utm_medium=referral&utm_campaign=enterprise&utm_term=repo>`_
Security
^^^^^^^^
pytest has never been associated with a security vunerability, but in any case, to report a
pytest has never been associated with a security vulnerability, but in any case, to report a
security vulnerability please use the `Tidelift security contact <https://tidelift.com/security>`_.
Tidelift will coordinate the fix and disclosure.
@@ -131,7 +145,7 @@ Tidelift will coordinate the fix and disclosure.
License
-------
Copyright Holger Krekel and others, 2004-2019.
Copyright Holger Krekel and others, 2004-2020.
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.

View File

@@ -12,6 +12,9 @@ Tidelift aims to make Open Source sustainable by offering subscriptions to compa
on Open Source packages. This subscription allows it to pay maintainers of those Open Source
packages to aid sustainability of the work.
It is the perfect platform for companies that want to support Open Source packages and at the same
time obtain assurances regarding maintenance, quality and security.
Funds
=====

View File

@@ -4,9 +4,6 @@ trigger:
variables:
PYTEST_ADDOPTS: "--junitxml=build/test-results/$(tox.env).xml -vv"
python.needs_vc: False
COVERAGE_FILE: "$(Build.Repository.LocalPath)/.coverage"
COVERAGE_PROCESS_START: "$(Build.Repository.LocalPath)/.coveragerc"
PYTEST_COVERAGE: '0'
jobs:
@@ -16,44 +13,10 @@ jobs:
vmImage: "vs2017-win2016"
strategy:
matrix:
py27:
python.version: '2.7'
tox.env: 'py27'
py27-nobyte-lsof-numpy:
python.version: '2.7'
tox.env: 'py27-lsof-nobyte-numpy'
# Coverage for:
# - test_supports_breakpoint_module_global
# - test_terminal_reporter_writer_attr (without xdist)
# - "if write" branch in _pytest.assertion.rewrite
# - numpy
# - pytester's LsofFdLeakChecker (being skipped)
PYTEST_COVERAGE: '1'
py27-twisted:
python.version: '2.7'
tox.env: 'py27-twisted'
python.needs_vc: True
py27-pluggymaster-xdist:
python.version: '2.7'
tox.env: 'py27-pluggymaster-xdist'
# Coverage for:
# - except-IOError in _attempt_to_close_capture_file for py2.
# Also seen with py27-nobyte (using xdist), and py27-xdist.
# But no exception with py27-pexpect,py27-twisted,py27-numpy.
PYTEST_COVERAGE: '1'
# -- pypy2 and pypy3 are disabled for now: #5279 --
# pypy:
# python.version: 'pypy2'
# tox.env: 'pypy'
# -- pypy3 disabled for now: #5279 --
# pypy3:
# python.version: 'pypy3'
# tox.env: 'pypy3'
py34-xdist:
python.version: '3.4'
tox.env: 'py34-xdist'
# Coverage for:
# - _pytest.compat._bytes_to_ascii
PYTEST_COVERAGE: '1'
py35-xdist:
python.version: '3.5'
tox.env: 'py35-xdist'
@@ -65,7 +28,7 @@ jobs:
tox.env: 'py36-xdist'
py37:
python.version: '3.7'
tox.env: 'py37'
tox.env: 'py37-twisted-numpy'
# Coverage for:
# - _py36_windowsconsoleio_workaround (with py36+)
# - test_request_garbage (no xdist)
@@ -73,12 +36,12 @@ jobs:
py37-linting/docs/doctesting:
python.version: '3.7'
tox.env: 'linting,docs,doctesting'
py37-twisted/numpy:
python.version: '3.7'
tox.env: 'py37-twisted,py37-numpy'
py37-pluggymaster-xdist:
python.version: '3.7'
tox.env: 'py37-pluggymaster-xdist'
py38-xdist:
python.version: '3.8'
tox.env: 'py38-xdist'
maxParallel: 10
steps:
@@ -87,15 +50,16 @@ jobs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: choco install vcpython27
condition: eq(variables['python.needs_vc'], True)
displayName: 'Install VC for py27'
- script: python -m pip install --upgrade pip && python -m pip install tox
displayName: 'Install tox'
- script: |
call scripts/setup-coverage-vars.bat || goto :eof
- bash: |
if [[ "$PYTEST_COVERAGE" == "1" ]]; then
export _PYTEST_TOX_COVERAGE_RUN="coverage run -m"
export _PYTEST_TOX_EXTRA_DEP=coverage-enable-subprocess
export COVERAGE_FILE="$PWD/.coverage"
export COVERAGE_PROCESS_START="$PWD/.coveragerc"
fi
python -m tox -e $(tox.env)
displayName: 'Run tests'
@@ -105,9 +69,12 @@ jobs:
testRunTitle: '$(tox.env)'
condition: succeededOrFailed()
- script: call scripts\upload-coverage.bat
displayName: 'Report and upload coverage'
condition: eq(variables['PYTEST_COVERAGE'], '1')
- bash: |
if [[ "$PYTEST_COVERAGE" == 1 ]]; then
scripts/report-coverage.sh
fi
env:
CODECOV_NAME: $(tox.env)
CODECOV_TOKEN: $(CODECOV_TOKEN)
PYTEST_CODECOV_NAME: $(tox.env)
displayName: Report and upload coverage
condition: eq(variables['PYTEST_COVERAGE'], '1')

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import sys
if __name__ == "__main__":
@@ -7,7 +6,7 @@ if __name__ == "__main__":
import pstats
script = sys.argv[1:] if len(sys.argv) > 1 else ["empty.py"]
stats = cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
cProfile.run("pytest.cmdline.main(%r)" % script, "prof")
p = pstats.Stats("prof")
p.strip_dirs()
p.sort_stats("cumulative")

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# 10000 iterations, just for relative comparison
# 2.7.5 3.3.2
# FilesCompleter 75.1109 69.2116

View File

@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
for i in range(1000):
exec("def test_func_%d(): pass" % i)

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import pytest

View File

@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from six.moves import range
import pytest
SKIP = True

View File

@@ -1,17 +1,20 @@
This directory contains "newsfragments" which are short files that contain a small **ReST**-formatted
text that will be added to the next ``CHANGELOG``.
The ``CHANGELOG`` will be read by users, so this description should be aimed to pytest users
The ``CHANGELOG`` will be read by **users**, so this description should be aimed to pytest users
instead of describing internal changes which are only relevant to the developers.
Make sure to use full sentences with correct case and punctuation, for example::
Make sure to use full sentences in the **past or present tense** and use punctuation, examples::
Fix issue with non-ascii messages from the ``warnings`` module.
Improved verbose diff output with sequences.
Terminal summary statistics now use multiple colors.
Each file should be named like ``<ISSUE>.<TYPE>.rst``, where
``<ISSUE>`` is an issue number, and ``<TYPE>`` is one of:
* ``feature``: new user facing features, like new command-line options and new behavior.
* ``improvement``: improvement of existing functionality, usually without requiring user intervention (for example, new fields being written in ``--junitxml``, improved colors in terminal, etc).
* ``bugfix``: fixes a reported bug.
* ``doc``: documentation improvement, like rewording an entire session or adding missing docs.
* ``deprecation``: feature deprecation.
@@ -28,6 +31,7 @@ changelog using that instead.
If you are not sure what issue type to use, don't hesitate to ask in your PR.
``towncrier`` preserves multiple paragraphs and formatting (code blocks, lists, and so on), but for entries
other than ``features`` it is usually better to stick to a single paragraph to keep it concise. You can install
``towncrier`` and then run ``towncrier --draft``
if you want to get a preview of how your change will look in the final release notes.
other than ``features`` it is usually better to stick to a single paragraph to keep it concise.
You can also run ``tox -e docs`` to build the documentation
with the draft changelog (``doc/en/_build/changelog.html``) if you want to get a preview of how your change will look in the final release notes.

7
codecov.yml Normal file
View File

@@ -0,0 +1,7 @@
coverage:
status:
project: true
patch: true
changes: true
comment: off

View File

@@ -16,7 +16,7 @@ REGENDOC_ARGS := \
--normalize "/[ \t]+\n/\n/" \
--normalize "~\$$REGENDOC_TMPDIR~/home/sweet/project~" \
--normalize "~/path/to/example~/home/sweet/project~" \
--normalize "/in \d+.\d+ seconds/in 0.12 seconds/" \
--normalize "/in \d.\d\ds/in 0.12s/" \
--normalize "@/tmp/pytest-of-.*/pytest-\d+@PYTEST_TMPDIR@" \
--normalize "@pytest-(\d+)\\.[^ ,]+@pytest-\1.x.y@" \
--normalize "@(This is pytest version )(\d+)\\.[^ ,]+@\1\2.x.y@" \

View File

@@ -4,12 +4,15 @@
<li><a href="{{ pathto('index') }}">Home</a></li>
<li><a href="{{ pathto('getting-started') }}">Install</a></li>
<li><a href="{{ pathto('contents') }}">Contents</a></li>
<li><a href="{{ pathto('reference') }}">Reference</a></li>
<li><a href="{{ pathto('reference') }}">API Reference</a></li>
<li><a href="{{ pathto('example/index') }}">Examples</a></li>
<li><a href="{{ pathto('customize') }}">Customize</a></li>
<li><a href="{{ pathto('changelog') }}">Changelog</a></li>
<li><a href="{{ pathto('contributing') }}">Contributing</a></li>
<li><a href="{{ pathto('backwards-compatibility') }}">Backwards Compatibility</a></li>
<li><a href="{{ pathto('py27-py34-deprecation') }}">Python 2.7 and 3.4 Support</a></li>
<li><a href="{{ pathto('sponsor') }}">Sponsor</a></li>
<li><a href="{{ pathto('tidelift') }}">pytest for Enterprise</a></li>
<li><a href="{{ pathto('license') }}">License</a></li>
<li><a href="{{ pathto('contact') }}">Contact Channels</a></li>
</ul>

View File

@@ -16,7 +16,7 @@
{%- block footer %}
<div class="footer">
&copy; Copyright {{ copyright }}.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.
</div>
{% if pagename == 'index' %}
</div>

View File

@@ -0,0 +1,15 @@
{#
basic/searchbox.html with heading removed.
#}
{%- if pagename != "search" and builder != "singlehtml" %}
<div id="searchbox" style="display: none" role="search">
<div class="searchformwrapper">
<form class="search" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" aria-labelledby="searchlabel"
placeholder="Search"/>
<input type="submit" value="{{ _('Go') }}" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
{%- endif %}

View File

@@ -8,11 +8,12 @@
{% set page_width = '1020px' %}
{% set sidebar_width = '220px' %}
/* orange of logo is #d67c29 but we use black for links for now */
{% set link_color = '#000' %}
{% set link_hover_color = '#000' %}
/* muted version of green logo color #C9D22A */
{% set link_color = '#606413' %}
/* blue logo color */
{% set link_hover_color = '#009de0' %}
{% set base_font = 'sans-serif' %}
{% set header_font = 'serif' %}
{% set header_font = 'sans-serif' %}
@import url("basic.css");
@@ -20,7 +21,7 @@
body {
font-family: {{ base_font }};
font-size: 17px;
font-size: 16px;
background-color: white;
color: #000;
margin: 0;
@@ -78,13 +79,13 @@ div.related {
}
div.sphinxsidebar a {
color: #444;
text-decoration: none;
border-bottom: 1px dotted #999;
border-bottom: none;
}
div.sphinxsidebar a:hover {
border-bottom: 1px solid #999;
color: {{ link_hover_color }};
border-bottom: 1px solid {{ link_hover_color }};
}
div.sphinxsidebar {
@@ -106,14 +107,14 @@ div.sphinxsidebar h3,
div.sphinxsidebar h4 {
font-family: {{ header_font }};
color: #444;
font-size: 24px;
font-size: 21px;
font-weight: normal;
margin: 0 0 5px 0;
margin: 16px 0 0 0;
padding: 0;
}
div.sphinxsidebar h4 {
font-size: 20px;
font-size: 18px;
}
div.sphinxsidebar h3 a {
@@ -205,10 +206,22 @@ div.body p, div.body dd, div.body li {
line-height: 1.4em;
}
ul.simple li {
margin-bottom: 0.5em;
}
div.topic ul.simple li {
margin-bottom: 0;
}
div.topic li > p:first-child {
margin-top: 0;
margin-bottom: 0;
}
div.admonition {
background: #fafafa;
margin: 20px -30px;
padding: 10px 30px;
padding: 10px 20px;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
@@ -217,11 +230,6 @@ div.admonition tt.xref, div.admonition a tt {
border-bottom: 1px solid #fafafa;
}
dd div.admonition {
margin-left: -60px;
padding-left: 60px;
}
div.admonition p.admonition-title {
font-family: {{ header_font }};
font-weight: normal;
@@ -231,7 +239,7 @@ div.admonition p.admonition-title {
line-height: 1;
}
div.admonition p.last {
div.admonition :last-child {
margin-bottom: 0;
}
@@ -243,7 +251,7 @@ dt:target, .highlight {
background: #FAF3E8;
}
div.note {
div.note, div.warning {
background-color: #eee;
border: 1px solid #ccc;
}
@@ -257,6 +265,11 @@ div.topic {
background-color: #eee;
}
div.topic a {
text-decoration: none;
border-bottom: none;
}
p.admonition-title {
display: inline;
}
@@ -358,21 +371,10 @@ ul, ol {
pre {
background: #eee;
padding: 7px 30px;
margin: 15px -30px;
padding: 7px 12px;
line-height: 1.3em;
}
dl pre, blockquote pre, li pre {
margin-left: -60px;
padding-left: 60px;
}
dl dl pre {
margin-left: -90px;
padding-left: 90px;
}
tt {
background-color: #ecf0f3;
color: #222;
@@ -393,6 +395,20 @@ a.reference:hover {
border-bottom: 1px solid {{ link_hover_color }};
}
li.toctree-l1 a.reference,
li.toctree-l2 a.reference,
li.toctree-l3 a.reference,
li.toctree-l4 a.reference {
border-bottom: none;
}
li.toctree-l1 a.reference:hover,
li.toctree-l2 a.reference:hover,
li.toctree-l3 a.reference:hover,
li.toctree-l4 a.reference:hover {
border-bottom: 1px solid {{ link_hover_color }};
}
a.footnote-reference {
text-decoration: none;
font-size: 0.7em;
@@ -408,6 +424,56 @@ a:hover tt {
background: #EEE;
}
#reference div.section h2 {
/* separate code elements in the reference section */
border-top: 2px solid #ccc;
padding-top: 0.5em;
}
#reference div.section h3 {
/* separate code elements in the reference section */
border-top: 1px solid #ccc;
padding-top: 0.5em;
}
dl.class, dl.function {
margin-top: 1em;
margin-bottom: 1em;
}
dl.class > dd {
border-left: 3px solid #ccc;
margin-left: 0px;
padding-left: 30px;
}
dl.field-list {
flex-direction: column;
}
dl.field-list dd {
padding-left: 4em;
border-left: 3px solid #ccc;
margin-bottom: 0.5em;
}
dl.field-list dd > ul {
list-style: none;
padding-left: 0px;
}
dl.field-list dd > ul > li li :first-child {
text-indent: 0;
}
dl.field-list dd > ul > li :first-child {
text-indent: -2em;
padding-left: 0px;
}
dl.field-list dd > p:first-child {
text-indent: -2em;
}
@media screen and (max-width: 870px) {

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Comment

View File

@@ -24,11 +24,9 @@ The ideal pytest helper
- feels confident in using pytest (e.g. has explored command line options, knows how to write parametrized tests, has an idea about conftest contents)
- does not need to be an expert in every aspect!
`Pytest helpers, sign up here`_! (preferably in February, hard deadline 22 March)
Pytest helpers, sign up here! (preferably in February, hard deadline 22 March)
.. _`Pytest helpers, sign up here`: http://goo.gl/forms/nxqAhqWt1P
The ideal partner project
-----------------------------------------
@@ -40,11 +38,9 @@ The ideal partner project
- has the support of the core development team, in trying out pytest adoption
- has no tests... or 100% test coverage... or somewhere in between!
`Partner projects, sign up here`_! (by 22 March)
Partner projects, sign up here! (by 22 March)
.. _`Partner projects, sign up here`: http://goo.gl/forms/ZGyqlHiwk3
What does it mean to "adopt pytest"?
-----------------------------------------
@@ -68,11 +64,11 @@ Progressive success might look like:
It may be after the month is up, the partner project decides that pytest is not right for it. That's okay - hopefully the pytest team will also learn something about its weaknesses or deficiencies.
.. _`nose and unittest`: faq.html#how-does-pytest-relate-to-nose-and-unittest
.. _assert: asserts.html
.. _assert: assert.html
.. _pycmd: https://bitbucket.org/hpk42/pycmd/overview
.. _`setUp/tearDown methods`: xunit_setup.html
.. _fixtures: fixture.html
.. _markers: markers.html
.. _markers: mark.html
.. _distributed: xdist.html

View File

@@ -6,6 +6,30 @@ Release announcements
:maxdepth: 2
release-5.3.3
release-5.3.2
release-5.3.1
release-5.3.0
release-5.2.4
release-5.2.3
release-5.2.2
release-5.2.1
release-5.2.0
release-5.1.3
release-5.1.2
release-5.1.1
release-5.1.0
release-5.0.1
release-5.0.0
release-4.6.9
release-4.6.8
release-4.6.7
release-4.6.6
release-4.6.5
release-4.6.4
release-4.6.3
release-4.6.2
release-4.6.1
release-4.6.0
release-4.5.0
release-4.4.2

View File

@@ -7,7 +7,7 @@ see below for summary and detailed lists. A lot of long-deprecated code
has been removed, resulting in a much smaller and cleaner
implementation. See the new docs with examples here:
http://pytest.org/2.0.0/index.html
http://pytest.org/en/latest/index.html
A note on packaging: pytest used to part of the "py" distribution up
until version py-1.3.4 but this has changed now: pytest-2.0.0 only
@@ -36,12 +36,12 @@ New Features
import pytest ; pytest.main(arglist, pluginlist)
see http://pytest.org/2.0.0/usage.html for details.
see http://pytest.org/en/latest/usage.html for details.
- new and better reporting information in assert expressions
if comparing lists, sequences or strings.
see http://pytest.org/2.0.0/assert.html#newreport
see http://pytest.org/en/latest/assert.html#newreport
- new configuration through ini-files (setup.cfg or tox.ini recognized),
for example::
@@ -50,7 +50,7 @@ New Features
norecursedirs = .hg data* # don't ever recurse in such dirs
addopts = -x --pyargs # add these command line options by default
see http://pytest.org/2.0.0/customize.html
see http://pytest.org/en/latest/customize.html
- improved standard unittest support. In general py.test should now
better be able to run custom unittest.TestCases like twisted trial

View File

@@ -57,7 +57,7 @@ Changes between 2.0.0 and 2.0.1
- refinements to "collecting" output on non-ttys
- refine internal plugin registration and --traceconfig output
- introduce a mechanism to prevent/unregister plugins from the
command line, see http://pytest.org/latest/plugins.html#cmdunregister
command line, see http://pytest.org/en/latest/plugins.html#cmdunregister
- activate resultlog plugin by default
- fix regression wrt yielded tests which due to the
collection-before-running semantics were not

View File

@@ -12,7 +12,7 @@ courtesy of Benjamin Peterson. You can now safely use ``assert``
statements in test modules without having to worry about side effects
or python optimization ("-OO") options. This is achieved by rewriting
assert statements in test modules upon import, using a PEP302 hook.
See http://pytest.org/assert.html#advanced-assertion-introspection for
See https://docs.pytest.org/en/latest/assert.html for
detailed information. The work has been partly sponsored by my company,
merlinux GmbH.

View File

@@ -9,7 +9,7 @@ with these improvements:
- new @pytest.mark.parametrize decorator to run tests with different arguments
- new metafunc.parametrize() API for parametrizing arguments independently
- see examples at http://pytest.org/latest/example/parametrize.html
- see examples at http://pytest.org/en/latest/example/parametrize.html
- NOTE that parametrize() related APIs are still a bit experimental
and might change in future releases.
@@ -18,7 +18,7 @@ with these improvements:
- "-m markexpr" option for selecting tests according to their mark
- a new "markers" ini-variable for registering test markers for your project
- the new "--strict" bails out with an error if using unregistered markers.
- see examples at http://pytest.org/latest/example/markers.html
- see examples at http://pytest.org/en/latest/example/markers.html
* duration profiling: new "--duration=N" option showing the N slowest test
execution or setup/teardown calls. This is most useful if you want to
@@ -78,7 +78,7 @@ Changes between 2.1.3 and 2.2.0
or through plugin hooks. Also introduce a "--strict" option which
will treat unregistered markers as errors
allowing to avoid typos and maintain a well described set of markers
for your test suite. See examples at http://pytest.org/latest/mark.html
for your test suite. See examples at http://pytest.org/en/latest/mark.html
and its links.
- issue50: introduce "-m marker" option to select tests based on markers
(this is a stricter and more predictable version of "-k" in that "-m"

View File

@@ -3,22 +3,22 @@ pytest-2.3: improved fixtures / better unittest integration
pytest-2.3 comes with many major improvements for fixture/funcarg management
and parametrized testing in Python. It is now easier, more efficient and
more predicatable to re-run the same tests with different fixture
more predictable to re-run the same tests with different fixture
instances. Also, you can directly declare the caching "scope" of
fixtures so that dependent tests throughout your whole test suite can
re-use database or other expensive fixture objects with ease. Lastly,
it's possible for fixture functions (formerly known as funcarg
factories) to use other fixtures, allowing for a completely modular and
re-useable fixture design.
re-usable fixture design.
For detailed info and tutorial-style examples, see:
http://pytest.org/latest/fixture.html
http://pytest.org/en/latest/fixture.html
Moreover, there is now support for using pytest fixtures/funcargs with
unittest-style suites, see here for examples:
http://pytest.org/latest/unittest.html
http://pytest.org/en/latest/unittest.html
Besides, more unittest-test suites are now expected to "simply work"
with pytest.
@@ -29,11 +29,11 @@ pytest-2.2.4.
If you are interested in the precise reasoning (including examples) of the
pytest-2.3 fixture evolution, please consult
http://pytest.org/latest/funcarg_compare.html
http://pytest.org/en/latest/funcarg_compare.html
For general info on installation and getting started:
http://pytest.org/latest/getting-started.html
http://pytest.org/en/latest/getting-started.html
Docs and PDF access as usual at:
@@ -94,7 +94,7 @@ Changes between 2.2.4 and 2.3.0
- pluginmanager.register(...) now raises ValueError if the
plugin has been already registered or the name is taken
- fix issue159: improve http://pytest.org/latest/faq.html
- fix issue159: improve http://pytest.org/en/latest/faq.html
especially with respect to the "magic" history, also mention
pytest-django, trial and unittest integration.

View File

@@ -16,7 +16,7 @@ comes with the following fixes and features:
- yielded test functions will now have autouse-fixtures active but
cannot accept fixtures as funcargs - it's anyway recommended to
rather use the post-2.0 parametrize features instead of yield, see:
http://pytest.org/latest/example/parametrize.html
http://pytest.org/en/latest/example/parametrize.html
- fix autouse-issue where autouse-fixtures would not be discovered
if defined in an a/conftest.py file and tests in a/tests/test_some.py
- fix issue226 - LIFO ordering for fixture teardowns

View File

@@ -7,7 +7,7 @@ from a few supposedly very minor incompatibilities. See below for
a full list of details. A few feature highlights:
- new yield-style fixtures `pytest.yield_fixture
<http://pytest.org/latest/yieldfixture.html>`_, allowing to use
<http://pytest.org/en/latest/yieldfixture.html>`_, allowing to use
existing with-style context managers in fixture functions.
- improved pdb support: ``import pdb ; pdb.set_trace()`` now works

View File

@@ -91,7 +91,7 @@ holger krekel
it might be the cause for other finalizers to fail.
- fix ordering when mock.patch or other standard decorator-wrappings
are used with test methods. This fixues issue346 and should
are used with test methods. This fixes issue346 and should
help with random "xdist" collection failures. Thanks to
Ronny Pfannschmidt and Donald Stufft for helping to isolate it.

View File

@@ -35,7 +35,7 @@ holger krekel
- fix issue435: make reload() work when assert rewriting is active.
Thanks Daniel Hahler.
- fix issue616: conftest.py files and their contained fixutres are now
- fix issue616: conftest.py files and their contained fixtures are now
properly considered for visibility, independently from the exact
current working directory and test arguments that are used.
Many thanks to Eric Siegerman and his PR235 which contains
@@ -52,7 +52,7 @@ holger krekel
- add ability to set command line options by environment variable PYTEST_ADDOPTS.
- added documentation on the new pytest-dev teams on bitbucket and
github. See https://pytest.org/latest/contributing.html .
github. See https://pytest.org/en/latest/contributing.html .
Thanks to Anatoly for pushing and initial work on this.
- fix issue650: new option ``--docttest-ignore-import-errors`` which

View File

@@ -75,7 +75,7 @@ The py.test Development Team
**Changes**
* **Important**: `py.code <https://pylib.readthedocs.io/en/latest/code.html>`_ has been
* **Important**: `py.code <https://pylib.readthedocs.io/en/stable/code.html>`_ has been
merged into the ``pytest`` repository as ``pytest._code``. This decision
was made because ``py.code`` had very few uses outside ``pytest`` and the
fact that it was in a different repository made it difficult to fix bugs on
@@ -88,7 +88,7 @@ The py.test Development Team
**experimental**, so you definitely should not import it explicitly!
Please note that the original ``py.code`` is still available in
`pylib <https://pylib.readthedocs.io>`_.
`pylib <https://pylib.readthedocs.io/en/stable/>`_.
* ``pytest_enter_pdb`` now optionally receives the pytest config object.
Thanks `@nicoddemus`_ for the PR.
@@ -131,7 +131,7 @@ The py.test Development Team
with same name.
.. _`traceback style docs`: https://pytest.org/latest/usage.html#modifying-python-traceback-printing
.. _`traceback style docs`: https://pytest.org/en/latest/usage.html#modifying-python-traceback-printing
.. _#1422: https://github.com/pytest-dev/pytest/issues/1422
.. _#1379: https://github.com/pytest-dev/pytest/issues/1379

View File

@@ -66,8 +66,8 @@ The py.test Development Team
.. _#510: https://github.com/pytest-dev/pytest/issues/510
.. _#1506: https://github.com/pytest-dev/pytest/pull/1506
.. _#1496: https://github.com/pytest-dev/pytest/issue/1496
.. _#1524: https://github.com/pytest-dev/pytest/issue/1524
.. _#1496: https://github.com/pytest-dev/pytest/issues/1496
.. _#1524: https://github.com/pytest-dev/pytest/pull/1524
.. _@astraw38: https://github.com/astraw38
.. _@hackebrot: https://github.com/hackebrot

View File

@@ -20,7 +20,7 @@ Thanks to all who contributed to this release, among them:
* Jeffrey Rackauckas
* Jose Carlos Menezes
* Ronny Pfannschmidt
* Zac-HD
* Zac Hatfield-Dodds
* iwanb

View File

@@ -21,7 +21,6 @@ Thanks to all who contributed to this release, among them:
* Kyle Altendorf
* Stephan Hoyer
* Zac Hatfield-Dodds
* Zac-HD
* songbowen

View File

@@ -28,7 +28,6 @@ Thanks to all who contributed to this release, among them:
* Pulkit Goyal
* Samuel Searles-Bryant
* Zac Hatfield-Dodds
* Zac-HD
Happy testing,

View File

@@ -0,0 +1,19 @@
pytest-4.6.1
=======================================
pytest 4.6.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,18 @@
pytest-4.6.2
=======================================
pytest 4.6.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-4.6.3
=======================================
pytest 4.6.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Dirk Thomas
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,22 @@
pytest-4.6.4
=======================================
pytest 4.6.4 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Thomas Grainger
* Zac Hatfield-Dodds
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-4.6.5
=======================================
pytest 4.6.5 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Thomas Grainger
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,20 @@
pytest-4.6.6
=======================================
pytest 4.6.6 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Michael Goerz
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,19 @@
pytest-4.6.7
=======================================
pytest 4.6.7 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Bruno Oliveira
* Daniel Hahler
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,20 @@
pytest-4.6.8
=======================================
pytest 4.6.8 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Ryan Mast
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-4.6.9
=======================================
pytest 4.6.9 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Felix Yan
* Hugo
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,46 @@
pytest-5.0.0
=======================================
The pytest team is proud to announce the 5.0.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:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Dirk Thomas
* Evan Kepner
* Florian Bruhin
* Hugo
* Kevin J. Foley
* Pulkit Goyal
* Ralph Giles
* Ronny Pfannschmidt
* Thomas Grainger
* Thomas Hisch
* Tim Gates
* Victor Maryama
* Yuri Apollov
* Zac Hatfield-Dodds
* curiousjazz77
* patriksevallius
Happy testing,
The Pytest Development Team

View File

@@ -0,0 +1,25 @@
pytest-5.0.1
=======================================
pytest 5.0.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* AmirElkess
* Andreu Vallbona Plazas
* Anthony Sottile
* Bruno Oliveira
* Florian Bruhin
* Michael Moore
* Niklas Meinzer
* Thomas Grainger
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,56 @@
pytest-5.1.0
=======================================
The pytest team is proud to announce the 5.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:
* Albert Tugushev
* Alexey Zankevich
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* David Röthlisberger
* Florian Bruhin
* Ilya Stepin
* Jon Dufresne
* Kaiqi
* Max R
* Miro Hrončok
* Oliver Bestwalter
* Ran Benita
* Ronny Pfannschmidt
* Samuel Searles-Bryant
* Semen Zhydenko
* Steffen Schroeder
* Thomas Grainger
* Tim Hoffmann
* William Woodall
* Wojtek Erbetowski
* Xixi Zhao
* Yash Todi
* boris
* dmitry.dygalo
* helloocc
* martbln
* mei-li
Happy testing,
The Pytest Development Team

View File

@@ -0,0 +1,24 @@
pytest-5.1.1
=======================================
pytest 5.1.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Florian Bruhin
* Hugo van Kemenade
* Ran Benita
* Ronny Pfannschmidt
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,23 @@
pytest-5.1.2
=======================================
pytest 5.1.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Andrzej Klajnert
* Anthony Sottile
* Bruno Oliveira
* Christian Neumüller
* Robert Holt
* linchiwei123
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,23 @@
pytest-5.1.3
=======================================
pytest 5.1.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Christian Neumüller
* Daniel Hahler
* Gene Wood
* Hugo
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,35 @@
pytest-5.2.0
=======================================
The pytest team is proud to announce the 5.2.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:
* Andrzej Klajnert
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* James Cooke
* Michael Goerz
* Ran Benita
* Tomáš Chvátal
Happy testing,
The Pytest Development Team

View File

@@ -0,0 +1,23 @@
pytest-5.2.1
=======================================
pytest 5.2.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Florian Bruhin
* Hynek Schlawack
* Kevin J. Foley
* tadashigaki
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,29 @@
pytest-5.2.2
=======================================
pytest 5.2.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Albert Tugushev
* Andrzej Klajnert
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Florian Bruhin
* Nattaphoom Chaipreecha
* Oliver Bestwalter
* Philipp Loose
* Ran Benita
* Victor Maryama
* Yoav Caspi
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,28 @@
pytest-5.2.3
=======================================
pytest 5.2.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Brett Cannon
* Bruno Oliveira
* Daniel Hahler
* Daniil Galiev
* David Szotten
* Florian Bruhin
* Patrick Harmon
* Ran Benita
* Zac Hatfield-Dodds
* Zak Hassan
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,22 @@
pytest-5.2.4
=======================================
pytest 5.2.4 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Hugo
* Michael Shields
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,45 @@
pytest-5.3.0
=======================================
The pytest team is proud to announce the 5.3.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:
* AnjoMan
* Anthony Sottile
* Anton Lodder
* Bruno Oliveira
* Daniel Hahler
* Gregory Lee
* Josh Karpel
* JoshKarpel
* Joshua Storck
* Kale Kundert
* MarcoGorelli
* Michael Krebs
* NNRepos
* Ran Benita
* TH3CHARLie
* Tibor Arpas
* Zac Hatfield-Dodds
* 林玮
Happy testing,
The Pytest Development Team

View File

@@ -0,0 +1,26 @@
pytest-5.3.1
=======================================
pytest 5.3.1 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Felix Yan
* Florian Bruhin
* Mark Dickinson
* Nikolay Kondratyev
* Steffen Schroeder
* Zac Hatfield-Dodds
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,26 @@
pytest-5.3.2
=======================================
pytest 5.3.2 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Anthony Sottile
* Bruno Oliveira
* Claudio Madotto
* Daniel Hahler
* Jared Vasquez
* Michael Rose
* Ran Benita
* Ronny Pfannschmidt
* Zac Hatfield-Dodds
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,30 @@
pytest-5.3.3
=======================================
pytest 5.3.3 has just been released to PyPI.
This is a bug-fix release, being a drop-in replacement. To upgrade::
pip install --upgrade pytest
The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
Thanks to all who contributed to this release, among them:
* Adam Johnson
* Alexandre Mulatinho
* Anthony Sottile
* Bruno Oliveira
* Chris NeJame
* Daniel Hahler
* Hugo van Kemenade
* Marcelo Duarte Trevisani
* PaulC
* Ran Benita
* Ryan Barner
* Seth Junot
* marc
Happy testing,
The pytest Development Team

View File

@@ -31,7 +31,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
@@ -47,7 +47,7 @@ you will see the return value of the function call:
E + where 3 = f()
test_assert1.py:6: AssertionError
========================= 1 failed in 0.12 seconds =========================
============================ 1 failed in 0.12s =============================
``pytest`` has support for showing the values of the most common subexpressions
including calls, attributes, comparisons, and binary and unary
@@ -186,7 +186,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
@@ -208,7 +208,7 @@ if you run this module:
E Use -v to get the full diff
test_assert2.py:6: AssertionError
========================= 1 failed in 0.12 seconds =========================
============================ 1 failed in 0.12s =============================
Special comparisons are done for a number of cases:
@@ -238,14 +238,17 @@ file which provides an alternative explanation for ``Foo`` objects:
def pytest_assertrepr_compare(op, left, right):
if isinstance(left, Foo) and isinstance(right, Foo) and op == "==":
return ["Comparing Foo instances:", " vals: %s != %s" % (left.val, right.val)]
return [
"Comparing Foo instances:",
" vals: {} != {}".format(left.val, right.val),
]
now, given this test module:
.. code-block:: python
# content of test_foocompare.py
class Foo(object):
class Foo:
def __init__(self, val):
self.val = val
@@ -276,7 +279,7 @@ the conftest file:
E vals: 1 != 2
test_foocompare.py:12: AssertionError
1 failed in 0.12 seconds
1 failed in 0.12s
.. _assert-details:
.. _`assert introspection`:

View File

@@ -104,6 +104,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
Captured logs are available through the following properties/methods::
* caplog.messages -> list of format-interpolated log messages
* caplog.text -> string containing formatted log output
* caplog.records -> list of logging.LogRecord instances
* caplog.record_tuples -> list of (logger_name, level, message) tuples
@@ -160,9 +161,12 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
in python < 3.6 this is a pathlib2.Path
no tests ran in 0.12 seconds
no tests ran in 0.12s
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like::
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like:
.. code-block:: python
import pytest
help(pytest)

View File

@@ -33,15 +33,18 @@ Other plugins may access the `config.cache`_ object to set/get
Rerunning only failures or failures first
-----------------------------------------------
First, let's create 50 test invocation of which only 2 fail::
First, let's create 50 test invocation of which only 2 fail:
.. code-block:: python
# content of test_50.py
import pytest
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
pytest.fail("bad luck")
pytest.fail("bad luck")
If you run this for the first time you will see two failures:
@@ -57,10 +60,10 @@ If you run this for the first time you will see two failures:
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
test_50.py:7: Failed
_______________________________ test_num[25] _______________________________
i = 25
@@ -68,11 +71,11 @@ If you run this for the first time you will see two failures:
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
2 failed, 48 passed in 0.12 seconds
test_50.py:7: Failed
2 failed, 48 passed in 0.12s
If you then run it with ``--lf``:
@@ -80,7 +83,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 50 items / 48 deselected / 2 selected
@@ -96,10 +99,10 @@ If you then run it with ``--lf``:
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
test_50.py:7: Failed
_______________________________ test_num[25] _______________________________
i = 25
@@ -107,14 +110,14 @@ If you then run it with ``--lf``:
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
================= 2 failed, 48 deselected in 0.12 seconds ==================
test_50.py:7: Failed
===================== 2 failed, 48 deselected in 0.12s =====================
You have run only the two failing test from the last run, while 48 tests have
not been run ("deselected").
You have run only the two failing tests from the last run, while the 48 passing
tests have not been run ("deselected").
Now, if you run with the ``--ff`` option, all tests will be run but the first
previous failures will be executed first (as can be seen from the series
@@ -124,7 +127,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 50 items
@@ -140,10 +143,10 @@ of ``FF`` and dots):
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
test_50.py:7: Failed
_______________________________ test_num[25] _______________________________
i = 25
@@ -151,11 +154,11 @@ of ``FF`` and dots):
@pytest.mark.parametrize("i", range(50))
def test_num(i):
if i in (17, 25):
> pytest.fail("bad luck")
E Failed: bad luck
> pytest.fail("bad luck")
E Failed: bad luck
test_50.py:6: Failed
=================== 2 failed, 48 passed in 0.12 seconds ====================
test_50.py:7: Failed
======================= 2 failed, 48 passed in 0.12s =======================
.. _`config.cache`:
@@ -183,15 +186,19 @@ The new config.cache object
Plugins or conftest.py support code can get a cached value using the
pytest ``config`` object. Here is a basic example plugin which
implements a :ref:`fixture` which re-uses previously created state
across pytest invocations::
across pytest invocations:
.. code-block:: python
# content of test_caching.py
import pytest
import time
def expensive_computation():
print("running expensive computation...")
@pytest.fixture
def mydata(request):
val = request.config.cache.get("example/value", None)
@@ -201,6 +208,7 @@ across pytest invocations::
request.config.cache.set("example/value", val)
return val
def test_function(mydata):
assert mydata == 23
@@ -219,12 +227,12 @@ 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:17: AssertionError
test_caching.py:20: AssertionError
-------------------------- Captured stdout setup ---------------------------
running expensive computation...
1 failed in 0.12 seconds
1 failed in 0.12s
If you run it a second time the value will be retrieved from
If you run it a second time, the value will be retrieved from
the cache and nothing will be printed:
.. code-block:: pytest
@@ -240,8 +248,8 @@ the cache and nothing will be printed:
> assert mydata == 23
E assert 42 == 23
test_caching.py:17: AssertionError
1 failed in 0.12 seconds
test_caching.py:20: AssertionError
1 failed in 0.12s
See the :ref:`cache-api` for more details.
@@ -256,7 +264,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
cachedir: $PYTHON_PREFIX/.pytest_cache
@@ -269,13 +277,66 @@ You can always peek at the content of the cache using the
'test_caching.py::test_function': True,
'test_foocompare.py::test_compare': True}
cache/nodeids contains:
['test_caching.py::test_function']
['test_assert1.py::test_function',
'test_assert2.py::test_set_comparison',
'test_foocompare.py::test_compare',
'test_50.py::test_num[0]',
'test_50.py::test_num[1]',
'test_50.py::test_num[2]',
'test_50.py::test_num[3]',
'test_50.py::test_num[4]',
'test_50.py::test_num[5]',
'test_50.py::test_num[6]',
'test_50.py::test_num[7]',
'test_50.py::test_num[8]',
'test_50.py::test_num[9]',
'test_50.py::test_num[10]',
'test_50.py::test_num[11]',
'test_50.py::test_num[12]',
'test_50.py::test_num[13]',
'test_50.py::test_num[14]',
'test_50.py::test_num[15]',
'test_50.py::test_num[16]',
'test_50.py::test_num[17]',
'test_50.py::test_num[18]',
'test_50.py::test_num[19]',
'test_50.py::test_num[20]',
'test_50.py::test_num[21]',
'test_50.py::test_num[22]',
'test_50.py::test_num[23]',
'test_50.py::test_num[24]',
'test_50.py::test_num[25]',
'test_50.py::test_num[26]',
'test_50.py::test_num[27]',
'test_50.py::test_num[28]',
'test_50.py::test_num[29]',
'test_50.py::test_num[30]',
'test_50.py::test_num[31]',
'test_50.py::test_num[32]',
'test_50.py::test_num[33]',
'test_50.py::test_num[34]',
'test_50.py::test_num[35]',
'test_50.py::test_num[36]',
'test_50.py::test_num[37]',
'test_50.py::test_num[38]',
'test_50.py::test_num[39]',
'test_50.py::test_num[40]',
'test_50.py::test_num[41]',
'test_50.py::test_num[42]',
'test_50.py::test_num[43]',
'test_50.py::test_num[44]',
'test_50.py::test_num[45]',
'test_50.py::test_num[46]',
'test_50.py::test_num[47]',
'test_50.py::test_num[48]',
'test_50.py::test_num[49]',
'test_caching.py::test_function']
cache/stepwise contains:
[]
example/value contains:
42
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
``--cache-show`` takes an optional argument to specify a glob pattern for
filtering:
@@ -284,7 +345,7 @@ filtering:
$ pytest --cache-show example/*
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
cachedir: $PYTHON_PREFIX/.pytest_cache
@@ -292,7 +353,7 @@ filtering:
example/value contains:
42
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
Clearing Cache content
----------------------

View File

@@ -49,16 +49,21 @@ Using print statements for debugging
---------------------------------------------------
One primary benefit of the default capturing of stdout/stderr output
is that you can use print statements for debugging::
is that you can use print statements for debugging:
.. code-block:: python
# content of test_module.py
def setup_function(function):
print("setting up %s" % function)
print("setting up", function)
def test_func1():
assert True
def test_func2():
assert False
@@ -69,7 +74,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 2 items
@@ -83,10 +88,10 @@ of the failing function and hide the other one:
> assert False
E assert False
test_module.py:9: AssertionError
test_module.py:12: AssertionError
-------------------------- Captured stdout setup ---------------------------
setting up <function test_func2 at 0xdeadbeef>
==================== 1 failed, 1 passed in 0.12 seconds ====================
======================= 1 failed, 1 passed in 0.12s ========================
Accessing captured output from a test function
---------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# pytest documentation build configuration file, created by
# sphinx-quickstart on Fri Oct 8 17:54:28 2010.
@@ -16,11 +15,15 @@
#
# The full version, including alpha/beta/rc tags.
# The short X.Y version.
import datetime
import os
import sys
from _pytest import __version__ as version
from _pytest.compat import TYPE_CHECKING
if TYPE_CHECKING:
import sphinx.application
release = ".".join(version.split(".")[:2])
@@ -63,9 +66,8 @@ source_suffix = ".rst"
master_doc = "contents"
# General information about the project.
project = u"pytest"
year = datetime.datetime.utcnow().year
copyright = u"20152019 , holger krekel and pytest-dev team"
project = "pytest"
copyright = "20152020, holger krekel and pytest-dev team"
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -95,7 +97,7 @@ exclude_patterns = [
# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
default_role = "literal"
# If true, '()' will be appended to :func: etc. cross-reference text.
# add_function_parentheses = True
@@ -115,6 +117,19 @@ pygments_style = "sphinx"
# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
# A list of regular expressions that match URIs that should not be checked when
# doing a linkcheck.
linkcheck_ignore = [
"https://github.com/numpy/numpy/blob/master/doc/release/1.16.0-notes.rst#new-deprecations",
"https://blogs.msdn.microsoft.com/bharry/2017/06/28/testing-in-a-cloud-delivery-cadence/",
"http://pythontesting.net/framework/pytest-introduction/",
r"https://github.com/pytest-dev/pytest/issues/\d+",
r"https://github.com/pytest-dev/pytest/pull/\d+",
]
# The number of worker threads to use when checking links (default=5).
linkcheck_workers = 5
# -- Options for HTML output ---------------------------------------------------
@@ -168,18 +183,18 @@ html_favicon = "img/pytest1favi.ico"
html_sidebars = {
"index": [
"slim_searchbox.html",
"sidebarintro.html",
"globaltoc.html",
"links.html",
"sourcelink.html",
"searchbox.html",
],
"**": [
"slim_searchbox.html",
"globaltoc.html",
"relations.html",
"links.html",
"sourcelink.html",
"searchbox.html",
],
}
@@ -233,8 +248,8 @@ latex_documents = [
(
"contents",
"pytest.tex",
u"pytest Documentation",
u"holger krekel, trainer and consultant, http://merlinux.eu",
"pytest Documentation",
"holger krekel, trainer and consultant, http://merlinux.eu",
"manual",
)
]
@@ -266,16 +281,16 @@ latex_domain_indices = False
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("usage", "pytest", u"pytest usage", [u"holger krekel at merlinux eu"], 1)]
man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"], 1)]
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = u"pytest"
epub_author = u"holger krekel at merlinux eu"
epub_publisher = u"holger krekel at merlinux eu"
epub_copyright = u"2013, holger krekel et alii"
epub_title = "pytest"
epub_author = "holger krekel at merlinux eu"
epub_publisher = "holger krekel at merlinux eu"
epub_copyright = "2013-2020, holger krekel et alii"
# The language of the text. It defaults to the language option
# or en if the language is not set.
@@ -332,7 +347,30 @@ texinfo_documents = [
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
def setup(app):
def configure_logging(app: "sphinx.application.Sphinx") -> None:
"""Configure Sphinx's WarningHandler to handle (expected) missing include."""
import sphinx.util.logging
import logging
class WarnLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord) -> bool:
"""Ignore warnings about missing include with "only" directive.
Ref: https://github.com/sphinx-doc/sphinx/issues/2150."""
if (
record.msg.startswith('Problems with "include" directive path:')
and "_changelog_towncrier_draft.rst" in record.msg
):
return False
return True
logger = logging.getLogger(sphinx.util.logging.NAMESPACE)
warn_handler = [x for x in logger.handlers if x.level == logging.WARNING]
assert len(warn_handler) == 1, warn_handler
warn_handler[0].filters.insert(0, WarnLogFilter())
def setup(app: "sphinx.application.Sphinx") -> None:
# from sphinx.ext.autodoc import cut_lines
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
app.add_object_type(
@@ -341,3 +379,4 @@ def setup(app):
objname="configuration value",
indextemplate="pair: %s; configuration value",
)
configure_logging(app)

View File

@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
collect_ignore = ["conf.py"]

View File

@@ -38,19 +38,24 @@ Full pytest documentation
customize
example/index
bash-completion
faq
backwards-compatibility
deprecations
py27-py34-deprecation
historical-notes
license
contributing
development_guide
sponsor
tidelift
license
contact
historical-notes
talks
projects
faq
contact
tidelift
.. only:: html

View File

@@ -20,8 +20,6 @@ which were registered by installed plugins.
Initialization: determining rootdir and inifile
-----------------------------------------------
pytest determines a ``rootdir`` for each test run which depends on
the command line arguments (specified test files, paths) and on
the existence of *ini-files*. The determined ``rootdir`` and *ini-file* are
@@ -30,17 +28,17 @@ printed as part of the pytest header during startup.
Here's a summary what ``pytest`` uses ``rootdir`` for:
* Construct *nodeids* during collection; each test is assigned
a unique *nodeid* which is rooted at the ``rootdir`` and takes in account full path,
class name, function name and parametrization (if any).
a unique *nodeid* which is rooted at the ``rootdir`` and takes into account
the full path, class name, function name and parametrization (if any).
* Is used by plugins as a stable location to store project/test run specific information;
for example, the internal :ref:`cache <cache>` plugin creates a ``.pytest_cache`` subdirectory
in ``rootdir`` to store its cross-test run state.
Important to emphasize that ``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
``rootdir`` is **NOT** used to modify ``sys.path``/``PYTHONPATH`` or
influence how modules are imported. See :ref:`pythonpath` for more details.
``--rootdir=path`` command-line option can be used to force a specific directory.
The ``--rootdir=path`` command-line option can be used to force a specific directory.
The directory passed may contain environment variables when it is used in conjunction
with ``addopts`` in a ``pytest.ini`` file.
@@ -107,8 +105,8 @@ check for ini-files as follows:
# first look for pytest.ini files
path/pytest.ini
path/setup.cfg # must also contain [tool:pytest] section to match
path/tox.ini # must also contain [pytest] section to match
path/setup.cfg # must also contain [tool:pytest] section to match
pytest.ini
... # all the way down to the root
@@ -134,10 +132,13 @@ progress output, you can write it into a configuration file:
.. code-block:: ini
# content of pytest.ini or tox.ini
# setup.cfg files should use [tool:pytest] section instead
[pytest]
addopts = -ra -q
# content of setup.cfg
[tool:pytest]
addopts = -ra -q
Alternatively, you can set a ``PYTEST_ADDOPTS`` environment variable to add command
line options while the environment is in use:

View File

@@ -19,12 +19,83 @@ Below is a complete list of all pytest features which are considered deprecated.
:class:`_pytest.warning_types.PytestWarning` or subclasses, which can be filtered using
:ref:`standard warning filters <warnings>`.
``junit_family`` default value change to "xunit2"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.2
The default value of ``junit_family`` option will change to ``xunit2`` in pytest 6.0, given
that this is the version supported by default in modern tools that manipulate this type of file.
In order to smooth the transition, pytest will issue a warning in case the ``--junitxml`` option
is given in the command line but ``junit_family`` is not explicitly configured in ``pytest.ini``::
PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
Add 'junit_family=legacy' to your pytest.ini file to silence this warning and make your suite compatible.
In order to silence this warning, users just need to configure the ``junit_family`` option explicitly:
.. code-block:: ini
[pytest]
junit_family=legacy
``funcargnames`` alias for ``fixturenames``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 5.0
The ``FixtureRequest``, ``Metafunc``, and ``Function`` classes track the names of
their associated fixtures, with the aptly-named ``fixturenames`` attribute.
Prior to pytest 2.3, this attribute was named ``funcargnames``, and we have kept
that as an alias since. It is finally due for removal, as it is often confusing
in places where we or plugin authors must distinguish between fixture names and
names supplied by non-fixture things such as ``pytest.mark.parametrize``.
Result log (``--result-log``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 4.0
The ``--result-log`` option produces a stream of test reports which can be
analysed at runtime, but it uses a custom format which requires users to implement their own
parser.
The `pytest-reportlog <https://github.com/pytest-dev/pytest-reportlog>`__ plugin provides a ``--report-log`` option, a more standard and extensible alternative, producing
one JSON object per-line, and should cover the same use cases. Please try it out and provide feedback.
The plan is remove the ``--result-log`` option in pytest 6.0 if ``pytest-reportlog`` proves satisfactory
to all users and is deemed stable. The ``pytest-reportlog`` plugin might even be merged into the core
at some point, depending on the plans for the plugins and number of users using it.
Removed Features
----------------
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
an appropriate period of deprecation has passed.
``pytest.config`` global
~~~~~~~~~~~~~~~~~~~~~~~~
.. versionremoved:: 5.0
The ``pytest.config`` global object is deprecated. Instead use
``request.config`` (via the ``request`` fixture) or if you are a plugin author
use the ``pytest_configure(config)`` hook. Note that many hooks can also access
the ``config`` object indirectly, through ``session.config`` or ``item.config`` for example.
.. _`raises message deprecated`:
``"message"`` parameter of ``pytest.raises``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 4.1
.. versionremoved:: 5.0
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 prevent
@@ -55,22 +126,12 @@ If you still have concerns about this deprecation and future removal, please com
`issue #3974 <https://github.com/pytest-dev/pytest/issues/3974>`__.
``pytest.config`` global
~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 4.1
The ``pytest.config`` global object is deprecated. Instead use
``request.config`` (via the ``request`` fixture) or if you are a plugin author
use the ``pytest_configure(config)`` hook. Note that many hooks can also access
the ``config`` object indirectly, through ``session.config`` or ``item.config`` for example.
.. _raises-warns-exec:
``raises`` / ``warns`` with a string as the second argument
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 4.1
.. versionremoved:: 5.0
Use the context manager form of these instead. When necessary, invoke ``exec``
directly.
@@ -102,26 +163,6 @@ Becomes:
Result log (``--result-log``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The ``--resultlog`` command line option has been deprecated: it is little used
and there are more modern and better alternatives, for example `pytest-tap <https://tappy.readthedocs.io/en/latest/>`_.
This feature will be effectively removed in pytest 4.0 as the team intends to include a better alternative in the core.
If you have any concerns, please don't hesitate to `open an issue <https://github.com/pytest-dev/pytest/issues>`__.
Removed Features
----------------
As stated in our :ref:`backwards-compatibility` policy, deprecated features are removed only in major releases after
an appropriate period of deprecation has passed.
Using ``Class`` in custom Collectors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -439,7 +480,9 @@ Internal classes accessed through ``Node``
.. versionremoved:: 4.0
Access of ``Module``, ``Function``, ``Class``, ``Instance``, ``File`` and ``Item`` through ``Node`` instances now issue
this warning::
this warning:
.. code-block:: text
usage of Function.Module is deprecated, please use pytest.Module instead

View File

@@ -29,14 +29,14 @@ then you can just invoke ``pytest`` directly:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
test_example.txt . [100%]
========================= 1 passed in 0.12 seconds =========================
============================ 1 passed in 0.12s =============================
By default, pytest will collect ``test*.txt`` files looking for doctest directives, but you
can pass additional globs using the ``--doctest-glob`` option (multi-allowed).
@@ -58,7 +58,7 @@ and functions, including from test modules:
$ pytest --doctest-modules
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 2 items
@@ -66,7 +66,7 @@ and functions, including from test modules:
mymodule.py . [ 50%]
test_example.txt . [100%]
========================= 2 passed in 0.12 seconds =========================
============================ 2 passed in 0.12s =============================
You can make these changes permanent in your project by
putting them into a pytest.ini file like this:
@@ -103,7 +103,7 @@ that will be used for those doctest files using the
Using 'doctest' options
-----------------------
The standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
configuration file.
@@ -115,23 +115,52 @@ lengthy exception stack traces you can just write:
[pytest]
doctest_optionflags= NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL
pytest also introduces new options to allow doctests to run in Python 2 and
Python 3 unchanged:
* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
strings in expected doctest output.
* ``ALLOW_BYTES``: when enabled, the ``b`` prefix is stripped from byte strings
in expected doctest output.
Alternatively, options can be enabled by an inline comment in the doc test
itself:
.. code-block:: rst
# content of example.rst
>>> get_unicode_greeting() # doctest: +ALLOW_UNICODE
'Hello'
>>> something_that_raises() # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
ValueError: ...
pytest also introduces new options:
* ``ALLOW_UNICODE``: when enabled, the ``u`` prefix is stripped from unicode
strings in expected doctest output. This allows doctests to run in Python 2
and Python 3 unchanged.
* ``ALLOW_BYTES``: similarly, the ``b`` prefix is stripped from byte strings
in expected doctest output.
* ``NUMBER``: when enabled, floating-point numbers only need to match as far as
the precision you have written in the expected doctest output. For example,
the following output would only need to match to 2 decimal places::
>>> math.pi
3.14
If you wrote ``3.1416`` then the actual output would need to match to 4
decimal places; and so on.
This avoids false positives caused by limited floating-point precision, like
this::
Expected:
0.233
Got:
0.23300000000000001
``NUMBER`` also supports lists of floating-point numbers -- in fact, it
matches floating-point numbers appearing anywhere in the output, even inside
a string! This means that it may not be appropriate to enable globally in
``doctest_optionflags`` in your configuration file.
.. versionadded:: 5.1
Continue on failure
-------------------
By default, pytest would report only the first failure for a given doctest. If
you want to continue the test even when you have failures, do:
@@ -191,15 +220,21 @@ namespace in which your doctests run. It is intended to be used within
your own fixtures to provide the tests that use them with context.
``doctest_namespace`` is a standard ``dict`` object into which you
place the objects you want to appear in the doctest namespace::
place the objects you want to appear in the doctest namespace:
.. code-block:: python
# content of conftest.py
import numpy
@pytest.fixture(autouse=True)
def add_np(doctest_namespace):
doctest_namespace['np'] = numpy
doctest_namespace["np"] = numpy
which can then be used in your doctests directly::
which can then be used in your doctests directly:
.. code-block:: python
# content of numpy.py
def arange():
@@ -219,7 +254,9 @@ Skipping tests dynamically
.. versionadded:: 4.4
You can use ``pytest.skip`` to dynamically skip doctests. For example::
You can use ``pytest.skip`` to dynamically skip doctests. For example:
.. code-block:: text
>>> import sys, pytest
>>> if sys.platform.startswith('win'):

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import _pytest._code
import pytest
from pytest import raises
@@ -21,7 +20,7 @@ def test_generative(param1, param2):
assert param1 * 2 < param2
class TestFailing(object):
class TestFailing:
def test_simple(self):
def f():
return 42
@@ -41,7 +40,7 @@ class TestFailing(object):
assert not f()
class TestSpecialisedExplanations(object):
class TestSpecialisedExplanations:
def test_eq_text(self):
assert "spam" == "eggs"
@@ -101,7 +100,7 @@ class TestSpecialisedExplanations(object):
from dataclasses import dataclass
@dataclass
class Foo(object):
class Foo:
a: int
b: str
@@ -113,7 +112,7 @@ class TestSpecialisedExplanations(object):
import attr
@attr.s
class Foo(object):
class Foo:
a = attr.ib()
b = attr.ib()
@@ -123,7 +122,7 @@ class TestSpecialisedExplanations(object):
def test_attribute():
class Foo(object):
class Foo:
b = 1
i = Foo()
@@ -131,14 +130,14 @@ def test_attribute():
def test_attribute_instance():
class Foo(object):
class Foo:
b = 1
assert Foo().b == 2
def test_attribute_failure():
class Foo(object):
class Foo:
def _get_b(self):
raise Exception("Failed to get attrib")
@@ -149,10 +148,10 @@ def test_attribute_failure():
def test_attribute_multiple():
class Foo(object):
class Foo:
b = 1
class Bar(object):
class Bar:
b = 2
assert Foo().b == Bar().b
@@ -162,7 +161,7 @@ def globf(x):
return x + 1
class TestRaises(object):
class TestRaises:
def test_raises(self):
s = "qwe"
raises(TypeError, int, s)
@@ -178,7 +177,7 @@ class TestRaises(object):
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
items = [1, 2, 3]
print("items is %r" % items)
print("items is {!r}".format(items))
a, b = items.pop()
def test_some_error(self):
@@ -191,19 +190,20 @@ class TestRaises(object):
# thanks to Matthew Scott for this test
def test_dynamic_compile_shows_nicely():
import imp
import importlib.util
import sys
src = "def foo():\n assert 1 == 0\n"
name = "abc-123"
module = imp.new_module(name)
spec = importlib.util.spec_from_loader(name, loader=None)
module = importlib.util.module_from_spec(spec)
code = _pytest._code.compile(src, name, "exec")
exec(code, module.__dict__)
sys.modules[name] = module
module.foo()
class TestMoreErrors(object):
class TestMoreErrors:
def test_complex_error(self):
def f():
return 44
@@ -253,16 +253,16 @@ class TestMoreErrors(object):
x = 0
class TestCustomAssertMsg(object):
class TestCustomAssertMsg:
def test_single_line(self):
class A(object):
class A:
a = 1
b = 2
assert A.a == b, "A.a appears not to be b"
def test_multiline(self):
class A(object):
class A:
a = 1
b = 2
@@ -271,7 +271,7 @@ class TestCustomAssertMsg(object):
), "A.a appears not to be b\nor does not appear to be b\none of those"
def test_custom_repr(self):
class JSON(object):
class JSON:
a = 1
def __repr__(self):

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import py
import pytest

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
hello = "world"

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import py
failure_demo = py.path.local(__file__).dirpath("failure_demo.py")

View File

@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
def setup_module(module):
module.TestStateFullThing.classcount = 0
class TestStateFullThing(object):
class TestStateFullThing:
def setup_class(cls):
cls.classcount += 1

View File

@@ -18,7 +18,7 @@ example: specifying and selecting acceptance tests
return AcceptFixture(request)
class AcceptFixture(object):
class AcceptFixture:
def __init__(self, request):
if not request.config.getoption("acceptance"):
pytest.skip("specify -A to run acceptance tests")
@@ -65,7 +65,7 @@ extend the `accept example`_ by putting this in our test module:
return arg
class TestSpecialAcceptance(object):
class TestSpecialAcceptance:
def test_sometest(self, accept):
assert accept.tmpdir.join("special").check()

View File

@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
collect_ignore = ["nonpython"]

View File

@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
import pytest
@pytest.fixture("session")
@pytest.fixture(scope="session")
def setup(request):
setup = CostlySetup()
yield setup
setup.finalize()
class CostlySetup(object):
class CostlySetup:
def __init__(self):
import time

View File

@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
#

View File

@@ -1,3 +1,2 @@
# -*- coding: utf-8 -*-
def test_quick(setup):
pass

View File

@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
#

View File

@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
def test_something(setup):
assert setup.timecostly == 1

View File

@@ -0,0 +1,38 @@
import pytest
# fixtures documentation order example
order = []
@pytest.fixture(scope="session")
def s1():
order.append("s1")
@pytest.fixture(scope="module")
def m1():
order.append("m1")
@pytest.fixture
def f1(f3):
order.append("f1")
@pytest.fixture
def f3():
order.append("f3")
@pytest.fixture(autouse=True)
def a1():
order.append("a1")
@pytest.fixture
def f2():
order.append("f2")
def test_order(f1, m1, f2, s1):
assert order == ["s1", "m1", "a1", "f3", "f1", "f2"]

View File

@@ -33,7 +33,7 @@ You can "mark" a test function with custom metadata like this:
pass
class TestClass(object):
class TestClass:
def test_method(self):
pass
@@ -45,14 +45,14 @@ You can then restrict a test run to only run tests marked with ``webtest``:
$ pytest -v -m 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/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 4 items / 3 deselected / 1 selected
test_server.py::test_send_http PASSED [100%]
================== 1 passed, 3 deselected in 0.12 seconds ==================
===================== 1 passed, 3 deselected in 0.12s ======================
Or the inverse, running all tests except the webtest ones:
@@ -60,7 +60,7 @@ Or the inverse, running all tests except the webtest ones:
$ pytest -v -m "not 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/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 4 items / 1 deselected / 3 selected
@@ -69,7 +69,7 @@ Or the inverse, running all tests except the webtest ones:
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.12s ======================
Selecting tests based on their node ID
--------------------------------------
@@ -82,14 +82,14 @@ tests based on their module, class, method, or function name:
$ pytest -v test_server.py::TestClass::test_method
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 1 item
test_server.py::TestClass::test_method PASSED [100%]
========================= 1 passed in 0.12 seconds =========================
============================ 1 passed in 0.12s =============================
You can also select on the class:
@@ -97,14 +97,14 @@ You can also select on the class:
$ pytest -v test_server.py::TestClass
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 1 item
test_server.py::TestClass::test_method PASSED [100%]
========================= 1 passed in 0.12 seconds =========================
============================ 1 passed in 0.12s =============================
Or select multiple nodes:
@@ -112,7 +112,7 @@ Or select multiple nodes:
$ pytest -v test_server.py::TestClass test_server.py::test_send_http
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 2 items
@@ -120,7 +120,7 @@ Or select multiple nodes:
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.12s =============================
.. _node-id:
@@ -152,14 +152,14 @@ select tests based on their names:
$ pytest -v -k http # running with the above defined example module
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 4 items / 3 deselected / 1 selected
test_server.py::test_send_http PASSED [100%]
================== 1 passed, 3 deselected in 0.12 seconds ==================
===================== 1 passed, 3 deselected in 0.12s ======================
And you can also run all tests except the ones that match the keyword:
@@ -167,7 +167,7 @@ And you can also run all tests except the ones that match the keyword:
$ pytest -k "not send_http" -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/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 4 items / 1 deselected / 3 selected
@@ -176,7 +176,7 @@ And you can also run all tests except the ones that match the keyword:
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.12s ======================
Or to select "http" and "quick" tests:
@@ -184,7 +184,7 @@ Or to select "http" and "quick" tests:
$ pytest -k "http or quick" -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/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 4 items / 2 deselected / 2 selected
@@ -192,7 +192,7 @@ Or to select "http" and "quick" tests:
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.12s ======================
.. note::
@@ -278,7 +278,7 @@ its test methods:
@pytest.mark.webtest
class TestClass(object):
class TestClass:
def test_startup(self):
pass
@@ -288,15 +288,14 @@ its test methods:
This is equivalent to directly applying the decorator to the
two test functions.
To remain backward-compatible with Python 2.4 you can also set a
``pytestmark`` attribute on a TestClass like this:
Due to legacy reasons, it is possible to set the ``pytestmark`` attribute on a TestClass like this:
.. code-block:: python
import pytest
class TestClass(object):
class TestClass:
pytestmark = pytest.mark.webtest
or if you need to use multiple markers you can use a list:
@@ -306,7 +305,7 @@ or if you need to use multiple markers you can use a list:
import pytest
class TestClass(object):
class TestClass:
pytestmark = [pytest.mark.webtest, pytest.mark.slowtest]
You can also set a module level marker::
@@ -337,7 +336,7 @@ apply a marker to an individual test instance:
@pytest.mark.foo
@pytest.mark.parametrize(
("n", "expected"), [(1, 2), pytest.param((1, 3), marks=pytest.mark.bar), (2, 3)]
("n", "expected"), [(1, 2), pytest.param(1, 3, marks=pytest.mark.bar), (2, 3)]
)
def test_increment(n, expected):
assert n + 1 == expected
@@ -385,7 +384,7 @@ specifies via named environments:
envnames = [mark.args[0] for mark in item.iter_markers(name="env")]
if envnames:
if item.config.getoption("-E") not in envnames:
pytest.skip("test requires env in %r" % envnames)
pytest.skip("test requires env in {!r}".format(envnames))
A test file using this local plugin:
@@ -407,14 +406,14 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
test_someenv.py s [100%]
======================== 1 skipped in 0.12 seconds =========================
============================ 1 skipped in 0.12s ============================
and here is one that specifies exactly the environment needed:
@@ -422,14 +421,14 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
test_someenv.py . [100%]
========================= 1 passed in 0.12 seconds =========================
============================ 1 passed in 0.12s =============================
The ``--markers`` option always gives you a list of available markers:
@@ -500,7 +499,7 @@ The output is as follows:
$ pytest -q -s
Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef>,), kwargs={})
.
1 passed in 0.12 seconds
1 passed in 0.12s
We can see that the custom marker has its argument set extended with the function ``hello_world``. This is the key difference between creating a custom marker as a callable, which invokes ``__call__`` behind the scenes, and using ``with_args``.
@@ -524,7 +523,7 @@ code you can read over all such settings. Example:
@pytest.mark.glob("class", x=2)
class TestClass(object):
class TestClass:
@pytest.mark.glob("function", x=3)
def test_something(self):
pass
@@ -540,7 +539,7 @@ test function. From a conftest file we can read it like this:
def pytest_runtest_setup(item):
for mark in item.iter_markers(name="glob"):
print("glob args=%s kwargs=%s" % (mark.args, mark.kwargs))
print("glob args={} kwargs={}".format(mark.args, mark.kwargs))
sys.stdout.flush()
Let's run this without capturing output and see what we get:
@@ -552,7 +551,7 @@ Let's run this without capturing output and see what we get:
glob args=('class',) kwargs={'x': 2}
glob args=('module',) kwargs={'x': 1}
.
1 passed in 0.12 seconds
1 passed in 0.12s
marking platform specific tests with pytest
--------------------------------------------------------------
@@ -579,7 +578,7 @@ for your particular platform, you could use the following plugin:
supported_platforms = ALL.intersection(mark.name for mark in item.iter_markers())
plat = sys.platform
if supported_platforms and plat not in supported_platforms:
pytest.skip("cannot run on platform %s" % (plat))
pytest.skip("cannot run on platform {}".format(plat))
then tests will be skipped if they were specified for a different platform.
Let's do a little test file to show how this looks like:
@@ -615,7 +614,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items
@@ -623,8 +622,8 @@ then you will see two tests skipped and two executed tests as expected:
test_plat.py s.s. [100%]
========================= short test summary info ==========================
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:13: cannot run on platform linux
=================== 2 passed, 2 skipped in 0.12 seconds ====================
SKIPPED [2] $REGENDOC_TMPDIR/conftest.py:12: cannot run on platform linux
======================= 2 passed, 2 skipped in 0.12s =======================
Note that if you specify a platform via the marker-command line option like this:
@@ -632,14 +631,14 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items / 3 deselected / 1 selected
test_plat.py . [100%]
================== 1 passed, 3 deselected in 0.12 seconds ==================
===================== 1 passed, 3 deselected in 0.12s ======================
then the unmarked-tests will not be run. It is thus a way to restrict the run to the specific tests.
@@ -696,7 +695,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items / 2 deselected / 2 selected
@@ -712,7 +711,7 @@ We can now use the ``-m option`` to select one set:
test_module.py:8: in test_interface_complex
assert 0
E assert 0
================== 2 failed, 2 deselected in 0.12 seconds ==================
===================== 2 failed, 2 deselected in 0.12s ======================
or to select both "event" and "interface" tests:
@@ -720,7 +719,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items / 1 deselected / 3 selected
@@ -740,4 +739,4 @@ or to select both "event" and "interface" tests:
test_module.py:12: in test_event_simple
assert 0
E assert 0
================== 3 failed, 1 deselected in 0.12 seconds ==================
===================== 3 failed, 1 deselected in 0.12s ======================

View File

@@ -1,15 +1,14 @@
# -*- coding: utf-8 -*-
"""
module containing a parametrized tests testing cross-python
serialization via the pickle module.
"""
import distutils.spawn
import shutil
import subprocess
import textwrap
import pytest
pythonlist = ["python2.7", "python3.4", "python3.5"]
pythonlist = ["python3.5", "python3.6", "python3.7"]
@pytest.fixture(params=pythonlist)
@@ -23,9 +22,9 @@ def python2(request, python1):
return Python(request.param, python1.picklefile)
class Python(object):
class Python:
def __init__(self, version, picklefile):
self.pythonpath = distutils.spawn.find_executable(version)
self.pythonpath = shutil.which(version)
if not self.pythonpath:
pytest.skip("{!r} not found".format(version))
self.picklefile = picklefile
@@ -70,4 +69,4 @@ class Python(object):
@pytest.mark.parametrize("obj", [42, {}, {1: 3}])
def test_basic_objects(python1, python2, obj):
python1.dumps(obj)
python2.load_and_is_true("obj == %s" % obj)
python2.load_and_is_true("obj == {}".format(obj))

View File

@@ -12,14 +12,14 @@ A basic example for specifying tests in Yaml files
.. _`pytest-yamlwsgi`: http://bitbucket.org/aafshar/pytest-yamlwsgi/src/tip/pytest_yamlwsgi.py
.. _`PyYAML`: https://pypi.org/project/PyYAML/
Here is an example ``conftest.py`` (extracted from Ali Afshnars special purpose `pytest-yamlwsgi`_ plugin). This ``conftest.py`` will collect ``test*.yml`` files and will execute the yaml-formatted content as custom tests:
Here is an example ``conftest.py`` (extracted from Ali Afshnars special purpose `pytest-yamlwsgi`_ plugin). This ``conftest.py`` will collect ``test*.yaml`` files and will execute the yaml-formatted content as custom tests:
.. include:: nonpython/conftest.py
:literal:
You can create a simple example file:
.. include:: nonpython/test_simple.yml
.. include:: nonpython/test_simple.yaml
:literal:
and if you installed `PyYAML`_ or a compatible YAML-parser you can
@@ -27,21 +27,21 @@ now execute the test specification:
.. code-block:: pytest
nonpython $ pytest test_simple.yml
nonpython $ pytest test_simple.yaml
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
collected 2 items
test_simple.yml F. [100%]
test_simple.yaml F. [100%]
================================= 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.12s ========================
.. regendoc:wipe
@@ -64,20 +64,20 @@ consulted when reporting in ``verbose`` mode:
nonpython $ pytest -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/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
collecting ... collected 2 items
test_simple.yml::hello FAILED [ 50%]
test_simple.yml::ok PASSED [100%]
test_simple.yaml::hello FAILED [ 50%]
test_simple.yaml::ok PASSED [100%]
================================= 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.12s ========================
.. regendoc:wipe
@@ -88,13 +88,13 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
collected 2 items
<Package $REGENDOC_TMPDIR/nonpython>
<YamlFile test_simple.yml>
<YamlFile test_simple.yaml>
<YamlItem hello>
<YamlItem ok>
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================

View File

@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
# content of conftest.py
import pytest
def pytest_collect_file(parent, path):
if path.ext == ".yml" and path.basename.startswith("test"):
if path.ext == ".yaml" and path.basename.startswith("test"):
return YamlFile(path, parent)
@@ -19,7 +18,7 @@ class YamlFile(pytest.File):
class YamlItem(pytest.Item):
def __init__(self, name, parent, spec):
super(YamlItem, self).__init__(name, parent)
super().__init__(name, parent)
self.spec = spec
def runtest(self):
@@ -34,13 +33,13 @@ class YamlItem(pytest.Item):
return "\n".join(
[
"usecase execution failed",
" spec failed: %r: %r" % excinfo.value.args[1:3],
" spec failed: {1!r}: {2!r}".format(*excinfo.value.args),
" no further details known at this point.",
]
)
def reportinfo(self):
return self.fspath, 0, "usecase: %s" % self.name
return self.fspath, 0, "usecase: {}".format(self.name)
class YamlException(Exception):

View File

@@ -1,4 +1,4 @@
# test_simple.yml
# test_simple.yaml
ok:
sub1: sub1

View File

@@ -19,24 +19,30 @@ Generating parameters combinations, depending on command line
Let's say we want to execute a test with different computation
parameters and the parameter range shall be determined by a command
line argument. Let's first write a simple (do-nothing) computation test::
line argument. Let's first write a simple (do-nothing) computation test:
.. code-block:: python
# content of test_compute.py
def test_compute(param1):
assert param1 < 4
Now we add a test configuration like this::
Now we add a test configuration like this:
.. code-block:: python
# content of conftest.py
def pytest_addoption(parser):
parser.addoption("--all", action="store_true",
help="run all combinations")
parser.addoption("--all", action="store_true", help="run all combinations")
def pytest_generate_tests(metafunc):
if 'param1' in metafunc.fixturenames:
if metafunc.config.getoption('all'):
if "param1" in metafunc.fixturenames:
if metafunc.config.getoption("all"):
end = 5
else:
end = 2
@@ -48,7 +54,7 @@ This means that we only run 2 tests if we do not pass ``--all``:
$ pytest -q test_compute.py
.. [100%]
2 passed in 0.12 seconds
2 passed in 0.12s
We run only two computations, so we see two dots.
let's run the full monty:
@@ -66,8 +72,8 @@ let's run the full monty:
> assert param1 < 4
E assert 4 < 4
test_compute.py:3: AssertionError
1 failed, 4 passed in 0.12 seconds
test_compute.py:4: AssertionError
1 failed, 4 passed in 0.12s
As expected when running the full range of ``param1`` values
we'll get an error on the last one.
@@ -83,7 +89,9 @@ Running pytest with ``--collect-only`` will show the generated IDs.
Numbers, strings, booleans and None will have their usual string representation
used in the test ID. For other objects, pytest will make a string based on
the argument name::
the argument name:
.. code-block:: python
# content of test_time.py
@@ -112,7 +120,7 @@ the argument name::
def idfn(val):
if isinstance(val, (datetime,)):
# note this wouldn't show any hours/minutes/seconds
return val.strftime('%Y%m%d')
return val.strftime("%Y%m%d")
@pytest.mark.parametrize("a,b,expected", testdata, ids=idfn)
@@ -120,12 +128,18 @@ the argument name::
diff = a - b
assert diff == expected
@pytest.mark.parametrize("a,b,expected", [
pytest.param(datetime(2001, 12, 12), datetime(2001, 12, 11),
timedelta(1), id='forward'),
pytest.param(datetime(2001, 12, 11), datetime(2001, 12, 12),
timedelta(-1), id='backward'),
])
@pytest.mark.parametrize(
"a,b,expected",
[
pytest.param(
datetime(2001, 12, 12), datetime(2001, 12, 11), timedelta(1), id="forward"
),
pytest.param(
datetime(2001, 12, 11), datetime(2001, 12, 12), timedelta(-1), id="backward"
),
],
)
def test_timedistance_v3(a, b, expected):
diff = a - b
assert diff == expected
@@ -144,7 +158,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 8 items
@@ -158,7 +172,7 @@ objects, they are still using the default pytest representation:
<Function test_timedistance_v3[forward]>
<Function test_timedistance_v3[backward]>
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
In ``test_timedistance_v3``, we used ``pytest.param`` to specify the test IDs
together with the actual data, instead of listing them separately.
@@ -171,10 +185,13 @@ A quick port of "testscenarios"
Here is a quick port to run tests configured with `test scenarios`_,
an add-on from Robert Collins for the standard unittest framework. We
only have to work a bit to construct the correct arguments for pytest's
:py:func:`Metafunc.parametrize`::
:py:func:`Metafunc.parametrize`:
.. code-block:: python
# content of test_scenarios.py
def pytest_generate_tests(metafunc):
idlist = []
argvalues = []
@@ -182,13 +199,15 @@ only have to work a bit to construct the correct arguments for pytest's
idlist.append(scenario[0])
items = scenario[1].items()
argnames = [x[0] for x in items]
argvalues.append(([x[1] for x in items]))
argvalues.append([x[1] for x in items])
metafunc.parametrize(argnames, argvalues, ids=idlist, scope="class")
scenario1 = ('basic', {'attribute': 'value'})
scenario2 = ('advanced', {'attribute': 'value2'})
class TestSampleWithScenarios(object):
scenario1 = ("basic", {"attribute": "value"})
scenario2 = ("advanced", {"attribute": "value2"})
class TestSampleWithScenarios:
scenarios = [scenario1, scenario2]
def test_demo1(self, attribute):
@@ -203,14 +222,14 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items
test_scenarios.py .... [100%]
========================= 4 passed in 0.12 seconds =========================
============================ 4 passed in 0.12s =============================
If you just collect tests you'll also nicely see 'advanced' and 'basic' as variants for the test function:
@@ -218,7 +237,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 4 items
@@ -229,7 +248,7 @@ If you just collect tests you'll also nicely see 'advanced' and 'basic' as varia
<Function test_demo1[advanced]>
<Function test_demo2[advanced]>
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
Note that we told ``metafunc.parametrize()`` that your scenario values
should be considered class-scoped. With pytest-2.3 this leads to a
@@ -243,12 +262,16 @@ Deferring the setup of parametrized resources
The parametrization of test functions happens at collection
time. It is a good idea to setup expensive resources like DB
connections or subprocess only when the actual test is run.
Here is a simple example how you can achieve that, first
the actual test requiring a ``db`` object::
Here is a simple example how you can achieve that. This test
requires a ``db`` object fixture:
.. code-block:: python
# content of test_backends.py
import pytest
def test_db_initialized(db):
# a dummy test
if db.__class__.__name__ == "DB2":
@@ -256,20 +279,27 @@ the actual test requiring a ``db`` object::
We can now add a test configuration that generates two invocations of
the ``test_db_initialized`` function and also implements a factory that
creates a database object for the actual test invocations::
creates a database object for the actual test invocations:
.. code-block:: python
# content of conftest.py
import pytest
def pytest_generate_tests(metafunc):
if 'db' in metafunc.fixturenames:
metafunc.parametrize("db", ['d1', 'd2'], indirect=True)
class DB1(object):
def pytest_generate_tests(metafunc):
if "db" in metafunc.fixturenames:
metafunc.parametrize("db", ["d1", "d2"], indirect=True)
class DB1:
"one database object"
class DB2(object):
class DB2:
"alternative database object"
@pytest.fixture
def db(request):
if request.param == "d1":
@@ -285,7 +315,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 2 items
@@ -293,7 +323,7 @@ Let's first see how it looks like at collection time:
<Function test_db_initialized[d1]>
<Function test_db_initialized[d2]>
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
And then when we run the test:
@@ -312,8 +342,8 @@ And then when we run the test:
> pytest.fail("deliberately failing for demo purposes")
E Failed: deliberately failing for demo purposes
test_backends.py:6: Failed
1 failed, 1 passed in 0.12 seconds
test_backends.py:8: Failed
1 failed, 1 passed in 0.12s
The first invocation with ``db == "DB1"`` passed while the second with ``db == "DB2"`` failed. Our ``db`` fixture function has instantiated each of the DB values during the setup phase while the ``pytest_generate_tests`` generated two according calls to the ``test_db_initialized`` during the collection phase.
@@ -327,23 +357,29 @@ parameter on particular arguments. It can be done by passing list or tuple of
arguments' names to ``indirect``. In the example below there is a function ``test_indirect`` which uses
two fixtures: ``x`` and ``y``. Here we give to indirect the list, which contains the name of the
fixture ``x``. The indirect parameter will be applied to this argument only, and the value ``a``
will be passed to respective fixture function::
will be passed to respective fixture function:
.. code-block:: python
# content of test_indirect_list.py
import pytest
@pytest.fixture(scope='function')
@pytest.fixture(scope="function")
def x(request):
return request.param * 3
@pytest.fixture(scope='function')
@pytest.fixture(scope="function")
def y(request):
return request.param * 2
@pytest.mark.parametrize('x, y', [('a', 'b')], indirect=['x'])
def test_indirect(x,y):
assert x == 'aaa'
assert y == 'b'
@pytest.mark.parametrize("x, y", [("a", "b")], indirect=["x"])
def test_indirect(x, y):
assert x == "aaa"
assert y == "b"
The result of this test will be successful:
@@ -351,14 +387,14 @@ 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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 1 item
<Module test_indirect_list.py>
<Function test_indirect[a-b]>
======================= no tests ran in 0.12 seconds =======================
========================== no tests ran in 0.12s ===========================
.. regendoc:wipe
@@ -370,23 +406,28 @@ Parametrizing test methods through per-class configuration
Here is an example ``pytest_generate_tests`` function implementing a
parametrization scheme similar to Michael Foord's `unittest
parametrizer`_ but in a lot less code::
parametrizer`_ but in a lot less code:
.. code-block:: python
# content of ./test_parametrize.py
import pytest
def pytest_generate_tests(metafunc):
# called once per each test function
funcarglist = metafunc.cls.params[metafunc.function.__name__]
argnames = sorted(funcarglist[0])
metafunc.parametrize(argnames, [[funcargs[name] for name in argnames]
for funcargs in funcarglist])
metafunc.parametrize(
argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist]
)
class TestClass(object):
class TestClass:
# a map specifying multiple argument sets for a test method
params = {
'test_equals': [dict(a=1, b=2), dict(a=3, b=3), ],
'test_zerodivision': [dict(a=1, b=0), ],
"test_equals": [dict(a=1, b=2), dict(a=3, b=3)],
"test_zerodivision": [dict(a=1, b=0)],
}
def test_equals(self, a, b):
@@ -412,8 +453,8 @@ argument sets to use for each test function. Let's run it:
> assert a == b
E assert 1 == 2
test_parametrize.py:18: AssertionError
1 failed, 2 passed in 0.12 seconds
test_parametrize.py:21: AssertionError
1 failed, 2 passed in 0.12s
Indirect parametrization with multiple fixtures
--------------------------------------------------------------
@@ -429,15 +470,16 @@ is to be run with different sets of arguments for its three arguments:
.. literalinclude:: multipython.py
Running it results in some skips if we don't have all the python interpreters installed and otherwise runs all combinations (5 interpreters times 5 interpreters times 3 objects to serialize/deserialize):
Running it results in some skips if we don't have all the python interpreters installed and otherwise runs all combinations (3 interpreters times 3 interpreters times 3 objects to serialize/deserialize):
.. code-block:: pytest
. $ pytest -rs -q multipython.py
...sss...sssssssss...sss... [100%]
ssssssssssssssssssssssss... [100%]
========================= short test summary info ==========================
SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:31: 'python3.4' not found
12 passed, 15 skipped in 0.12 seconds
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.5' not found
SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:29: 'python3.6' not found
3 passed, 24 skipped in 0.12s
Indirect parametrization of optional implementations/imports
--------------------------------------------------------------------
@@ -446,36 +488,47 @@ If you want to compare the outcomes of several implementations of a given
API, you can write test functions that receive the already imported implementations
and get skipped in case the implementation is not importable/available. Let's
say we have a "base" implementation and the other (possibly optimized ones)
need to provide similar results::
need to provide similar results:
.. code-block:: python
# content of conftest.py
import pytest
@pytest.fixture(scope="session")
def basemod(request):
return pytest.importorskip("base")
@pytest.fixture(scope="session", params=["opt1", "opt2"])
def optmod(request):
return pytest.importorskip(request.param)
And then a base implementation of a simple function::
And then a base implementation of a simple function:
.. code-block:: python
# content of base.py
def func1():
return 1
And an optimized version::
And an optimized version:
.. code-block:: python
# content of opt1.py
def func1():
return 1.0001
And finally a little test module::
And finally a little test module:
.. code-block:: python
# content of test_module.py
def test_func1(basemod, optmod):
assert round(basemod.func1(), 3) == round(optmod.func1(), 3)
@@ -486,7 +539,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
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collected 2 items
@@ -494,8 +547,8 @@ If you run this with reporting for skips enabled:
test_module.py .s [100%]
========================= short test summary info ==========================
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:11: could not import 'opt2': No module named 'opt2'
=================== 1 passed, 1 skipped in 0.12 seconds ====================
SKIPPED [1] $REGENDOC_TMPDIR/conftest.py:12: could not import 'opt2': No module named 'opt2'
======================= 1 passed, 1 skipped in 0.12s =======================
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:
@@ -548,7 +601,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker:
$ pytest -v -m basic
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-4.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
platform linux -- Python 3.x.y, pytest-5.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 17 items / 14 deselected / 3 selected
@@ -557,7 +610,7 @@ Then run ``pytest`` with verbose mode and with only the ``basic`` marker:
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.12s ================
As the result:
@@ -578,22 +631,28 @@ Use :func:`pytest.raises` with the
in which some tests raise exceptions and others do not.
It is helpful to define a no-op context manager ``does_not_raise`` to serve
as a complement to ``raises``. For example::
as a complement to ``raises``. For example:
.. code-block:: python
from contextlib import contextmanager
import pytest
@contextmanager
def does_not_raise():
yield
@pytest.mark.parametrize('example_input,expectation', [
(3, does_not_raise()),
(2, does_not_raise()),
(1, does_not_raise()),
(0, pytest.raises(ZeroDivisionError)),
])
@pytest.mark.parametrize(
"example_input,expectation",
[
(3, does_not_raise()),
(2, does_not_raise()),
(1, does_not_raise()),
(0, pytest.raises(ZeroDivisionError)),
],
)
def test_division(example_input, expectation):
"""Test how much I know division."""
with expectation:
@@ -603,14 +662,20 @@ In the example above, the first three test cases should run unexceptionally,
while the fourth should raise ``ZeroDivisionError``.
If you're only supporting Python 3.7+, you can simply use ``nullcontext``
to define ``does_not_raise``::
to define ``does_not_raise``:
.. code-block:: python
from contextlib import nullcontext as does_not_raise
Or, if you're supporting Python 3.3+ you can use::
Or, if you're supporting Python 3.3+ you can use:
.. code-block:: python
from contextlib import ExitStack as does_not_raise
Or, if desired, you can ``pip install contextlib2`` and use::
Or, if desired, you can ``pip install contextlib2`` and use:
from contextlib2 import ExitStack as does_not_raise
.. code-block:: python
from contextlib2 import nullcontext as does_not_raise

Some files were not shown because too many files have changed in this diff Show More