Compare commits

..

979 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
3f12087fe0 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-02-11 15:56:37 +00:00
pytest bot
bc3021cdfd Prepare release version 7.0.1 2022-02-11 15:54:45 +00:00
Bruno Oliveira
591d476f14 Merge pull request #9673 from nicoddemus/backport-9511
[7.0.x] Enable testing with Python 3.11 (#9511)
2022-02-11 12:45:35 -03:00
Bruno Oliveira
6ca733e8f1 Enable testing with Python 3.11 (#9511) 2022-02-11 12:26:29 -03:00
Bruno Oliveira
ac37b1b113 Merge pull request #9671 from nicoddemus/backport-9668
[7.0.x] Merge pull request #9668 from hugovk/test-me-latest-3.10
2022-02-11 12:21:36 -03:00
Bruno Oliveira
c891e402ac Merge pull request #9672 from nicoddemus/backport-9669
[7.0.x] Merge pull request #9669 from hugovk/ci-only-update-plugin-list-for-upstream
2022-02-11 10:00:08 -03:00
Bruno Oliveira
e2753a2b8b Merge pull request #9669 from hugovk/ci-only-update-plugin-list-for-upstream 2022-02-11 09:34:30 -03:00
Bruno Oliveira
b5a154c1d9 Merge pull request #9668 from hugovk/test-me-latest-3.10 2022-02-11 09:28:15 -03:00
Bruno Oliveira
0fae45bb6e Merge pull request #9660 from pytest-dev/backport-9646-to-7.0.x 2022-02-10 14:30:27 -03:00
Bruno Oliveira
37d434f5fc [7.0.x] Delay warning about collector/item diamond inheritance 2022-02-10 17:12:02 +00:00
github-actions[bot]
6684110408 [7.0.x] unittest: restore UnitTestFunction.obj to return unbound rather than bound method (#9656)
Co-authored-by: Ran Benita <ran@unusedvar.com>
2022-02-09 23:20:31 +01:00
Ran Benita
ed8255c811 Merge pull request #9653 from pytest-dev/backport-9651-to-7.0.x
[7.0.x] Rename ``pythonpath`` plugin to ``python_path``
2022-02-09 13:54:07 +02:00
Ran Benita
453bcb1b83 [7.0.x] Rename `pythonpath plugin to python_path` 2022-02-09 11:20:53 +00:00
Bruno Oliveira
a24c78b7af Merge pull request #9649 from pytest-dev/backport-9642-to-7.0.x 2022-02-08 13:26:10 -03:00
Anthony Sottile
4bf8aff5b7 [7.0.x] allow running testids which contain :: in the parametrized portion 2022-02-08 16:09:06 +00:00
Ran Benita
462a6f0de6 Merge pull request #9647 from pytest-dev/backport-9609-to-7.0.x
[7.0.x] importlib.readers not valid until python 3.10
2022-02-08 17:54:38 +02:00
Ran Benita
c588a4720e [7.0.x] importlib.readers not valid until python 3.10 2022-02-08 17:36:38 +02:00
Ran Benita
048a10bd96 Merge pull request #9648 from pytest-dev/backport-9638-to-7.0.x
[7.0.x] work around test pollution caused by new setuptools mutating global logger level
2022-02-08 16:52:39 +02:00
Anthony Sottile
3c35477230 [7.0.x] work around test pollution caused by new setuptools mutating global logger level 2022-02-08 14:32:58 +00:00
github-actions[bot]
5eb4d6977c [7.0.x] doc: Hide done training (#9605)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-02-04 11:42:53 +00:00
github-actions[bot]
e37fbe5685 Prepare release 7.0.0 (#9598)
* Prepare release version 7.0.0

* Add note to changelog

Co-authored-by: pytest bot <pytestbot@gmail.com>
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-02-04 11:23:39 +01:00
github-actions[bot]
737b220516 [7.0.x] releasing: Add template for major releases (#9597)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-02-03 17:04:19 +01:00
github-actions[bot]
7fa3972963 [7.0.x] releasing: Always set doc_version (#9590)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-02-03 11:07:47 +00:00
github-actions[bot]
b304499925 [7.0.x] Make 'warnings' and 'deselected' in assert_outcomes optional (#9566)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2022-01-27 14:18:54 +00:00
github-actions[bot]
f17525df26 [7.0.x] doc: Add ellipsis to warning usecase list (#9562)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-01-27 10:36:58 -03:00
Florian Bruhin
0a7be971d2 ci: Bump up timeout (#9565)
macOS apparently can be slow, https://github.com/pytest-dev/pytest/runs/4965510831 for #9556 got cancelled at 91%

(cherry picked from commit 7bffcd0ac4)
2022-01-27 10:36:25 -03:00
github-actions[bot]
c17908cdb3 [7.0.x] doc: Recategorize 7.0.0 changelog items (#9564)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-01-27 10:36:15 -03:00
github-actions[bot]
ab549bba8a [7.0.x] Add missing cooperative constructor changelog (#9563)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-01-27 10:36:04 -03:00
github-actions[bot]
4b1707ff70 [7.0.x] Autouse linearization graph (#9557)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2022-01-27 11:57:34 +00:00
github-actions[bot]
28e5b3b8b7 [7.0.x] Add additional docs for uncooperative ctor deprecation (#9552)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2022-01-27 11:54:34 +00:00
Bruno Oliveira
e854d05328 Merge pull request #9550 from pytest-dev/backport-9545-to-7.0.x 2022-01-27 07:54:44 -03:00
Ran Benita
48e64feac7 [7.0.x] doc/reference: don't document pytest.__version__ under "Marks" 2022-01-27 08:50:18 +00:00
Bruno Oliveira
b66899d322 Merge pull request #9530 from nicoddemus/backport-9522 2022-01-25 16:53:49 -03:00
Ran Benita
b1b1bd03a8 Merge pull request #9544 from bluetech/backport-9532
[7.0.x] config: avoid stat storm in _getconftestmodules
2022-01-25 21:53:12 +02:00
Ran Benita
6639d6c7d8 Merge pull request #9532 from bluetech/getdir-cache
config: avoid stat storm in _getconftestmodules

(cherry picked from commit 5c69eced6c)

Conflicts:
	src/_pytest/config/__init__.py
2022-01-25 18:46:16 +02:00
Bruno Oliveira
6a1b8e4b28 Merge pull request #9522 from holmanb/rewrite-test 2022-01-20 13:21:48 -03:00
Ran Benita
5c49dea989 Merge pull request #9513 from pytest-dev/backport-9512-to-7.0.x
[7.0.x] testing: avoid private pluggy attributes in test
2022-01-14 18:30:33 +02:00
Ran Benita
a1635ca49a [7.0.x] testing: avoid private pluggy attributes in test 2022-01-14 16:10:54 +00:00
Bruno Oliveira
46c06e7560 Merge pull request #9508 from pytest-dev/backport-9495-to-7.0.x 2022-01-13 17:11:22 -03:00
Olga Matoula
94bcd2ce0f [7.0.x] Add docs on pytest.warns(None) deprecation 2022-01-13 19:51:06 +00:00
Bruno Oliveira
4967a0d084 Merge pull request #9507 from nicoddemus/backport-9506
[7.0.x] Improve on configuration file docs section
2022-01-13 15:14:32 -03:00
Bruno Oliveira
efa02cffdd Merge pull request #9506 from eamanu/fix-9505 2022-01-13 13:55:08 -03:00
Ran Benita
b5a6e30dae Merge pull request #9499 from pytest-dev/backport-9494-to-7.0.x
[7.0.x] python: add back `instance` accessor to all python nodes, not just Function
2022-01-10 21:28:12 +02:00
Ran Benita
d0ae12ca76 [7.0.x] python: add back instance accessor to all python nodes, not just Function 2022-01-10 19:09:14 +00:00
Ran Benita
0c5fc61610 Merge pull request #9485 from pytest-dev/backport-9484-to-7.0.x
[7.0.x] config: fix incorrect cache hit check in _getconftestmodules
2022-01-07 13:44:58 +02:00
Ran Benita
41cb93b549 [7.0.x] config: fix incorrect cache hit check in _getconftestmodules 2022-01-07 11:28:12 +00:00
Bruno Oliveira
7381ce2d83 Merge pull request #9474 from pytest-dev/backport-9400-to-7.0.x 2022-01-04 11:28:51 -03:00
Bruno Oliveira
5d151c0e7c Merge pull request #9476 from pytest-dev/backport-9464-to-7.0.x 2022-01-04 11:27:48 -03:00
Dan Alvizu
f988e070c6 [7.0.x] Doc update: clarify -W syntax 2022-01-04 14:04:18 +00:00
Bruno Oliveira
1a04121f2f [7.0.x] Ensure Config.inifile is available during pytest_cmdline_main 2022-01-04 13:24:11 +00:00
Ran Benita
8542eb47c4 Merge pull request #9453 from bluetech/backport-9451
[7.0.x] Backport "doc: document {Code,TracebackEntry}.path changes as breaking"
2021-12-28 10:55:24 +02:00
Ran Benita
4f79cea72d Merge pull request #9451 from bluetech/code-path-changelog
doc: document {Code,TracebackEntry}.path changes as breaking
(cherry picked from commit 1131f23e04)
2021-12-27 17:01:04 +02:00
Ran Benita
c76989352f Merge pull request #9450 from bluetech/backport-9438
[7.0.x] Backport "pytest: bring back direct imports of TempdirFactory, Testdir"
2021-12-27 16:54:01 +02:00
Ran Benita
74f4aad708 Merge pull request #9449 from bluetech/backport-9447
[7.0.x] Backport "code: accept any `os.PathLike[str]` in `Traceback.cut`"
2021-12-27 15:55:37 +02:00
Ran Benita
5171327e3b Merge pull request #9438 from bluetech/pytest-legacypath-imports
pytest: bring back direct imports of TempdirFactory, Testdir
(cherry picked from commit 69da199f6e)
2021-12-27 15:11:45 +02:00
Ran Benita
9274fa5610 Merge pull request #9447 from bluetech/code-cut-pathlike
code: accept any `os.PathLike[str]` in `Traceback.cut`
(cherry picked from commit fcef7e49fd)
2021-12-27 15:10:13 +02:00
Bruno Oliveira
161841d38e Fix typos (#9424) (#9448)
Co-authored-by: Kian Meng, Ang <kianmeng.ang@gmail.com>
2021-12-27 10:02:26 -03:00
Kian Meng, Ang
e62daed8c4 Fix typos (#9424) 2021-12-27 09:26:25 -03:00
Ran Benita
764f90351a Merge pull request #9446 from bluetech/backport-9443
[7.0.x] Backport "doc/reference: add 4 missing hooks to reference"
2021-12-27 12:11:44 +02:00
Ran Benita
50bf3625c9 Merge pull request #9445 from bluetech/backport-9441
[7.0.x] Backport "python: skip nose setup/teardown fixtures if non-callable"
2021-12-27 11:41:02 +02:00
Ran Benita
0002597ddd Merge pull request #9443 from bluetech/undocumented-hooks
doc/reference: add 4 missing hooks to reference

(cherry picked from commit 7a42db2bf0)
2021-12-27 11:14:58 +02:00
Ran Benita
41e424b172 Merge pull request #9441 from bluetech/nose-setup-callable
python: skip nose setup/teardown fixtures if non-callable
(cherry picked from commit 7fc2cf51c2)
2021-12-27 11:13:12 +02:00
Ran Benita
839ca90c0e Merge pull request #9439 from bluetech/backport-9416
[7.0.x] Backport "doc: fix a reference in "Writing hook functions""
2021-12-25 13:00:34 +02:00
Ran Benita
8f1a8800c8 Merge pull request #9416 from bluetech/doc-stash-fix
doc: fix a reference in "Writing hook functions"
(cherry picked from commit 443aa0219c)
2021-12-25 10:50:36 +02:00
Bruno Oliveira
045713ac2e Merge pull request #9418 from nicoddemus/backport-9417
[7.0.x] Fix test_errors_in_xfail_skip_expressions for Python 3.10.1
2021-12-16 10:57:49 -03:00
Bruno Oliveira
f094355401 Merge pull request #9417 from nicoddemus/fix-py3.10.1-9413 2021-12-16 10:38:43 -03:00
Bruno Oliveira
378baab126 Merge pull request #9409 from bluetech/backport-9401 2021-12-12 13:30:54 -03:00
Ran Benita
74b9f46e40 Merge pull request #9401 from bluetech/doc-hooks-ref
doc: add a `hook` crossref type
(cherry picked from commit 8040cfd965)
2021-12-12 18:05:19 +02:00
Bruno Oliveira
bf913eb4e7 Merge pull request #9398 from The-Compiler/backport-9390
[7.0.x] fix python version in changelog message (#9390)
2021-12-08 07:50:19 -03:00
Bruno Oliveira
813e1e5b54 Merge pull request #9399 from The-Compiler/backport-9394
[7.0.x] Hide internal stack when using pytest.approx() in bool context (#9394)
2021-12-08 07:50:11 -03:00
Bruno Oliveira
3587d6b526 Merge pull request #9397 from The-Compiler/backport-9389
[7.0.x] fix typo
2021-12-08 07:50:00 -03:00
Bruno Oliveira
76e108d06c Hide internal stack when using pytest.approx() in bool context (#9394)
This makes the error traceback point directly to the offending usage, rather
than to the internal `Approx.__bool__` method.

(cherry picked from commit 3ba9c01f9b)
2021-12-08 10:54:47 +01:00
Anthony Sottile
5f70fcba2e fix python version in changelog message (#9390)
(cherry picked from commit 7ae23ff8ae)
2021-12-08 10:54:19 +01:00
Éric
39028fac00 fix typo
(cherry picked from commit b691d31897)
2021-12-08 10:53:30 +01:00
Florian Bruhin
ac0870ebad scripts: Use release branch for changelog URL (#9380) (#9383)
* scripts: Use release branch for changelog URL

With a prerelease, /stable won't show the correct changelog.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 21a186bbda)
2021-12-07 19:19:42 +01:00
Florian Bruhin
871533322b Fix changelog URL in 7.0.0rc1 announcement (#9379) (#9382)
The changelog does not exist at /stable because an rc isn't stable...

(cherry picked from commit 5cb50fa13c)
2021-12-07 11:44:19 +01:00
Bruno Oliveira
df2c59c07e Merge pull request #9381 from nicoddemus/backport-9359 2021-12-07 07:20:38 -03:00
Yuval Shimon
9bfa02ea07 Fixed error message prints function decorators when using assert in Python 3.9 and above. (#9359) 2021-12-07 07:08:48 -03:00
github-actions[bot]
85897eddc6 Prepare release version 7.0.0rc1 (#9375)
Co-authored-by: pytest bot <pytestbot@gmail.com>
2021-12-07 09:37:18 +01:00
Florian Bruhin
fbf64d2529 Don't thank pytest bot (#9372) 2021-12-06 22:55:18 +01:00
Florian Bruhin
3a479db126 Fix hook param name in nonpython example (#9373)
Follow up to #9363
2021-12-06 22:55:06 +01:00
Bruno Oliveira
70d3d0f390 Drop readline workaround introduced in #1281 (#8848)
Fix #8733
Closes #8847
2021-12-06 19:50:11 +01:00
Florian Bruhin
b3ed595f52 Revert "Fix Dead link in README for 'assert statements' " (#9369)
This reverts commit 15989ddc8f.

Reverts #8945, thus reintroducing #8926 temporarily, but we should be close to
the 7.0.0 release now, where this is the correct URL to use.

Closes #8831 as follow-up to #8858.
2021-12-06 17:56:39 +00:00
Ran Benita
5c55e91d77 Merge pull request #9368 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-django-4.5.1
build(deps): Bump pytest-django from 4.4.0 to 4.5.1 in /testing/plugins_integration
2021-12-06 15:39:37 +02:00
Florian Bruhin
663be09723 Improve reference and path/fspath docs (#9341)
* Improve reference and path/fspath docs

Closes #9283

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fixups

* Add explanation

* Update wording after #9363

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-12-06 11:25:05 +01:00
dependabot[bot]
17e2ecb253 build(deps): Bump pytest-django in /testing/plugins_integration
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.4.0 to 4.5.1.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/master/docs/changelog.rst)
- [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.4.0...v4.5.1)

---
updated-dependencies:
- dependency-name: pytest-django
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-06 03:02:03 +00:00
Bruno Oliveira
5852d66a6a Merge pull request #9367 from pytest-dev/update-plugin-list/patch-a335ade1f
[automated] Update plugin list
2021-12-05 11:13:37 -03:00
pytest bot
72b7334f1d [automated] Update plugin list 2021-12-05 00:12:43 +00:00
Bruno Oliveira
a335ade1f5 Rename pathlib hook parameters (#9363)
* Rename pytest_ignore_collect fspath parameter to collection_path

* Rename pytest_collect_file fspath parameter to file_path

* Rename pytest_pycollect_makemodule fspath parameter to module_path

* Rename pytest_report_header startpath parameter to start_path

* Rename pytest_report_collectionfinish startpath parameter to start_path

* Update docs with the renamed parameters

* Use pytest-flakes fork temporarily to prove it works

* Use pytest-flakes 4.0.5
2021-12-03 13:14:09 +01:00
Bruno Oliveira
96366dca42 Merge pull request #9356 from nicoddemus/copyright 2021-12-02 07:37:16 -03:00
Bruno Oliveira
482b858675 Merge pull request #9357 from GergelyKalmar/remove-unnecessary-newline 2021-12-01 19:08:46 -03:00
GergelyKalmar
82d450f98e Update authors 2021-11-30 19:04:00 +01:00
GergelyKalmar
1bcc2f87a2 Do not display empty worker info 2021-11-30 18:59:46 +01:00
Bruno Oliveira
ed24f29e60 Change copyright notice so yearly updates are not needed
Just learned that we don't need to do this every year: https://hynek.me/til/copyright-years

Followed Go's example of only stating the starting year: https://github.com/golang/go/blob/master/LICENSE

Btw any ideas why the dates vary? Some start in 2004, others 2013, 2015... shouldn't be the same year for all locations?
2021-11-30 09:28:23 -03:00
Zac Hatfield-Dodds
e2ee3144ed Merge pull request #9352 from truth-quark/spelling_fix_9351 2021-11-30 22:47:35 +11:00
Ben Davies
86bcaad828 Fix output of example test method. 2021-11-30 14:55:05 +11:00
Bruno Oliveira
fa240b0bb4 Merge pull request #9345 from aminalaee/patch-1 2021-11-29 11:43:53 -03:00
Bruno Oliveira
7627a7b413 Merge pull request #9348 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.4.0
build(deps): Bump anyio[curio,trio] from 3.3.4 to 3.4.0 in /testing/plugins_integration
2021-11-29 11:32:07 -03:00
dependabot[bot]
a0a37adfb2 build(deps): Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.3.4 to 3.4.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.3.4...3.4.0)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-29 03:02:13 +00:00
Ran Benita
64f22dcb80 Merge pull request #9346 from pytest-dev/update-plugin-list/patch-e01231c21
[automated] Update plugin list
2021-11-28 15:25:05 +02:00
pytest bot
7de752a50b [automated] Update plugin list 2021-11-28 00:12:22 +00:00
Amin Alaee
f0d5d523aa Update .readthedocs.yml 2021-11-27 13:15:16 +01:00
Bruno Oliveira
e01231c215 Merge pull request #9332 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-11-26 11:02:59 -03:00
Florian Bruhin
8436d695e5 Fix doc issues in deprecation change (#9336)
Follow-up to #9309.

The issue in the changelog broke the docs build with:

doc/en/_changelog_towncrier_draft.rst:47: WARNING: Inline literal start-string
without end-string.

The second change isn't as critical, but caused the text to be rendered as
monospace including the tilde (i.e. `~pytest.PytestDeprecationwarning`).
2021-11-25 09:43:23 +01:00
pre-commit-ci[bot]
372a6fdfd7 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.10b0 → 21.11b1](https://github.com/psf/black/compare/21.10b0...21.11b1)
- [github.com/asottile/blacken-docs: v1.11.0 → v1.12.0](https://github.com/asottile/blacken-docs/compare/v1.11.0...v1.12.0)
- [github.com/asottile/pyupgrade: v2.29.0 → v2.29.1](https://github.com/asottile/pyupgrade/compare/v2.29.0...v2.29.1)
- [github.com/asottile/setup-cfg-fmt: v1.19.0 → v1.20.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.19.0...v1.20.0)
2021-11-22 20:52:15 +00:00
Ran Benita
df9e94fbca Change deprecation warnings into errors for 7.0 release, using a new mechanism (#9309) 2021-11-21 17:13:44 +02:00
github-actions[bot]
4fd897a631 [automated] Update plugin list (#9326)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-11-21 17:12:22 +02:00
Bruno Oliveira
cd49075ad7 Merge pull request #9319 from nicoddemus/skip-test-prefix-integration-3.9 2021-11-19 12:23:34 -03:00
Bruno Oliveira
bd897513f2 Skip TestPyCacheDir.test_sys_pycache_prefix_integration on Windows + Python 3.9
Related to #9298
2021-11-19 11:22:08 -03:00
Ran Benita
a172a4141b Change PytestRemovedIn7Warning to error by default
Per our backward compatibility policy.

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-11-14 23:57:10 +02:00
Ran Benita
128f29ee35 Categorize deprecation warnings to PytestRemovedInXWarning
Closes #7480.

This allows us to more easily follow our deprecation policy of turning
warnings into errors for the X.0 releases before complete removal in
X.1.

It also makes the deprecation timeline clear to both the users and
pytest developers -- it can be hard to keep track.

Note that the designation is not meant to be a binding contract - if the
time comes for removal of a specific deprecation but we decide it's too
soon, can just bump it to the next major.

Inspired by Django:
https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/submitting-patches/#deprecating-a-feature
2021-11-14 23:57:10 +02:00
Bruno Oliveira
3dc17f1c3b Merge pull request #9293 from hoefling/doc/extlinks-gh-user 2021-11-13 10:57:37 -03:00
Ran Benita
062d91ab47 python: remove the Instance collector node 2021-11-13 14:03:44 +02:00
Florian Bruhin
17b38259fd Pin towncrier to 19.9.0 (#9282)
See https://github.com/twisted/towncrier/issues/346
Closes #8817, supersedes #9045 and #9046.
2021-11-11 16:48:54 +01:00
Bruno Oliveira
c5ab30d907 Merge pull request #9294 from spagh-eddie/patch-1 2021-11-11 07:33:21 -03:00
Eddie
a76df875c7 Remove space inside of dotted attribute 2021-11-10 12:54:21 -08:00
oleg.hoefling
2f1096cd55 replace hardcoded links to github user profiles with extlinks
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-11-10 20:47:27 +01:00
Florian Bruhin
5d87a27434 Elide pytest-internal paths for --fixtures (#9281)
* Elide pytest-internal paths for --fixtures

Fixes #8822

* Make flake8 happy
2021-11-10 15:16:41 +01:00
Florian Bruhin
f9afcd2d8a More pytest 7 changelog fixes (#9285)
* Remove changelog entry for #8251

Reverted in #8903

* Move #9202 changelog to to trivial

This won't concern users of pytest

* Streamline deprecation changelogs/docs

* Remove #8994 changelog

This is an impovement for a warning introduced in this release, so including it in a changelog against the last release seems confusing.

* Remove #9241 changelog

This is an impovement for a doc update introduced in this release, so including it in a changelog against the last release seems confusing. The issue number also seems about something different.

* Remove #8897 changelog

Empty file...

* Various minor changelog fixes
2021-11-10 15:16:24 +01:00
Ran Benita
d6e6b9696d Merge pull request #9286 from bluetech/legacypath-subplugins
legacypath: support late-loading of pytester plugin
2021-11-09 15:05:15 +02:00
Ran Benita
63899c76a4 legacypath: support late-loading of pytester plugin
Fixes #9280.

Previous approach didn't support pytester being loaded using
`pytest_plugins = "pytester"` in a conftest.
2021-11-08 21:56:40 +02:00
Ran Benita
f87df9c52e nodes: keep plugins which subclass Item, File working for a bit more (#9279)
* nodes: keep plugins which subclass Item, File working for a bit more

Fix #8435.

* Update src/_pytest/nodes.py

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Co-authored-by: Florian Bruhin <me@the-compiler.org>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-11-08 14:51:04 +00:00
Simon K
eb6c4493b2 Deprecation of msg= for both pytest.skip() and pytest.fail(). (#8950)
* porting pytest.skip() to use reason=, adding tests

* avoid adding **kwargs, it breaks other functionality, use optional msg= instead

* deprecation of `pytest.fail(msg=...)`

* fix bug with not capturing the returned reason value

* pass reason= in acceptance async tests instead of msg=

* finalising deprecations of `msg` in `pytest.skip()` and `pytest.fail()`

* Update doc/en/deprecations.rst

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

* Update doc/en/deprecations.rst

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

* fix failing test after upstream merge

* adding deprecation to `pytest.exit(msg=...)`

* add docs for pytest.exit deprecations

* finalising deprecation of msg for pytest.skip, pytest.exit and pytest.fail

* hold a reference to the Scope instance to please mypy

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-11-08 15:31:14 +01:00
Bruno Oliveira
b7603fa730 Merge pull request #9278 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2.9 2021-11-08 10:13:19 -03:00
Bruno Oliveira
b378f9a6e0 Merge pull request #9276 from hoefling/doc/extlinks-bpo 2021-11-08 09:41:26 -03:00
Bruno Oliveira
13d23a2dd5 Merge pull request #9275 from hoefling/doc/extlinks-gh-pull 2021-11-08 09:39:50 -03:00
Thomas Hisch
59373fe402 Merge pull request #9271 from thisch/unpack
Inline PercentStyleMultiline._update_message
2021-11-08 12:54:44 +01:00
dependabot[bot]
ff9e51c171 build(deps): Bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.2.8 to 3.2.9.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2.8...3.2.9)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-08 03:01:45 +00:00
Ran Benita
86446edc86 Merge pull request #9273 from bluetech/nose-fixtures2
nose: fix class- and module-level fixture behavior
2021-11-07 23:14:39 +02:00
github-actions[bot]
2792f9184e [automated] Update plugin list (#9274)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-11-07 23:12:57 +02:00
oleg.hoefling
16e15b99ae sphinx 3 compat
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-11-07 15:24:57 +01:00
oleg.hoefling
36265ccbf6 replace hardcoded links to bugs.python.org with extlinks
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-11-07 15:24:57 +01:00
oleg.hoefling
bba0ce4877 replace hardcoded links to github pull requests with extlinks
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-11-07 15:18:36 +01:00
Simon K
7037a58711 use list comp for getreports in terminal py (#9243) 2021-11-06 16:32:37 +00:00
Ran Benita
89f0b5b5a2 nose: fix class- and module-level fixture behavior
Fixes #9272.

Fixing the issue directly in the plugin is somewhat hard, so do it in
core. Since the plugin is going to be deprecated, I figure it's OK to
cheat a bit.
2021-11-06 14:45:24 +02:00
Oleg Höfling
49f934618c Replace hardcoded links to Github issues with extlinks (#9234) 2021-11-06 11:16:11 +02:00
Thomas Hisch
d8b647970f Inline PercentStyleMultiline._update_message
and take advantage of dict unpacking operator.
2021-11-05 23:08:30 +01:00
Ran Benita
842814c969 Merge pull request #9262 from bluetech/export-reports
Export CollectReport and TestReport
2021-11-03 15:17:22 +02:00
Ran Benita
b0aa870b11 Export CollectReport and TestReport
Refs #7469.
2021-11-02 20:58:51 +02:00
Ran Benita
a53abe93d8 Merge pull request #9208 from bluetech/legacypath-plugin
Add legacypath plugin, move py.path stuff there
2021-11-02 20:35:12 +02:00
Bruno Oliveira
e1b3c2da4b Merge pull request #9256 from pytest-dev/pre-commit-ci-update-config 2021-11-01 19:15:31 -03:00
pre-commit-ci[bot]
2fa37f677b [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.9b0 → 21.10b0](https://github.com/psf/black/compare/21.9b0...21.10b0)
- [github.com/asottile/setup-cfg-fmt: v1.18.0 → v1.19.0](https://github.com/asottile/setup-cfg-fmt/compare/v1.18.0...v1.19.0)
2021-11-01 20:26:52 +00:00
Harshna
9d17cebe64 Use correct input arg type for _bestrelpath (#9238)
Closes #8990
2021-11-01 17:43:05 +02:00
Cristian Vera
f288afde1d Use codecov github action instead of deprecated bash uploader (#9252)
Fixes #9202.
2021-11-01 17:41:56 +02:00
denivyruck
0191563fd6 DoctTest line numbers not found due to method wrapping (#8861)
Closes #8796
2021-11-01 09:01:25 +02:00
Ran Benita
1de5c07b95 Merge pull request #9255 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-bdd-5.0.0
build(deps): Bump pytest-bdd from 4.1.0 to 5.0.0 in /testing/plugins_integration
2021-11-01 08:58:37 +02:00
Alexander King
31c207a0b5 Support forwardslash characters in identifiers (#9249)
Closes #8377.
2021-11-01 08:54:18 +02:00
Ran Benita
11bb9205d7 [automated] Update plugin list (#9253)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-11-01 08:42:35 +02:00
dependabot[bot]
8932970a68 build(deps): Bump pytest-bdd in /testing/plugins_integration
Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 4.1.0 to 5.0.0.
- [Release notes](https://github.com/pytest-dev/pytest-bdd/releases)
- [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-bdd/compare/4.1.0...5.0.0)

---
updated-dependencies:
- dependency-name: pytest-bdd
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-01 03:01:28 +00:00
pytest bot
81e2d46302 [automated] Update plugin list 2021-10-31 00:11:03 +00:00
andrewdotn
1824349f74 Use Ubuntu 20.04, lualatex for readthedocs builds (#9242) 2021-10-30 11:21:14 -03:00
Ran Benita
69b0a7b306 ci: remove linting job - covered be pre-commit.ci (#9247) 2021-10-29 19:23:47 -03:00
Ran Benita
e6eac28f0e legacypath: only add testdir and tmpdir fixtures if corresponding plugins are registered
This preserves the existing behavior and gives a proper error message
in case e.g. `testdir` is requested without the `pytester` plugin being
loaded.
2021-10-29 13:11:12 +03:00
Ran Benita
c3dff755af Move Node.fspath to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
ce7cff9f8e Move pathlist support to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
d9ca55c648 Move Session.startdir to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
84722a7904 Move Config.{invocation_dir,rootdir,inifile} to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
d979f82fb0 Move TerminalReporter.stardir to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
7c0011374c Move FixtureRequest.fspath to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
a1a605a63e Move Cache.makedir to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
5e883f5195 Move tmpdir to legacypath plugin 2021-10-28 21:51:51 +03:00
Ran Benita
1df28a4450 Move testdir to legacypath plugin 2021-10-28 21:51:51 +03:00
andrewdotn
bcad6e8e9a Make plugin list in PDF docs readable (#9241)
The current PDF docs attempt to format the list of all plugins as a
table, without any word-wrapping of the plugin description. That results
in almost all the information getting cut off. This PR formats the same
information into more of a paragraph format for the PDF, with nothing
cut off.

Fixes #451
2021-10-28 11:31:52 +03:00
Ran Benita
c2ece58aa0 Add legacypath plugin 2021-10-27 09:31:44 +03:00
Ran Benita
b7fc0003fd Merge pull request #9232 from bluetech/deprecate-node-fspath-args
Deprecate Node constuctor fspath argument, and other small changes/fixes
2021-10-27 09:26:57 +03:00
Ran Benita
7706fd6840 nodes: deprecate fspath arguments to node constructors
This is unfortunately a dependency on `py.path` which cannot be moved to
an external plugins or eased in any way, so has to be deprecated in
order for pytest to be able to eventually remove the dependency on `py`.
2021-10-27 08:36:10 +03:00
Ran Benita
99363ad7ff recwarn: fix was -> were in DID NOT WARN message 2021-10-27 08:36:10 +03:00
Ran Benita
3c5c5feb04 Merge pull request #9230 from bluetech/pytester-transitive-public
Export pytester transitive types
2021-10-27 08:05:08 +03:00
Alexander King
14e032088c Change the command for package building in release CI workflow (#9229) 2021-10-25 21:32:12 +03:00
Ran Benita
89f8ff5a6d Merge pull request #9233 from pytest-dev/update-plugin-list/patch-f695e18dd
[automated] Update plugin list
2021-10-25 21:05:55 +03:00
pytest bot
2f0e1cd230 [automated] Update plugin list 2021-10-24 00:11:06 +00:00
Ran Benita
60ca83746b docs: change references to 6.3 -> 7.0
The plans have changed, next version will be 7.0 not 6.3.
2021-10-23 22:49:55 +03:00
Ran Benita
755ce9bc80 hookspec: improve legacy path deprecation docs 2021-10-23 22:49:54 +03:00
Ran Benita
afc7442e22 nodes: inline _imply_path
Only one usage left, and we certainly don't expect more!

Rename `_imply_path_only` to `_imply_path`, that's a less confusing name
now.
2021-10-23 22:10:08 +03:00
Ran Benita
6be3f31dba nodes: remove redundent _imply_path call
The Node ctor will take care of the check.
2021-10-23 21:34:16 +03:00
Ran Benita
853b0a4c29 nodes: fix bug in Node() fspath compat
Since path <-> fspath are converted to each other, we need to check both
before looking at the parent, in case fspath is set but path is not.
2021-10-23 21:33:12 +03:00
Ran Benita
11e36c8493 Make transitive Pytester types public
Export `HookRecorder`, `RecordedHookCall` (originally `ParsedCall`),
`RunResult`, `LineMatcher`.

These types are reachable through `Pytester` and so should be public
themselves for typing and other purposes.

The name `ParsedCall` I think is too generic under the `pytest`
namespace, so rename it to `RecordedHookCall`.

The `HookRecorder`'s constructor is made private -- it should only be
constructed by `Pytester`.

`LineMatcher` and `RunResult` are exported as is - no private and no
rename, since they're being used.

All of the classes are made final as they are not designed for
subclassing.
2021-10-23 10:59:18 +03:00
Ran Benita
259cff59f5 Remove {pytester,testdir}.Session aliases
This causes `Session` documentation to be rendered again in full under
`pytester` and `testdir` in the API Reference. I tried but couldn't get
sphinx to hide it.

Since it's a pretty odd thing to have (should just use
`pytest.Session`), and I couldn't find any plugin which uses this, let's
just remove it.
2021-10-23 10:25:29 +03:00
Ran Benita
f695e18ddb Merge pull request #9227 from bluetech/config-_cleanup
Use public API for adding config cleanup
2021-10-22 22:50:55 +03:00
Alexander King
005690bd67 Add template for prereleases (#9165)
Fix #8820
2021-10-22 10:00:00 -03:00
Oleg Höfling
1e9e16d829 Replace hardcoded links to PyPI with extlinks (#9224) 2021-10-22 09:47:57 -03:00
Ran Benita
5fd182f3de Use public API for adding config cleanup
No need to spuriously access the private internals of Config.
2021-10-22 11:03:27 +03:00
Ran Benita
2af41c5703 Merge pull request #9226 from bluetech/doc-setup-py
doc: modernize discussion of setup.py in "Good Integration Practices"
2021-10-22 11:01:10 +03:00
Ran Benita
7314b32b63 doc: modernize discussion of setup.py in "Good Integration Practices" 2021-10-22 10:24:39 +03:00
Bruno Oliveira
61e506a63f Merge pull request #9223 from nicoddemus/better-filter-warnings-messages 2021-10-21 22:45:00 -03:00
Bruno Oliveira
f5fd2fb176 Improve UX during errors while parsing warning filters
Fix #7864
Fix #9218

Closes #8343
Closes #7877
2021-10-21 13:15:41 -03:00
Bruno Oliveira
4a3834101e Merge pull request #9209 from pytest-dev/update-plugin-list/patch-0696d3eda
[automated] Update plugin list
2021-10-19 06:53:25 -03:00
Bruno Oliveira
20a69e11aa Merge pull request #9214 from nicoddemus/confcutdir-9210 2021-10-19 06:52:52 -03:00
Bruno Oliveira
c000955dde Remove incorrect docs about confcutdir being a config option
Fix #9210
2021-10-18 19:20:27 -03:00
dependabot[bot]
080fc81971 build(deps): Bump pytest-asyncio from 0.15.1 to 0.16.0 in /testing/plugins_integration (#9212)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-18 19:16:55 -03:00
dependabot[bot]
73fb797bbd build(deps): Bump anyio[curio,trio] from 3.3.3 to 3.3.4 in /testing/plugins_integration (#9211)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-18 19:16:16 -03:00
Cristian Vera
cbcfeca78c Cache.set preserves key order when saving dicts (#9206)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-10-18 19:15:34 -03:00
pytest bot
3cc0c451e7 [automated] Update plugin list 2021-10-17 00:11:56 +00:00
Ran Benita
0696d3eda1 Merge pull request #9207 from bluetech/rm-py-pre
Remove some `py` uses
2021-10-16 22:26:45 +03:00
Ran Benita
a3b69d9d83 Remove py version printing, traceback filtering, freezing
Not so important anymore, and makes it easier to remove the py
dependency.
2021-10-16 12:01:31 +03:00
Ran Benita
bc2f20722c testing: remove a few redundant py references 2021-10-16 11:58:35 +03:00
Bruno Oliveira
5fc7b21391 Use xelatex engine for better Unicode support (#9197) 2021-10-12 10:12:15 -03:00
pre-commit-ci[bot]
d7752b4d1e [pre-commit.ci] pre-commit autoupdate (#9191)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-10-11 20:09:25 +00:00
dependabot[bot]
110d70ec88 build(deps): bump django from 3.2.7 to 3.2.8 in /testing/plugins_integration (#9190)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-10-11 12:44:28 +00:00
James Myatt
ccd3874d7a Recommend not integrating with setuptools (#9185) 2021-10-11 15:28:27 +03:00
dependabot[bot]
d0cc45d723 build(deps): bump anyio[curio,trio] from 3.3.2 to 3.3.3 in /testing/plugins_integration (#9189)
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.3.2 to 3.3.3.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.3.2...3.3.3)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-10-11 09:25:51 -03:00
Ran Benita
da3b3012b1 Merge pull request #9184 from bluetech/reportinfo-pathlike
[7.0] Change `Node.reportinfo()` return value from `py.path` to `str|os.PathLike[str]`
2021-10-11 14:33:03 +03:00
github-actions[bot]
4b417ac38e [automated] Update plugin list (#9186)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-10-10 12:00:43 -03:00
Ran Benita
14a879b6d1 Merge pull request #9183 from bluetech/rm-redundent-osfspath
Remove redundant explicit os.fspath calls
2021-10-09 19:14:55 +03:00
Bernát Gábor
3407fe63e2 Support the importlib.resources files API in rewritten files (#9173) 2021-10-09 10:54:44 -03:00
Ran Benita
7eee5c1634 Change Node.reportinfo() return value from py.path to str|os.PathLike[str]
`reportinfo()` is the last remaining py.path-only code path in pytest,
i.e. the last piece holding back py.path deprecation. The problem with
it is that plugins/users use it from both sides -- implementing it
(returning the value) and using it (using the return value). Dealing
with implementers is easy enough -- allow to return `os.PathLike[str]`.
But for callers who expect strictly `py.path` this will break and
there's not really a good way to provide backward compat for this.

From analyzing a corpus of 680 pytest plugins, the vast majority of
`reportinfo` appearances are implementations, and the few callers don't
actually access the path part of the return tuple.

As for test suites that might access `reportinfo` (e.g. using
`request.node.reportinfo()` or other ways), that is much harder to
survey, but from the ones I searched, I only found case
(`pytest_teamcity`, but even then it uses `str(fspath)` so is unlikely
to be affected in practice). They are better served with using
`node.location` or `node.path` directly.

Therefore, just break it and change the return type to
`str|os.PathLike[str]`.

Refs #7259.
2021-10-09 15:02:03 +03:00
Ran Benita
5059b31a73 Remove redundant explicit os.fspath calls
Python calls it on its own.
2021-10-09 13:44:44 +03:00
Jeff Rasley
e84ba80301 Update pastebin URL from bpaste to bpa.st (#9131) 2021-10-06 08:12:48 -03:00
Ran Benita
e077f1cbd5 Merge pull request #9168 from bluetech/node-keywords-dups
mark/structures: fix NodeKeywords.{__iter__,__len__} given duplicates
2021-10-06 12:01:05 +03:00
Ran Benita
cf4495ffe1 mark/structures: fix NodeKeywords.{__iter__,__len__} given duplicates
Regressed in c4b9b14a4 -- the `set` stuff had a reason which I had
missed.
2021-10-06 11:24:28 +03:00
Ran Benita
c9267af3bf Merge pull request #9166 from bluetech/optimize-imply-path
nodes: micro-optimize _imply_path
2021-10-06 10:50:10 +03:00
Ran Benita
076ac901bb nodes: micro-optimize _imply_path 2021-10-06 10:29:52 +03:00
Bruno Oliveira
14b79a66a3 Merge pull request #9025 from davidszotten/more_verbose_for_ci 2021-10-05 16:52:47 -03:00
Bruno Oliveira
9546fb713a Merge pull request #9066 from eamanu/fix-8994 2021-10-05 16:52:08 -03:00
Bruno Oliveira
fb52fc5163 Merge pull request #9070 from andrewdotn/main 2021-10-05 16:51:58 -03:00
Bruno Oliveira
459e10b802 Merge pull request #9133 from okken/9113_deselected_assert_outcomes 2021-10-05 16:50:42 -03:00
Ran Benita
d0bdc26490 Merge pull request #9164 from bluetech/optimize-keywords
mark/structures: micro-optimize item.keywords/NodeKeywords
2021-10-05 20:03:42 +03:00
Ran Benita
c4b9b14a44 mark/structures: micro-optimize item.keywords/NodeKeywords 2021-10-05 16:50:22 +03:00
Ran Benita
54811b24e2 Merge pull request #9163 from bluetech/rewrite-end-lineno
rewrite: fixup end_lineno, end_col_offset of rewritten asserts
2021-10-05 16:46:29 +03:00
Ran Benita
6a5211f369 rewrite: fixup end_lineno, end_col_offset of rewritten asserts
These are new additions in Python 3.8:
https://docs.python.org/3/whatsnew/3.8.html#ast
I'm not sure what's using them but we should set them anyway.
2021-10-05 10:51:09 +03:00
Brian Okken
c82bda259c Add a pythonpath setting to allow paths to be added to sys.path. (#9134) 2021-10-05 09:36:38 +03:00
Bruno Oliveira
05a97375fd Merge pull request #9162 from pytest-dev/pre-commit-ci-update-config 2021-10-04 18:55:29 -03:00
Zac Hatfield-Dodds
e763fde482 Merge pull request #9158 from hoefling/doc/internal-crossrefs
replace hardcoded urls to docs.pytest.org with internal crossrefs, add crossrefs to numpy docs, use sphinx pep role
2021-10-05 08:43:19 +11:00
pre-commit-ci[bot]
1a8b4343ff [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.28.0 → v2.29.0](https://github.com/asottile/pyupgrade/compare/v2.28.0...v2.29.0)
2021-10-04 19:49:14 +00:00
Ran Benita
483f239d01 Merge pull request #9161 from bluetech/attrs-auto
Use attr.s(auto_attribs=True) in more places
2021-10-04 21:59:52 +03:00
oleg.hoefling
3926526c95 revert changes in doc/en/announce
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-10-04 20:06:13 +02:00
Ronny Pfannschmidt
028eb6fab6 Merge pull request #9115 from RonnyPfannschmidt/fix-regendoc
fix #8818 - run regendoc without tox cachedir
2021-10-04 19:11:45 +02:00
Ran Benita
e5468681b0 Use attr.s(auto_attribs=True) in more places
It's nicer to read without the attr.ib noise.
2021-10-04 19:24:12 +03:00
Ran Benita
dced00e60f Merge pull request #9154 from bluetech/refactor-callspec2
python: refactor CallSpec2
2021-10-04 18:56:29 +03:00
Ran Benita
570b1facb7 python: refactor CallSpec2
This type is semi-private; not documented but many plugins access it
through `item.callspec`. However, plugins access the public fields and
almost none try to construct or monkeypatch it. So we should be allowed
to clean it up some.

- Convert to attrs, add slots and frozen

- Instead of doing `new = old.copy(); new.setmulti2()`, do `new =
  old.setmulti()`. This is cleaner and faster.

- Remove the `metafunc` attribute. This causes a reference cycle
  (multifunc._calls -> callspec -> multifunc) for no good reason --
  neither pytest itself or plugins access this attribute, so let's not
  keep the Metafunc objects alive past their due.

- Some comments.

I would have also like to make the dicts and lists themselves immutable,
however some plugins mess with those so that should be done separately,
if at all.
2021-10-04 17:33:52 +03:00
Bruno Oliveira
c4557c3192 Merge pull request #9150 from nicoddemus/issue-9141-fixture-docs 2021-10-04 09:48:19 -03:00
Ran Benita
8a58b0c892 Merge pull request #9155 from pytest-dev/update-plugin-list/patch-0fbfd1ca3
[automated] Update plugin list
2021-10-04 10:46:16 +03:00
Ran Benita
73634ffb49 Merge pull request #9160 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-cov-3.0.0
build(deps): bump pytest-cov from 2.12.1 to 3.0.0 in /testing/plugins_integration
2021-10-04 10:45:21 +03:00
Ronny Pfannschmidt
c21ef7ba22 fix #8818 - run regendoc without tox cachedir
#4270 introduced per tox env pytest cachedirs and
never protected regendoc against it
2021-10-04 08:56:26 +02:00
dependabot[bot]
c061412a8b build(deps): bump pytest-cov in /testing/plugins_integration
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.12.1 to 3.0.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.12.1...v3.0.0)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-04 03:01:33 +00:00
oleg.hoefling
d58ee2b677 replace hardcoded urls to docs.pytest.org with internal crossrefs, add external crossrefs where possible
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-10-04 00:23:41 +02:00
Ronny Pfannschmidt
35d8c1398c Merge pull request #8134 from RonnyPfannschmidt/setuptools_scm_5
fixes #8133: migrate to setuptools_scm 6.x
2021-10-03 20:46:00 +02:00
pytest bot
618ee0f268 [automated] Update plugin list 2021-10-03 00:11:19 +00:00
Ronny Pfannschmidt
0892c77bc6 fixes #8133: mitigate regendoc issues wrt PRETEND_VERSION
this issues is less likely to hit due to the recent regendoc release
which includes a wheel

* migrate to setuptools_scm 6.3.2
* use SETUPTOOLS_SCM_PRETEND_VERSION_FOR_PYTEST
2021-10-02 20:22:18 +02:00
Ran Benita
0fbfd1ca36 Merge pull request #9152 from bluetech/mark-optimize
mark/structures: slightly optimize some functions
2021-10-02 15:57:57 +03:00
Ran Benita
2cfce8d8c4 Merge pull request #9153 from bluetech/coverage-assert-never
coverage: add assert_never to exclude_lines
2021-10-02 15:56:24 +03:00
Ran Benita
1d0261e5cb coverage: add assert_never to exclude_lines
These are assertions that should never trigger.
2021-10-02 14:26:04 +03:00
Ran Benita
637e8efdd4 mark/structures: slightly optimize some functions
`normalize_mark_list` shows up in pandas collection profiles. It's
simple enough to improve.
2021-10-02 14:06:52 +03:00
Bruno Oliveira
ac3614b999 Add note about fixture teardown and SIGTERM and SIGQUIT signals
Close #9141
2021-10-01 16:12:03 -03:00
Ran Benita
f65dfc39f3 Merge pull request #9123 from pytest-dev/update-plugin-list/patch-112204cf8
[automated] Update plugin list
2021-10-01 16:31:59 +03:00
Ran Benita
8af558723e main: avoid Path(Path(...)) calls, they're slow (#9147) 2021-10-01 16:21:32 +03:00
Ran Benita
5fc3e35afb Merge pull request #9144 from bluetech/py36_order_by_definition
py36+ tests are definition ordered [v2]
2021-10-01 16:17:37 +03:00
Ran Benita
d8831c64eb Merge pull request #9148 from bluetech/lru-cache-method
Avoid `@lru_cache` on methods
2021-10-01 16:16:51 +03:00
Ran Benita
3a6eaa9c1c Merge pull request #9145 from bluetech/compat-pattern
compat: replace REGEX_TYPE with typing.Pattern
2021-10-01 16:16:28 +03:00
Ran Benita
c86ceb4d01 main: avoid Path(Path(...)) calls, they're slow 2021-10-01 15:30:03 +03:00
Ran Benita
16e5fbe371 config: optimize PytestPluginManager._getconftestmodules
Now that it's no longer using `@lru_cache`, use another check to avoid
re-computation. Although `@lru_cache` is faster than the full function
call + checks, this approach also has the advantage that the caching
works for more than 128 entries.
2021-10-01 15:25:28 +03:00
Ran Benita
614f5394b5 Avoid @lru_cache on methods
The problem with `@lru_cache` on methods is that it also captures `self`
and leaks it until the entry is evicted (if ever).
2021-10-01 14:41:14 +03:00
Ran Benita
1f938e3ef5 compat: replace REGEX_TYPE with typing.Pattern
Since Python 3.7, there is `re.Pattern` for this, but since we need to
support Python 3.6, can use `typing.Pattern` which works as well.
2021-10-01 14:00:15 +03:00
Ran Benita
631c8b4df2 Merge pull request #9143 from bluetech/docs-stash-typo
Fix syntax typo in writing_hook_functions.rst
2021-10-01 11:38:15 +03:00
Ran Benita
4b13b5993e Fix syntax typo in writing_hook_functions.rst 2021-10-01 10:26:56 +03:00
Brian Okken
6d6cfd839a Add a deselected parameter to assert_outcomes() 2021-09-29 07:22:53 -07:00
Bruno Oliveira
7720154ca0 Merge pull request #9129 from nicoddemus/fix-linting-main
Fix formatting
2021-09-27 23:46:18 -03:00
Bruno Oliveira
7f5e49e70b Fix formatting 2021-09-27 22:51:08 -03:00
Bruno Oliveira
dd6d4b2fe0 Merge pull request #9128 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-27 20:37:57 -03:00
pre-commit-ci[bot]
56fda99fa1 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-09-27 19:47:18 +00:00
pre-commit-ci[bot]
70858ac266 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.26.0 → v2.28.0](https://github.com/asottile/pyupgrade/compare/v2.26.0...v2.28.0)
2021-09-27 19:44:12 +00:00
Bruno Oliveira
e3efbd4b39 Merge pull request #9127 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-rerunfailures-10.2
build(deps): bump pytest-rerunfailures from 10.1 to 10.2 in /testing/plugins_integration
2021-09-27 08:13:15 -03:00
Bruno Oliveira
bbd5d55e98 Merge pull request #9126 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.3.2
build(deps): bump anyio[curio,trio] from 3.3.1 to 3.3.2 in /testing/plugins_integration
2021-09-27 08:12:57 -03:00
dependabot[bot]
222fdd4a58 build(deps): bump pytest-rerunfailures in /testing/plugins_integration
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 10.1 to 10.2.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases)
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/10.1...10.2)

---
updated-dependencies:
- dependency-name: pytest-rerunfailures
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 03:02:31 +00:00
dependabot[bot]
442abeafd0 build(deps): bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.3.1 to 3.3.2.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.3.1...3.3.2)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-27 03:02:27 +00:00
pytest bot
4a016db7b4 [automated] Update plugin list 2021-09-26 00:11:24 +00:00
Florian Bruhin
112204cf8d Fix non-sensical error message (#9077)
* Fix non-sensical error message

Introduced in 12de92cd2b / #7698

* Add a test

* Put the unit back into unittest

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-09-24 06:15:53 +02:00
Ran Benita
037d2903be Merge pull request #9112 from bluetech/plugin-list-escape
scripts/update-plugin-list: escape summary for special RST chars
2021-09-22 17:00:07 +03:00
pre-commit-ci[bot]
24b347507a [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-09-22 13:41:33 +00:00
Ran Benita
4ae4bec968 scripts/update-plugin-list: escape summary for special RST chars
A new plugin has this summary:

    Continiously runs pytest on changes in *.py files

The `*` is interpreted as a special character and fails the CI.

Add some rudimentary escaping to hopefully prevent this.
2021-09-22 16:39:15 +03:00
Bruno Oliveira
bec42f7b0b Merge pull request #9092 from nicoddemus/cleanup-projects-page 2021-09-22 10:28:45 -03:00
Ran Benita
3f404418bf Merge pull request #9088 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.3.1
build(deps): bump anyio[curio,trio] from 3.3.0 to 3.3.1 in /testing/plugins_integration
2021-09-22 15:56:28 +03:00
Ran Benita
cf5b7a0958 Merge pull request #9103 from pytest-dev/update-plugin-list/patch-60e995d90
[automated] Update plugin list
2021-09-22 15:55:49 +03:00
Bruno Oliveira
f50652a5d2 Merge pull request #9111 from ziebam/iss4320-better-docs-for-testdir-copy-example 2021-09-22 07:51:42 -03:00
ziebam
70a3c965ea Add myself to AUTHORS file 2021-09-22 00:23:13 +02:00
ziebam
6ea762c46c Add a changelog entry 2021-09-22 00:22:37 +02:00
ziebam
520aa61e19 Improve docs for pytester.copy_example 2021-09-22 00:16:52 +02:00
Bruno Oliveira
fe44409cf6 Merge pull request #9107 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-20 21:28:03 -03:00
pre-commit-ci[bot]
43c0687a77 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.8b0 → 21.9b0](https://github.com/psf/black/compare/21.8b0...21.9b0)
2021-09-20 20:00:19 +00:00
pytest bot
86fc02bfcb [automated] Update plugin list 2021-09-19 00:10:14 +00:00
Bruno Oliveira
c761c45cf9 Remove obsolete projects page from docs
The projects page unfortunately contains a lot of old projects, and some information there appears to be stale.

It was created at a time pytest was starting to be used, but seems pointless now as pytest is the most popular testing framework, so listing a few dozen projects which use it seems pointless.

Rather than updating it, I think we should remove it because this has the chance to become stale again soon, and not sure how valuable it is anyway.
2021-09-14 08:04:49 -03:00
Bruno Oliveira
60e995d902 Merge pull request #9091 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-09-13 18:48:26 -03:00
pre-commit-ci[bot]
3867b681cd [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.25.0 → v2.26.0](https://github.com/asottile/pyupgrade/compare/v2.25.0...v2.26.0)
2021-09-13 19:40:27 +00:00
dependabot[bot]
87bbbaa0dc build(deps): bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.3.0 to 3.3.1.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.3.0...3.3.1)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-13 03:01:43 +00:00
Simon K
0e7bb34081 adding contact and badge for pytest-dev discord server (#9078)
* adding badges/docs for pytest-dev discord and pytest libera web chat
2021-09-12 18:22:44 +01:00
Bruno Oliveira
4e916ce347 Merge pull request #9086 from pytest-dev/update-plugin-list/patch-581b021aa
[automated] Update plugin list
2021-09-11 22:46:19 -03:00
pytest bot
0407c62121 [automated] Update plugin list 2021-09-12 00:11:27 +00:00
Bruno Oliveira
581b021aa2 Merge pull request #9084 from The-Compiler/remove-workshoptage
Remove finished open training
2021-09-10 08:26:21 -03:00
Florian Bruhin
1c1dcf27c8 Remove finished open training 2021-09-09 22:29:34 +02:00
Zac Hatfield-Dodds
8900e3b937 Merge pull request #9041 from hoefling/doc/stdlib-crossrefs 2021-09-07 21:22:24 +10:00
Bruno Oliveira
4274af1c28 Merge pull request #9076 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2.7
build(deps): bump django from 3.2.5 to 3.2.7 in /testing/plugins_integration
2021-09-06 11:13:20 -03:00
Bruno Oliveira
9d0829f150 Merge pull request #9075 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-twisted-1.13.4
build(deps): bump pytest-twisted from 1.13.3 to 1.13.4 in /testing/plugins_integration
2021-09-06 11:13:00 -03:00
dependabot[bot]
ba14a81c7f build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.2.5 to 3.2.7.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2.5...3.2.7)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 03:01:53 +00:00
dependabot[bot]
af09415cd1 build(deps): bump pytest-twisted in /testing/plugins_integration
Bumps [pytest-twisted](https://github.com/pytest-dev/pytest-twisted) from 1.13.3 to 1.13.4.
- [Release notes](https://github.com/pytest-dev/pytest-twisted/releases)
- [Commits](https://github.com/pytest-dev/pytest-twisted/compare/v1.13.3...v1.13.4)

---
updated-dependencies:
- dependency-name: pytest-twisted
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-06 03:01:49 +00:00
Bruno Oliveira
01d046ecb3 Merge pull request #9073 from pytest-dev/update-plugin-list/patch-20863c3a0
[automated] Update plugin list
2021-09-05 12:32:19 -03:00
pytest bot
1f00461e57 [automated] Update plugin list 2021-09-05 00:09:51 +00:00
Andrew Neitsch
a9edfdf9db Run black on conf.py 2021-09-02 20:42:29 -06:00
Andrew Neitsch
b46d5f4657 Only use inkscapeconverter if inkscape installed 2021-09-02 20:40:17 -06:00
Andrew Neitsch
e929d15848 Include figures in PDF docs
The PDF documentation on readthedocs was missing the figures in the
fixtures reference chapter. This PR uses a Sphinx plugin that
automatically converts the checked-in SVG files to the PDF input files
that LaTeX requires.

The SVG-to-PDF conversion is done by inkscape, which gave the best
conversion among the tools I tried. However, it [does not yet
understand][href-bug] that you can write a plain `href` instead of
`xlink:href` in svg files, so I’ve had to edit the SVG files
accordingly.

[href-bug]: https://github.com/TeX-Live/luatex.git
2021-09-02 17:40:41 -06:00
Emmanuel Arias
dc9192c8eb add changelog file 2021-09-02 00:14:19 -03:00
Emmanuel Arias
59d314de3d Show fullname on direct Node construction warning
This commit add the fullname on the Node construction warning.
Also add a test for this case.
2021-09-01 16:13:26 -03:00
Bruno Oliveira
20863c3a0c Merge pull request #9065 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-30 16:49:04 -03:00
pre-commit-ci[bot]
7bcdcc0239 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.7b0 → 21.8b0](https://github.com/psf/black/compare/21.7b0...21.8b0)
- [github.com/asottile/blacken-docs: v1.10.0 → v1.11.0](https://github.com/asottile/blacken-docs/compare/v1.10.0...v1.11.0)
- [github.com/asottile/pyupgrade: v2.24.0 → v2.25.0](https://github.com/asottile/pyupgrade/compare/v2.24.0...v2.25.0)
2021-08-30 19:25:44 +00:00
Simon K
740abd9684 #9062 - Allow --stepwise-skip to implicitly enable --stepwise (#9064)
* #9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise`

* Update changelog/9062.improvement.rst

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-08-30 19:24:14 +01:00
Kale Kundert
af42e7154a Prevent approx from being used without a comparison (#9061)
Some of the top search-engine hits for pytest.approx use the function without actually comparing it to anything.

This PR will cause these tests to fail by implementing approx.__bool__() to raise an AssertionError that briefly explains how to correctly use approx.
2021-08-30 18:19:31 +00:00
Bruno Oliveira
771c4b9313 Merge pull request #9063 from nicoddemus/cherry-pick-release
Merge pull request #9057 from pytest-dev/release-6.2.5
2021-08-30 15:13:58 -03:00
Bruno Oliveira
ea5ff44ef3 Merge pull request #9057 from pytest-dev/release-6.2.5
(cherry picked from commit 16664a1b72)
2021-08-30 14:44:49 -03:00
Bruno Oliveira
014fa61e0d Merge pull request #9053 from nicoddemus/change-8494-to-trivial 2021-08-29 10:52:01 -03:00
Bruno Oliveira
d023e6344a Merge pull request #9055 from pytest-dev/update-plugin-list/patch-398783521
[automated] Update plugin list
2021-08-29 00:35:42 -03:00
pytest bot
544ecce677 [automated] Update plugin list 2021-08-29 00:09:53 +00:00
Bruno Oliveira
14709f33af As discussed in Discord, move 3.10 changelog to trivial
This was backported to `6.2.x`, but we agreed this should
actually a trivial change and go into `6.2.5`, instead of a new `6.3.0`.
2021-08-28 11:59:53 -03:00
Bruno Oliveira
3987835213 Merge pull request #9049 from nicoddemus/prerelease-option
Fix prepare-release-pr invocation with empty --prerelease argument
2021-08-27 14:47:58 -03:00
Bruno Oliveira
675f8da3a1 Fix prepare-release-pr invocation with empty --prerelease argument 2021-08-27 14:46:28 -03:00
Bruno Oliveira
3c0510894b Merge pull request #9048 from nicoddemus/prerelease-option
'prerelease' input is not required in prepare-release-pr workflow
2021-08-27 14:40:11 -03:00
Bruno Oliveira
9501e54852 'prerelease' input is not required in prepare-release-pr workflow
The default is the correct value when generating a normal release.
2021-08-27 14:26:30 -03:00
Bruno Oliveira
b6aba1d58d Merge pull request #9047 from nicoddemus/changelog-9040
Add changelog for #9040 (pluggy 1.0)
2021-08-27 14:23:49 -03:00
Bruno Oliveira
44ba2fa372 Add changelog for #9040 (pluggy 1.0) 2021-08-27 14:09:21 -03:00
oleg.hoefling
d1aea7d7a8 use intersphinx crossrefs to stdlib docs where possible instead of hardcoded URLs
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
2021-08-26 16:05:03 +02:00
Bruno Oliveira
41dc9bbc44 Merge pull request #9040 from nicoddemus/bump-pluggy 2021-08-26 10:14:27 -03:00
Bruno Oliveira
109bc2649d Adapt docs references to use pluggy 1.0
Also use the intersphinx reference instead of the class directly.
2021-08-26 09:52:05 -03:00
Bruno Oliveira
fbba504cd5 Allow pluggy >=1.0
Now that pluggy 1.0 has been released, we can allow pluggy 1.0 with new pytest versions.
2021-08-26 09:26:51 -03:00
Bruno Oliveira
1a2306cec6 Merge pull request #9033 from kulikjak/fix-cwd-removal-Solaris
Fix cwd removal on Solaris
2021-08-24 10:39:37 -03:00
Bruno Oliveira
78d21dc836 Merge pull request #9034 from williamjamir/williamjamir-patch-1
Fix typo in fixture.rst
2021-08-24 10:38:50 -03:00
William Jamir Silva
696bf96c83 Fix typo in fixture.rst 2021-08-24 09:32:40 -03:00
Bruno Oliveira
59189ebeb5 Merge pull request #9029 from pytest-dev/update-plugin-list/patch-83b609d7f
[automated] Update plugin list
2021-08-24 08:04:29 -03:00
Jakub Kulík
e146aaa2e2 Fix cwd removal on Solaris 2021-08-24 12:11:06 +02:00
Anthony Sottile
ebe5e451d1 Merge pull request #9031 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-23 15:27:47 -04:00
pre-commit-ci[bot]
e8aa395346 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.3 → v2.24.0](https://github.com/asottile/pyupgrade/compare/v2.23.3...v2.24.0)
2021-08-23 18:58:43 +00:00
pytest bot
1b130d4404 [automated] Update plugin list 2021-08-22 00:09:13 +00:00
Bruno Oliveira
83b609d7f7 Merge pull request #9028 from Exifers/patch-1
Fix typo in documentation
2021-08-21 11:49:11 -03:00
Emmanuel Meric de Bellefon
ec2099e057 Update index.rst 2021-08-21 11:11:37 +02:00
David Szotten
d5c020d8c5 always show full diff in ci
follow-up to #1314, for similar reasons

closes #9023
2021-08-19 20:17:43 +01:00
Florian Bruhin
c9870480e0 doc: Update trainings (#9022) 2021-08-19 18:40:19 +02:00
David Szotten
2367e6e9bf refactor ci helper to prepare for re-use 2021-08-19 11:24:51 +00:00
Bruno Oliveira
16077f2a65 Merge pull request #9017 from hugovk/update-deprecated-unittest-aliases 2021-08-18 08:11:50 -03:00
Hugo van Kemenade
5ec89fd6e5 Docs: refer to non-deprecated unittest alias 2021-08-18 12:43:59 +03:00
Anthony Sottile
720b91df2e Merge pull request #8995 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-17 14:36:42 -04:00
Bruno Oliveira
0f79fc6dbb Merge pull request #8752 from azmeuk/issue-7132-syntax-highlight-themes 2021-08-15 09:06:41 -03:00
Bruno Oliveira
36ed2f7d90 Merge pull request #9006 from pytest-dev/update-plugin-list/patch-243972941
[automated] Update plugin list
2021-08-15 09:04:32 -03:00
pytest bot
1cbb67f71b [automated] Update plugin list 2021-08-15 00:09:52 +00:00
Éloi Rivard
7770dacb8d pygments themes are customizable 2021-08-13 19:15:01 +02:00
pre-commit-ci[bot]
108f1d7e5e [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.1 → v2.23.3](https://github.com/asottile/pyupgrade/compare/v2.23.1...v2.23.3)
2021-08-09 18:53:50 +00:00
Terje Runde
2439729413 logging: Make it possible to add cli colors to custom log levels
Closes #8803
PR #8804

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Terje Runde <terje.runde@flir.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-08-09 13:48:47 +00:00
Ran Benita
df033f3ab1 Merge pull request #8987 from bluetech/k-backslash
mark/expression: allow backslash characters in identifiers
2021-08-08 17:15:53 +03:00
Ran Benita
25c65616f4 mark/expression: allow backslash characters in identifiers
Fixes #8983.
2021-08-08 11:56:17 +03:00
Bruno Oliveira
a446ee81fd Merge pull request #8985 from pytest-dev/update-plugin-list/patch-bacc8498e
[automated] Update plugin list
2021-08-08 01:43:27 -03:00
pytest bot
4d2944e1d4 [automated] Update plugin list 2021-08-08 00:10:10 +00:00
Simon K
bacc8498e9 pytest_assertion_pass is no longer considered experimental (#8967)
* `pytest_assertion_pass` is no longer considered `experimental`

* adding changelog
2021-08-03 14:31:18 +01:00
Bruno Oliveira
599e3dfdb6 Merge pull request #8970 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-08-02 21:06:34 -03:00
pre-commit-ci[bot]
b33c81b57f [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.23.0 → v2.23.1](https://github.com/asottile/pyupgrade/compare/v2.23.0...v2.23.1)
2021-08-02 18:53:11 +00:00
Bruno Oliveira
bacb8a4a56 Merge pull request #8968 from pytest-dev/dependabot/pip/testing/plugins_integration/twisted-21.7.0 2021-08-02 10:19:40 -03:00
dependabot[bot]
c22bf3ff3e build(deps): bump twisted in /testing/plugins_integration
Bumps [twisted](https://github.com/twisted/twisted) from 21.2.0 to 21.7.0.
- [Release notes](https://github.com/twisted/twisted/releases)
- [Changelog](https://github.com/twisted/twisted/blob/trunk/NEWS.rst)
- [Commits](https://github.com/twisted/twisted/compare/twisted-21.2.0...twisted-21.7.0)

---
updated-dependencies:
- dependency-name: twisted
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-02 03:01:59 +00:00
Bruno Oliveira
e7916c4f4e [automated] Update plugin list (#8965)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-08-01 15:06:40 -03:00
Bruno Oliveira
a83b359cf0 Refactor internal scope handling by introducing Scope enum
PR #8913
2021-08-01 06:11:56 -03:00
pytest bot
fed18fb76d [automated] Update plugin list 2021-08-01 00:10:10 +00:00
Simon K
ef5d81ad5c add assert_outcomes(warnings=) functionality to RunResult
* expose `warnings=` to pytester `assert_outcomes()`

* fix test fallout from adding warnings= to assert_outcomes()

* #closes 8593 - Improve test and add a `changelog` entry for the change
2021-07-31 15:25:10 +01:00
Simon K
c27db3bd8e Deprecate pytest_cmdline_preparse
Close #8592 

PR #8956
2021-07-31 10:53:43 -03:00
Bruno Oliveira
0fd0e2a27c Merge pull request #8963 from symonk/mypy-pathlike-runtime-checkable-fix
typeshed `os.PathLike` is now `@runtime_checkable`, remove mypy ignore
2021-07-31 10:27:58 -03:00
Emmanuel Arias
2834b39b65 Add examples of parametrizing classes and all tests in a module
Closes #8947

PR #8962
2021-07-31 13:26:25 +00:00
symonk
1b9ba65b3f typeshed os.PathLike is now @runtime_checkable, remove mypy ignore 2021-07-31 14:00:36 +01:00
Ran Benita
6247a95601 Merge pull request #8920 from bluetech/stabilize-store
Rename Store to Stash and make it public
2021-07-31 10:32:30 +03:00
Bruno Oliveira
60d9891474 Fix small typo in pluggy writing hook functions docs (#8961)
Fix small typo in pluggy writing hook functions docs
2021-07-30 22:27:01 -03:00
symonk
a9a934e8ce fix minor typo in writing hook functions documentation 2021-07-31 01:49:53 +01:00
Simon K
d5c62d0326 Making --debug more configurable for the pytest user (#8955)
Close #8954
2021-07-30 17:37:38 -03:00
Simon K
6d6bc97231 #7124: Fix --doctest-modules crashing when __main__.py is present (#8949)
* Fix ``--doctest-modules`` crashing when ``__main__.py`` is present
2021-07-27 22:50:26 +01:00
Bruno Oliveira
6a1ba80ab7 Merge pull request #8946 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-27 07:57:03 -03:00
Bruno Oliveira
df6d3b7dde Fix Dead link in README for 'assert statements' (#8945)
Closes: #8926
2021-07-27 07:56:19 -03:00
pre-commit-ci[bot]
237bdba061 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/reorder_python_imports: v2.5.0 → v2.6.0](https://github.com/asottile/reorder_python_imports/compare/v2.5.0...v2.6.0)
- [github.com/asottile/pyupgrade: v2.21.2 → v2.23.0](https://github.com/asottile/pyupgrade/compare/v2.21.2...v2.23.0)
2021-07-26 18:05:01 +00:00
Emmanuel Arias
15989ddc8f Fix Dead link in README for 'assert statements'
Closes: #8926
2021-07-26 12:14:52 -03:00
Simon K
1d848314d0 some small quality of life changes (#8454)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-07-26 07:48:15 -03:00
Bruno Oliveira
90b70a7efe Merge pull request #8942 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-twisted-1.13.3
build(deps): bump pytest-twisted from 1.13.2 to 1.13.3 in /testing/plugins_integration
2021-07-26 06:58:02 -03:00
Bruno Oliveira
4cc2781ad8 Merge pull request #8943 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.3.0
build(deps): bump anyio[curio,trio] from 3.2.1 to 3.3.0 in /testing/plugins_integration
2021-07-26 06:57:51 -03:00
dependabot[bot]
b35a3de006 build(deps): bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.2.1 to 3.3.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.2.1...3.3.0)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-26 03:01:29 +00:00
dependabot[bot]
de8ad53963 build(deps): bump pytest-twisted in /testing/plugins_integration
Bumps [pytest-twisted](https://github.com/pytest-dev/pytest-twisted) from 1.13.2 to 1.13.3.
- [Release notes](https://github.com/pytest-dev/pytest-twisted/releases)
- [Commits](https://github.com/pytest-dev/pytest-twisted/compare/v1.13.2...v1.13.3)

---
updated-dependencies:
- dependency-name: pytest-twisted
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-26 03:01:26 +00:00
Ran Benita
9c9d79890d Merge pull request #8941 from pytest-dev/update-plugin-list/patch-305e15df9
[automated] Update plugin list
2021-07-25 12:28:03 +03:00
pytest bot
8b5b3575a0 [automated] Update plugin list 2021-07-25 00:08:36 +00:00
Ran Benita
2aaea20cb2 Use {node,config}.stash instead of ._store
Use the public name. The `_store` name is only because some plugins
started using it anyway - will be removed at some point.
2021-07-24 17:40:08 +03:00
Ran Benita
c6bdeb8491 stash: make Stash and StashKey public
It's had enough time to bake - let's allow external plugins to use it.
2021-07-24 17:40:08 +03:00
Ran Benita
305e15df97 Merge pull request #8937 from nicoddemus/port-8932
contact.rst: Added github discussions
2021-07-24 11:32:07 +03:00
Bruno Oliveira
5e39f43e7c contact.rst: Added github discussions
Ported from #8932
2021-07-23 09:40:11 -03:00
Ronny Pfannschmidt
bd09b79236 Merge pull request #8922 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-20 10:42:38 +02:00
pre-commit-ci[bot]
53357f464c [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.6b0 → 21.7b0](https://github.com/psf/black/compare/21.6b0...21.7b0)
- [github.com/asottile/pyupgrade: v2.21.0 → v2.21.2](https://github.com/asottile/pyupgrade/compare/v2.21.0...v2.21.2)
2021-07-19 22:13:39 +00:00
Ran Benita
7ff07ff3e1 Merge pull request #8919 from pytest-dev/update-plugin-list/patch-940c6e233
[automated] Update plugin list
2021-07-18 16:13:14 +03:00
Ran Benita
5f39e31736 stash: implement __len__
Part of the MutableMapping abc (though we can't actually implement
that).
2021-07-18 15:32:52 +03:00
Ran Benita
5470d33e82 store: rename Store to Stash
The name "stash" is a bit more distinguishable and more evocative of the
intended usage.
2021-07-18 15:21:27 +03:00
pytest bot
0a1f58a912 [automated] Update plugin list 2021-07-18 00:08:39 +00:00
Bruno Oliveira
940c6e2337 Merge pull request #8904 from nicoddemus/types-atomicwrites
Add types-atomicwrites to mypy's pre-commit configuration
2021-07-15 12:35:51 -03:00
Thomas Grainger
388691a205 rename tmpdir.rst to tmp_path.rst (#8905) 2021-07-14 12:53:27 -03:00
Naveen-Pratap
febb978651 Update error message for module level skip to include 'allow_module_level' (#8906)
Co-authored-by: Naveen <NaveenPr1@microland.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-07-14 14:27:26 +00:00
Bruno Oliveira
69356d20cf Merge pull request #8903 from nicoddemus/remove-fspath-deprecation
Revert fspath deprecation
2021-07-14 09:32:48 -03:00
Bruno Oliveira
828fde1156 Merge pull request #8858 from The-Compiler/update-doc-urls 2021-07-14 09:28:46 -03:00
Bruno Oliveira
d71d31c1e0 Merge pull request #8812 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-07-13 08:31:32 -03:00
Bruno Oliveira
794f467647 Merge pull request #8854 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2.5 2021-07-13 08:30:28 -03:00
Bruno Oliveira
913d0c2380 Merge pull request #8855 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-rerunfailures-10.1
build(deps): bump pytest-rerunfailures from 10.0 to 10.1 in /testing/plugins_integration
2021-07-13 08:30:13 -03:00
Bruno Oliveira
59b86cf328 Merge pull request #8856 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-bdd-4.1.0
build(deps): bump pytest-bdd from 4.0.2 to 4.1.0 in /testing/plugins_integration
2021-07-13 08:29:47 -03:00
Bruno Oliveira
b88ee5bc55 Add types-atomicwrites to mypy's pre-commit configuration
This is a Windows only dependency, so the problem only shows up when trying to commit on Windows.
2021-07-13 08:27:35 -03:00
Bruno Oliveira
2c4c57e135 Revert fspath deprecation
It is not clear yet how we should proceed with this deprecation
because `pytest.Item.reportinfo` is public API and returns a `py.path` object,
and is not clear how plugins and our examples should handle that.

Reverting just the deprecation aspect of #8251 so we can get a 7.0.0 release out.

We will reintroduce the deprecation later once we have a clear path moving forward with replacing `reportinfo`.

Closes #8445
Closes #8821
2021-07-13 08:24:39 -03:00
Ronny Pfannschmidt
d0bd269b87 Merge pull request #8899 from gsmecher/parameterize-complex-numbers
Generate useful parameterization IDs for complex() numbers.
2021-07-13 07:03:37 +02:00
pre-commit-ci[bot]
7d1efd5c3a [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.19.4 → v2.21.0](https://github.com/asottile/pyupgrade/compare/v2.19.4...v2.21.0)
- [github.com/pre-commit/mirrors-mypy: v0.902 → v0.910](https://github.com/pre-commit/mirrors-mypy/compare/v0.902...v0.910)
2021-07-12 23:27:47 +00:00
Bruno Oliveira
3c18a9ecd0 Rename 8898.trivial.rst to 8898.improvement.rst 2021-07-12 18:09:13 -03:00
Graeme Smecher
5c04674e96 Generate useful parameterization IDs for complex() numbers. 2021-07-12 12:27:24 -07:00
Miro Hrončok
5165bf97c6 Revert "Adjust enum reprs for Python 3.10" (#8896)
This reverts commit 710446420c.

The change was reverted in Python 3.10.0b4:

https://mail.python.org/archives/list/python-dev@python.org/message/LSTMFAPSPD3BGZ4D6HQFODXZVB3PLYKF/
2021-07-12 14:32:27 +00:00
Bruno Oliveira
4a6acea1e3 Merge pull request #8888 from pytest-dev/update-plugin-list/patch-5d8392cb6
[automated] Update plugin list
2021-07-12 10:16:40 -03:00
pytest bot
b6648219ec [automated] Update plugin list 2021-07-11 00:08:26 +00:00
Anthony Sottile
5d8392cb68 Merge pull request #8874 from adamjstewart/monkeypatch/setenv
Docs: monkeypatch.setenv does not accept bool
2021-07-09 11:38:25 -04:00
Anthony Sottile
0182eb3743 Merge pull request #8881 from pytest-dev/asottile-patch-1
Remove upper pinning on tomli
2021-07-09 10:27:58 -04:00
Anthony Sottile
fa42be77a6 Remove upper pinning on tomli
the best practice is to only `<` when you know something is broken, and even then prefer `!=` assuming it will be fixed upstream for maximum compatibility
2021-07-09 10:09:05 -04:00
Bruno Oliveira
e86bf7fda0 Merge pull request #8857 from hukkin/tomli
Support TOML v1.0.0 syntax in `pyproject.toml`
2021-07-09 11:05:46 -03:00
Adam J. Stewart
17f1a0af8e Fix in more places, use default 2021-07-08 12:43:10 -05:00
Adam J. Stewart
3989a9bb05 Docs: monkeypatch.setenv does not accept bool 2021-07-08 12:21:30 -05:00
Sören Wegener
6740fb9da6 doc: Typofix in fixtures how-to (#8860) 2021-07-06 14:31:21 +00:00
Taneli Hukkinen
5987251407 Add a test for invalid TOML file 2021-07-06 16:53:32 +03:00
Taneli Hukkinen
40797dee87 Make news indicate that a dependency changed 2021-07-06 13:14:45 +03:00
Taneli Hukkinen
e1a4b4edd2 Convert TOMLDecodeError to UsageError 2021-07-06 13:10:44 +03:00
pre-commit-ci[bot]
51f645e567 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-07-06 07:18:57 +00:00
Florian Bruhin
953fdabaf0 Adjust doc links for new scheme
Closes #8831
2021-07-06 09:11:35 +02:00
Taneli Hukkinen
e942b12b94 Support TOML v1.0.0 syntax in pyproject.toml 2021-07-06 00:26:01 +03:00
dependabot[bot]
904637baa7 build(deps): bump pytest-bdd in /testing/plugins_integration
Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 4.0.2 to 4.1.0.
- [Release notes](https://github.com/pytest-dev/pytest-bdd/releases)
- [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-bdd/compare/4.0.2...4.1.0)

---
updated-dependencies:
- dependency-name: pytest-bdd
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-05 03:01:53 +00:00
dependabot[bot]
3e108012d9 build(deps): bump pytest-rerunfailures in /testing/plugins_integration
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 10.0 to 10.1.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases)
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/10.0...10.1)

---
updated-dependencies:
- dependency-name: pytest-rerunfailures
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-05 03:01:51 +00:00
dependabot[bot]
2d5990c443 build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2.4...3.2.5)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-05 03:01:49 +00:00
Florian Bruhin
8347b59295 Update remaining 7.0 references (#8834) 2021-07-04 10:27:43 +02:00
Eric Liu
8c25a14032 closes #8824 Changelog rewording for 7.0 (#8826)
* fixed changelog/*.rst docs

* add author name

* fixed-documents

* fix issue 8761 doc

* fix issue 8645 doc

* fix issue 8447 doc

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-07-03 12:20:12 +02:00
ericluoliu
501637547e Issue #8823 - remove bots from contributors list (#8828)
* fix-contributors-list

* remove-bots

* delete-extraneous-file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-06-30 13:53:32 +00:00
Srip
9cdb7223b5 doc: Adding the missing sys import (#8819) (#8827)
Co-authored-by: Sripradha Karkala <sripradha.karkala@nutanix.com>
2021-06-30 08:11:20 +02:00
Bruno Oliveira
1d67553403 Merge pull request #8247 from nicoddemus/version-stdout-8246 2021-06-28 16:13:31 -03:00
Florian Bruhin
4d965557e2 ci: Persist git credentials for prepare-release-pr (#8813)
See #8599, follow-up to #8681
2021-06-28 20:58:55 +02:00
Bruno Oliveira
109312ba86 Make --version write to stdout rather than stderr
Fix #8246
2021-06-28 15:56:26 -03:00
Bruno Oliveira
2623ee2e0e Merge pull request #8802 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.2.1
Bump anyio[curio,trio] from 3.2.0 to 3.2.1 in /testing/plugins_integration
2021-06-28 15:37:01 -03:00
Florian Bruhin
ba1ad7d517 Opt-out from regendoc for problematic example (#8810)
* Opt-out from regendoc for problematic example

See #8807

* Add comment
2021-06-28 17:47:49 +00:00
Florian Bruhin
c4c3b6d4fd Adjust fixme comments (#8811) 2021-06-28 17:41:22 +00:00
Florian Bruhin
e729e0d1e6 scripts: Don't capture output in prepare-release-pr.py (#8805)
We don't need to access the output in the script, and if we capture it,
we don't get any output on CI, so no way to see why a release failed.
2021-06-28 12:15:25 +00:00
Florian Bruhin
c19f63d39d Adjust releasing infra/docs (#8795)
* Adjust releasing infra/docs

Follow-up for #8150, see #7507

* Add suggestions
2021-06-28 12:24:48 +02:00
dependabot[bot]
51742e14a1 Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.2.0 to 3.2.1.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.2.0...3.2.1)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-28 03:01:47 +00:00
Srip
6573107b97 doc: Adding exit code for pytest usage examples (#8790) (#8800)
* doc: Adding exit code for pytest usage examples (#8790)

Fix #8790 

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Sripradha Karkala <sripradha.karkala@nutanix.com>
2021-06-27 13:29:16 +00:00
Bruno Oliveira
ef395e1c38 Merge pull request #8799 from pytest-dev/update-plugin-list/patch-cb1dba048
[automated] Update plugin list
2021-06-27 00:17:59 -03:00
pytest bot
f0e5640497 [automated] Update plugin list 2021-06-27 00:08:04 +00:00
Florian Bruhin
cb1dba0489 doc: Add new open trainings (#8793) 2021-06-24 20:21:22 +02:00
Bruno Oliveira
0d6cb3b281 Allow prereleases from prepare-release workflow (#8628)
Fix #7551
2021-06-24 18:05:56 +00:00
Ronny Pfannschmidt
d7b0e17205 issue a warning when Item and Collector are used in diamond inheritance (#8447)
* issue a warning when Items and Collector form a diamond

addresses #8435

* Apply suggestions from code review

Co-authored-by: Ran Benita <ran@unusedvar.com>

* Return support for the broken File/Item hybrids

* adds deprecation
* ads necessary support code in node construction

* fix incorrect mypy based assertions

* add docs for deprecation of Item/File inheritance

* warn when a non-cooperative ctor is encountered

* use getattr instead of cast to get the class __init__ for legacy ctors

* update documentation references for node inheritance

* clean up file+item inheritance test

enhance docs
move import upwards

Co-authored-by: Ran Benita <ran@unusedvar.com>
2021-06-24 11:45:32 +02:00
James Bourbeau
942789bace Fix API links in 'How to capture warnings' documentation page (#8792) 2021-06-23 19:34:48 +00:00
Florian Bruhin
f573b56bb6 Improve cache test and fix it in Docker (#8785)
* cache: Move repetitive code to fixture

* cache: Explicitly test for chmod result

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix lint

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-06-23 20:28:09 +02:00
Florian Bruhin
e44300de7e doc: Add history page (#8784)
Based on #8667
2021-06-23 20:26:08 +02:00
Ronny Pfannschmidt
8eb8c42bd6 Merge pull request #8786 from The-Compiler/outside
tests: Use less conflicting name for directory
2021-06-22 21:59:52 +02:00
Florian Bruhin
ac10fe0679 tests: Use less conflicting name for directory
Otherwise, if e.g. /outside is used for a Docker container, the test will fail
2021-06-22 13:25:52 +02:00
Bruno Oliveira
0a6a1fa225 Merge pull request #8782 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.2.0
Bump anyio[curio,trio] from 3.1.0 to 3.2.0 in /testing/plugins_integration
2021-06-21 07:41:15 -03:00
dependabot[bot]
d2886b8d23 Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.1.0...3.2.0)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-21 03:01:37 +00:00
Bruno Oliveira
68b329dda8 Merge pull request #8764 from pytest-dev/pre-commit-ci-update-config 2021-06-20 12:27:03 -03:00
Anthony Sottile
ab3cd644dc add temporary ignore for FileHandler stream close 2021-06-20 08:09:18 -07:00
Anthony Sottile
a1967e9594 fix overload of __getitem__ for Traceback 2021-06-19 21:41:00 -07:00
Anthony Sottile
c4da6fff42 Add missing types-* stub packages 2021-06-19 21:31:17 -07:00
pre-commit-ci[bot]
605fe29d12 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.5b2 → 21.6b0](https://github.com/psf/black/compare/21.5b2...21.6b0)
- [github.com/asottile/pyupgrade: v2.19.1 → v2.19.4](https://github.com/asottile/pyupgrade/compare/v2.19.1...v2.19.4)
- [github.com/pre-commit/pygrep-hooks: v1.8.0 → v1.9.0](https://github.com/pre-commit/pygrep-hooks/compare/v1.8.0...v1.9.0)
- [github.com/pre-commit/mirrors-mypy: v0.812 → v0.902](https://github.com/pre-commit/mirrors-mypy/compare/v0.812...v0.902)
2021-06-14 17:42:33 +00:00
Bruno Oliveira
ced125ad15 Merge pull request #8761 from nicoddemus/version-tuple 2021-06-14 09:27:22 -03:00
Bruno Oliveira
7eb0792cba Add pytest.version_tuple
This adds `pytest.version_tuple`, which makes it simpler for users to do something depending on the pytest version, such as declaring hooks which are introduced in later versions.

This feature was added originally in https://github.com/pypa/setuptools_scm/pull/475.

Followup to https://github.com/pytest-dev/pytest/pull/7605.
2021-06-14 09:04:14 -03:00
Bruno Oliveira
6447ca5f1e Merge pull request #8756 from pytest-dev/update-plugin-list/patch-c675d8054
[automated] Update plugin list
2021-06-13 00:56:20 -03:00
pytest bot
5ea541d415 [automated] Update plugin list 2021-06-13 00:10:04 +00:00
Bruno Oliveira
c675d8054d Merge pull request #8754 from nicoddemus/fix-deprecation-docs 2021-06-12 12:52:29 -03:00
Bruno Oliveira
16685dc279 Change os.getuid() guard in tmpdir.py
This matches the guard used by typeshed and avoid mypy errors on Windows:

48a346920b/stdlib/os/__init__.pyi (L388)
2021-06-12 12:31:58 -03:00
Bruno Oliveira
c85b21eaa0 Remove outdated docs about pytest.warns and DeprecatedWarning
Since #2908, the user doesn't need to set warning filters to capture
`DeprecationWarning` with `pytest.warns`.

Fix #8666
2021-06-12 12:09:26 -03:00
Bruno Oliveira
fb7e36b2f7 Merge pull request #8735 from pytest-dev/update-plugin-list/patch-8300b266a
[automated] Update plugin list
2021-06-12 10:49:02 -03:00
Anthony Sottile
c94766a580 Merge pull request #8738 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-django-4.4.0
Bump pytest-django from 4.3.0 to 4.4.0 in /testing/plugins_integration
2021-06-10 17:42:34 -07:00
dependabot[bot]
85faaf8a1d Bump pytest-django from 4.3.0 to 4.4.0 in /testing/plugins_integration
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.3.0 to 4.4.0.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/master/docs/changelog.rst)
- [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: pytest-django
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-11 00:18:17 +00:00
Anthony Sottile
5a9139c5ec Merge pull request #8739 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-cov-2.12.1
Bump pytest-cov from 2.12.0 to 2.12.1 in /testing/plugins_integration
2021-06-10 17:17:18 -07:00
dependabot[bot]
b04aa015b9 Bump pytest-cov from 2.12.0 to 2.12.1 in /testing/plugins_integration
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.12.0 to 2.12.1.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.12.0...v2.12.1)

---
updated-dependencies:
- dependency-name: pytest-cov
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-10 23:10:22 +00:00
Anthony Sottile
657e35618f Merge pull request #8737 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2.4
Bump django from 3.2.3 to 3.2.4 in /testing/plugins_integration
2021-06-10 16:09:40 -07:00
Bruno Oliveira
8010fb9f40 Merge pull request #8749 from beniwohli/fix-at-level-type-hints
updated type hints for caplog.at_level to match caplog.set_level
2021-06-10 19:33:35 -03:00
Benjamin Wohlwend
58036d463d updated type hints for caplog.at_level to match caplog.set_level
The underlying logging API accepts the log level both as int and
as string.
2021-06-10 09:34:54 +02:00
Bruno Oliveira
992eabc29e Merge pull request #8747 from asottile/typo-fix
Fix typo in fixture.rst
2021-06-09 19:54:23 -03:00
Jason Haugen
479209bde1 Fix typo in fixture.rst
Example referenced the wrong function name
2021-06-09 15:13:48 -07:00
Bruno Oliveira
68bb0db808 Merge pull request #8742 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-06-09 17:23:14 -03:00
pre-commit-ci[bot]
595b7e894c [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/asottile/pyupgrade: v2.19.0 → v2.19.1](https://github.com/asottile/pyupgrade/compare/v2.19.0...v2.19.1)
2021-06-08 01:55:19 +00:00
dependabot[bot]
bce0ceafe4 Bump django from 3.2.3 to 3.2.4 in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.2.3 to 3.2.4.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2.3...3.2.4)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-07 03:01:43 +00:00
pytest bot
50b166ff0b [automated] Update plugin list 2021-06-06 00:17:08 +00:00
Bruno Oliveira
8300b266a8 Merge pull request #8732 from domdfcoding/patch-1
Fix typo (setupttools -> setuptools)
2021-06-05 15:10:24 -03:00
Dominic Davis-Foster
7fb5a9d033 Fix typo (setupttools -> setuptools) 2021-06-05 16:03:59 +01:00
Anthony Sottile
bb9683deea Merge pull request #8729 from asottile/revert-traceback-frame
Revert "Merge pull request #8227 from encukou/defensive-get_source"
2021-06-03 12:46:53 -07:00
Anthony Sottile
77235e2759 Revert "Merge pull request #8227 from encukou/defensive-get_source"
This reverts commit 67af623d9e, reversing
changes made to aead41e449.
2021-06-03 08:45:57 -07:00
Florian Bruhin
9ad726a9a0 Switch to irc.libera.chat (#8722) 2021-06-01 17:34:29 +02:00
Bruno Oliveira
cde6920e49 Merge pull request #8719 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-31 16:34:45 -03:00
pre-commit-ci[bot]
c51520ab2a [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.5b1 → 21.5b2](https://github.com/psf/black/compare/21.5b1...21.5b2)
- [github.com/asottile/pyupgrade: v2.18.2 → v2.19.0](https://github.com/asottile/pyupgrade/compare/v2.18.2...v2.19.0)
2021-05-31 17:32:52 +00:00
Bruno Oliveira
360ce686f1 Merge pull request #8713 from pytest-dev/update-plugin-list/patch-43faea832
[automated] Update plugin list
2021-05-31 10:54:38 -03:00
Bruno Oliveira
7ce69347ce Merge pull request #8717 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-rerunfailures-10.0
Bump pytest-rerunfailures from 9.1.1 to 10.0 in /testing/plugins_integration
2021-05-31 09:30:19 -03:00
Bruno Oliveira
788d8785ce Merge pull request #8718 from dlax/docs/tmpdir_factory
Fix a typo in documentation about tmpdir_factory
2021-05-31 09:22:26 -03:00
Denis Laxalde
cf7425d22b Fix a typo in documentation about tmpdir_factory
The section refers to tmpdir_factory, but the sentence mentionned
tmp_path_factory.
2021-05-31 09:36:18 +02:00
dependabot[bot]
20f00997ff Bump pytest-rerunfailures in /testing/plugins_integration
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures) from 9.1.1 to 10.0.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases)
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/9.1.1...10.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-31 03:01:08 +00:00
pytest bot
4b7d8b2edd [automated] Update plugin list 2021-05-30 00:23:19 +00:00
Bruno Oliveira
43faea832d Merge pull request #8704 from offbyone/doc-getting-started-test-instance
Make the test class instance behaviour clearer
2021-05-26 18:42:37 -03:00
Bruno Oliveira
798bca4076 Merge pull request #8705 from MapleCCC/main
Fix cyclic links in goodpractices.rst
2021-05-26 18:41:13 -03:00
MapleCCC
627b446252 Fix cyclic links in goodpractices.rst 2021-05-27 04:33:49 +08:00
Chris Rose
640b2c0e13 Make the test class instance behaviour clearer
In the "Getting Started" doc, the test class instance example for
instance sharing doesn't actually demonstrate anything about the
reinstantiation of the class. This change shows clearly how the instance
data isn't retained between test runs.
2021-05-26 09:12:29 -07:00
Florian Bruhin
1d5ee4dd7c doc: Remove training sidebar (#8701) 2021-05-26 14:15:00 +02:00
Ran Benita
1ba5b48565 Merge pull request #8697 from bluetech/expose-config
config: expose Config and PytestPluginManager for typing purposes
2021-05-26 11:20:42 +03:00
Ran Benita
1b5f5326d7 Merge pull request #8695 from bluetech/export-parser
argparsing: export Parser and OptionGroup for typing purposes
2021-05-26 11:20:03 +03:00
pre-commit-ci[bot]
c5bf5f6fb0 [pre-commit.ci] pre-commit autoupdate (#8699)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/asottile/pyupgrade: v2.16.0 → v2.18.2](https://github.com/asottile/pyupgrade/compare/v2.16.0...v2.18.2)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-05-26 11:19:45 +03:00
Ran Benita
ef9d01826a Merge pull request #8693 from pytest-dev/update-plugin-list/patch-c198a7a67
[automated] Update plugin list
2021-05-24 19:14:03 +03:00
Ran Benita
847d8f42ea Merge pull request #8696 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.1.0
Bump anyio[curio,trio] from 3.0.1 to 3.1.0 in /testing/plugins_integration
2021-05-24 19:13:20 +03:00
Ran Benita
e6ed28f0e7 Merge pull request #8694 from bluetech/rec-eval-wrapper
code: remove unneeded comparison eval wrapper
2021-05-24 19:12:56 +03:00
Ran Benita
9719237fe6 doc: refer to type by its public name 2021-05-24 12:31:28 +03:00
Ran Benita
c0d525e44c config: expose PytestPluginManager for typing purposes
This type is used in hooks and transitively through `Config`.
2021-05-24 12:27:07 +03:00
Ran Benita
88d84a5791 config: expose Config for typing purposes
This type is used in hooks and fixtures.

The constructor is publicly documented so is not marked private.
2021-05-24 12:26:22 +03:00
dependabot[bot]
4a472952f7 Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.0.1 to 3.1.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.0.1...3.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 03:01:18 +00:00
Ran Benita
538b5c2499 argparsing: export Parser and OptionGroup for typing purposes
`Parser` is used by many plugins and custom hooks. `OptionGroup` is
exposed by the `parser.addgroup` API.

The constructors of both are marked private, they are not meant to be
constructed directly.
2021-05-24 00:52:03 +03:00
Ran Benita
c90fdc684b code: remove unneeded comparison eval wrapper
Given a `RecursionError` traceback, the `Traceback.recursionindex()`
method returns the index of the frame which started the recursion
(repeated set of frames). To do so it attempts to check whether two
frames are equivalent. Just checking the function/line is not enough
because the recursion variable(s) might differ (e.g. imagine the numeric
value in a recursive factorial implementation). So it also compares the
`f_locals` (local variables) of each frame for equivalence.

For some reason, the locals comparison is wrapped in an `eval` whose
purpose is to evaluate the comparison in one of the compared frame's
context (locals + globals in scope). However, I can not think of any way
in which the global scope could affect the evaluation. It would have an
affect when the locals are bound but that's already done. So this seems
unnecessary - remove it.
2021-05-23 20:59:38 +03:00
pytest bot
11538e35e4 [automated] Update plugin list 2021-05-23 00:12:33 +00:00
Zac Hatfield-Dodds
c198a7a67e Merge pull request #8677 from olgarithms/warns-no-arg-catches-any 2021-05-19 17:47:39 +10:00
Ran Benita
ff6d29717c Merge pull request #8681 from bluetech/ci-permissions
ci: few security/permissions improvements
2021-05-18 22:21:25 +03:00
Ran Benita
864a2bc0a3 ci: use GitHub Actions token instead of chatops/release_notes secrets
It seems more secure to use the controlled & limited token than an
ambient secret.
2021-05-18 16:05:14 +03:00
Ran Benita
6bc6ec323a ci: reduce workflow permissions
Decrease security exposure by restricting what the code executing in the
actions is allowed to do (in terms of GitHub operations).
2021-05-18 16:05:14 +03:00
Ran Benita
e2567a680e scripts: improve upload-coverage.sh
Mostly, verify the bash uploader hash and make it more strict and
verbose.
2021-05-18 16:05:14 +03:00
Anthony Sottile
d52cd08757 Merge pull request #8687 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-17 22:11:31 -07:00
pre-commit-ci[bot]
249c5b37dd [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/pre-commit/pre-commit-hooks: v3.4.0 → v4.0.1](https://github.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.1)
- [github.com/asottile/pyupgrade: v2.15.0 → v2.16.0](https://github.com/asottile/pyupgrade/compare/v2.15.0...v2.16.0)
2021-05-17 17:29:57 +00:00
Bruno Oliveira
0d502328ea Merge pull request #8653 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-mock-3.6.1 2021-05-17 08:21:42 -03:00
dependabot[bot]
53a74feea7 Bump pytest-mock from 3.6.0 to 3.6.1 in /testing/plugins_integration
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.6.0 to 3.6.1.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.6.0...v3.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 10:53:38 +00:00
Bruno Oliveira
88944bec6a Merge pull request #8684 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-django-4.3.0
Bump pytest-django from 4.2.0 to 4.3.0 in /testing/plugins_integration
2021-05-17 07:52:55 -03:00
dependabot[bot]
8872e8e7c7 Bump pytest-django from 4.2.0 to 4.3.0 in /testing/plugins_integration
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.2.0 to 4.3.0.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/master/docs/changelog.rst)
- [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.2.0...v4.3.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 10:51:47 +00:00
Bruno Oliveira
eb7acba9e9 Merge pull request #8683 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2.3
Bump django from 3.2.2 to 3.2.3 in /testing/plugins_integration
2021-05-17 07:51:36 -03:00
Bruno Oliveira
e59d0c461b Merge pull request #8682 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-cov-2.12.0
Bump pytest-cov from 2.11.1 to 2.12.0 in /testing/plugins_integration
2021-05-17 07:51:24 -03:00
Olga Matoula
3f414d7bbe Ignore depredcated warns(None) overload errors from mypy 2021-05-17 09:50:59 +01:00
Olga Matoula
dd8ad3fa9c Split warns matching string in multiple lines 2021-05-17 09:23:08 +01:00
dependabot[bot]
06718da5d6 Bump django from 3.2.2 to 3.2.3 in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.2.2 to 3.2.3.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2.2...3.2.3)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 03:01:19 +00:00
dependabot[bot]
c73e354019 Bump pytest-cov from 2.11.1 to 2.12.0 in /testing/plugins_integration
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.11.1 to 2.12.0.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.11.1...v2.12.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-17 03:01:15 +00:00
Olga Matoula
2414d23c78 Remove default arg from overloaded warns 2021-05-16 13:44:56 +01:00
Olga Matoula
24ad886b15 Remove the option to pass None in warns() 2021-05-16 12:10:32 +01:00
Olga Matoula
dbe66d97b4 Add better warning msg for deprecated warns(None) 2021-05-16 12:07:39 +01:00
Bruno Oliveira
b8f1b7cdc6 Merge pull request #8680 from pytest-dev/update-plugin-list/patch-c516dba
[automated] Update plugin list
2021-05-15 23:47:35 -03:00
pytest bot
a69ed66c2e [automated] Update plugin list 2021-05-16 00:10:52 +00:00
pre-commit-ci[bot]
6ae71a2c2b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-05-15 17:51:55 +00:00
Olga Matoula
8b2f83772d Catch any warning on warns with no arg passed 2021-05-15 18:50:39 +01:00
Rahul Kumaresan
c516dba69a add feature to view fixture source location in invocations with --fixtures-per-test option (#8626)
* add feature to view fixture source location in invocations with --fixtures-per-test option

* remove unrelated changes to show_fixtures_per_test::test_doctest_items

* eshew the extraneous else in _show_fixtures_per_test.write_fixture

* enable the accommodation of multi-line docstring with --fixtures-per-test option

* add feature to view fixture source location in invocations with --fixtures

* add colour encoding to fixture location paths

* add changelog for #8606 fixing

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-05-14 14:38:55 +02:00
Zack Kneupper
33c6ad5bf7 Replace some for loops, and other minor changes (#8660)
* Replace for loop using the  operator

* Replace for loop with a generator expression inside any()

* Replace for loop with a dictionary comprehension

* Use list comprehension

* Simplify arguments for range()

* Change newfuncargs variable to in-line dictionary comprehension

* is_ancestor: return base.is_relative_to(query)

* Remove unneeded import of pathlib

* Try using PurePath

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Import PurePath on new line

* Revert and remove is_relative_to

Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-05-14 09:32:50 +02:00
Ran Benita
364bbe42fc Merge pull request #8649 from Saiprasad16/main
UPDATE LICENSE
2021-05-13 17:34:18 +03:00
Ran Benita
c5de274136 Merge pull request #8650 from pytest-dev/update-plugin-list/patch-3ae0103
[automated] Update plugin list
2021-05-13 17:33:22 +03:00
Ran Benita
850a844779 Merge pull request #8664 from hroncok/test_unittest-ignore_DeprecationWarning-from-twisted
Ignore DeprecationWarnings in test_trial_error
2021-05-13 17:27:43 +03:00
Miro Hrončok
51293de324 Ignore DeprecationWarnings in test_trial_error
Fixes https://github.com/pytest-dev/pytest/issues/8663
2021-05-12 13:38:19 +02:00
Saiprasad Kale
0d6e3b7005 Update AUTHORS 2021-05-11 16:39:25 +05:30
Zack Kneupper
045ad5ac2d Replaced if-else statements with ternary expression (#8658)
* Replace if-else with ternary expression

* assign out variable in readouterr() with ternary expression

* assign err variable in readouterr() with ternary expression

* Assign precision with ternary expression

* ternary expression for collected/collecting

* Assign thread_name with ternary expression

* Update AUTHORS

Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
2021-05-11 11:52:55 +02:00
Ronny Pfannschmidt
7cec85a37d Merge pull request #8657 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-11 11:42:03 +02:00
Zack Kneupper
b4cd14aae3 Open log file in context manager (#8659)
Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
2021-05-11 09:10:01 +00:00
James Gerity
822624c252 Update help text for --pdbcls to match behavior (closes #8655) (#8656)
* Clarify help text for --pdbcls

* Add changelog entry for --pdbcls
2021-05-11 09:04:50 +00:00
dependabot[bot]
0a07b71046 Bump django from 3.2 to 3.2.2 in /testing/plugins_integration (#8652)
Bumps [django](https://github.com/django/django) from 3.2 to 3.2.2.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.2...3.2.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 10:44:32 +02:00
Zack Kneupper
48f14c48ea Remove unnecessary else clause in repr_failure() (#8661)
* Remove unnecessary else clause in repr_failure()

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-05-11 10:36:36 +02:00
pre-commit-ci[bot]
c519dd64ed [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.4b2 → 21.5b1](https://github.com/psf/black/compare/21.4b2...21.5b1)
- [github.com/PyCQA/flake8: 3.9.1 → 3.9.2](https://github.com/PyCQA/flake8/compare/3.9.1...3.9.2)
- [github.com/asottile/pyupgrade: v2.14.0 → v2.15.0](https://github.com/asottile/pyupgrade/compare/v2.14.0...v2.15.0)
2021-05-10 20:25:55 +00:00
pytest bot
e0a3dc7bf8 [automated] Update plugin list 2021-05-09 00:05:23 +00:00
Saiprasad Kale
7caf47acc6 Update AUTHORS 2021-05-08 23:50:17 +05:30
Saiprasad Kale
337a729d95 Update license.rst 2021-05-08 23:45:20 +05:30
Saiprasad Kale
6b53714d57 Update conf.py 2021-05-08 23:43:33 +05:30
Saiprasad Kale
647ac4a79d Update LICENSE 2021-05-08 23:38:48 +05:30
Zac Hatfield-Dodds
3ae0103975 Merge pull request #8641 from rahul-kumi/fix/8548
add support for precision bit in LEVEL_NAME_FMT regex
2021-05-08 01:17:55 +10:00
Rahul Kumaresan
9e11d645b1 cleanup tests by removal of unused code elements 2021-05-07 17:56:35 +05:30
Rahul Kumaresan
80acc0ed6f fix test_coloredlogformatter_with_width_precision test 2021-05-07 16:25:19 +05:30
Rahul Kumaresan
1e3fcece6d enhance support for precision bit in LEVELNAME_FMT_REGEX regex 2021-05-07 16:16:40 +05:30
Ran Benita
886fd70e2a Merge pull request #8594 from bluetech/addini-paths
argparsing: support parser.addini(type="paths") which returns pathlib.Paths
2021-05-07 12:44:53 +03:00
Ross Vandegrift
124691122a Expand command line argument examples with validation examples (#8610)
* Expand command line argument examples with validation examples

This shows how to pass more detailed error messages back to the user when
they've provided an incorrect value for a custom command line option.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-05-07 10:48:46 +03:00
Ran Benita
113a860a1f argparsing: support parser.addini(type="paths") which returns pathlib.Paths 2021-05-07 09:58:51 +03:00
Rahul Kumaresan
4b6188b3b1 add support for precision bit in LEVEL_NAME_FMT regex 2021-05-07 00:45:52 +05:30
Anthony Sottile
634312b14a Merge pull request #8633 from The-Compiler/ci-colors
ci: Force colors on
2021-05-05 08:09:47 -07:00
Rahul Kumaresan
245eefafcf clarify documentation about tolerance setting in unittest.TestCase.assertAlmost() (#8614) 2021-05-05 14:23:39 +02:00
Florian Bruhin
adc197424d Merge pull request #8555 from The-Compiler/py310-fix
Fix Python 3.10 test issues
2021-05-05 14:21:40 +02:00
mobius-crypt
385988ca1a Updated (#8620) 2021-05-05 14:16:21 +02:00
Tarcísio Fischer
b7416f7abd Suggest numpy testing module on pytest approx docs (#8615)
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Co-authored-by: Tarcisio Fischer <tarcisio@esss.co>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-05-04 23:08:41 -03:00
Anthony Sottile
a62a28b4b8 Merge pull request #8635 from asottile/fix-release
fix a command in RELEASING.rst
2021-05-04 09:40:25 -07:00
Bruno Oliveira
2534b7725e Merge pull request #8634 from The-Compiler/tidelift
Add myself to tidelift
2021-05-04 13:40:08 -03:00
Anthony Sottile
27564e7768 Merge pull request #8636 from asottile/cherry-pick-release
cherry-pick release notes from 6.2.4
2021-05-04 09:32:02 -07:00
Anthony Sottile
915ff7640b Merge pull request #8632 from pytest-dev/release-6.2.4
Prepare release 6.2.4

(cherry picked from commit 15a45388fa)
2021-05-04 09:27:16 -07:00
Anthony Sottile
5ae2106059 fix a command in RELEASING.rst 2021-05-04 09:25:11 -07:00
Florian Bruhin
3f71d63067 ci: Force colors on
See #7443
2021-05-04 17:55:47 +02:00
Florian Bruhin
4fc67eea4f Add myself to tidelift 2021-05-04 17:46:35 +02:00
Florian Bruhin
382599287f Fix test_errors_in_xfail_skip_expressions on Python 3.10 2021-05-04 17:26:53 +02:00
Florian Bruhin
61be48b485 Fix test_collect_symlink_dir on Windows 2021-05-04 17:25:08 +02:00
Florian Bruhin
e354c5c919 Fix warning filters used in tests 2021-05-04 17:25:02 +02:00
Florian Bruhin
710446420c Adjust enum reprs for Python 3.10
Potential fix for #8546
2021-05-04 17:24:50 +02:00
Florian Bruhin
f1570dc038 Ignore various warnings from Python 3.10
https://github.com/benjaminp/six/issues/341
https://github.com/benjaminp/six/pull/352
https://github.com/pypa/setuptools/pull/2517
2021-05-04 17:24:50 +02:00
Anthony Sottile
2637ec3921 Merge pull request #8624 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-05-03 18:27:37 -07:00
alshapton
4e048e0827 8625 - small grammar fix (#8627) 2021-05-03 20:42:23 +00:00
pre-commit-ci[bot]
f772e5e2b3 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 21.4b0 → 21.4b2](https://github.com/psf/black/compare/21.4b0...21.4b2)
- [github.com/asottile/pyupgrade: v2.13.0 → v2.14.0](https://github.com/asottile/pyupgrade/compare/v2.13.0...v2.14.0)
2021-05-03 17:21:32 +00:00
Bruno Oliveira
9c4da3e7b6 Merge pull request #8622 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.0.1
Bump anyio[curio,trio] from 3.0.0 to 3.0.1 in /testing/plugins_integration
2021-05-03 09:32:52 -03:00
dependabot[bot]
f1a97512da Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/3.0.0...3.0.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-03 03:01:15 +00:00
Bruno Oliveira
9fa205290e [automated] Update plugin list (#8618)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2021-05-02 10:23:11 -03:00
pytest bot
8f49ffdb57 [automated] Update plugin list 2021-05-02 00:12:49 +00:00
Tarcísio Fischer
9d9b84d175 Improve pytest.approx error messages readability (Pull request) (#8429)
Improve pytest.approx error messages readability (Pull request)
2021-04-30 07:36:56 -03:00
Parth Patel
992c403fc8 Improve iterparentnodeids to consume / parts until the first :: (#8577)
* Fix issue where TestCase.setUpClass is not called for test methods with a / in its name by checking if there is ::  before the selected / or any :: after. Also added a test case for this.

* removed print statement that was added

* Change iterparentnodeids to consume / parts until the first ::. Then consider ::. Tests were changed to reflect this.

* Update changelog/8509.improvement.rst

Co-authored-by: Ran Benita <ran@unusedvar.com>
2021-04-29 17:02:43 +03:00
Anthony Sottile
2049ae271e Merge pull request #8596 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-26 10:45:08 -07:00
pre-commit-ci[bot]
f5c22a6b45 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 20.8b1 → 21.4b0](https://github.com/psf/black/compare/20.8b1...21.4b0)
- [github.com/asottile/reorder_python_imports: v2.4.0 → v2.5.0](https://github.com/asottile/reorder_python_imports/compare/v2.4.0...v2.5.0)
- [github.com/asottile/pyupgrade: v2.12.0 → v2.13.0](https://github.com/asottile/pyupgrade/compare/v2.12.0...v2.13.0)
2021-04-26 17:23:05 +00:00
Ran Benita
134d8f78d8 Merge pull request #8595 from nschloe/url-fixes
"fix" a couple of http -> https redirects
2021-04-26 20:05:32 +03:00
Nico Schlömer
9ef608ef76 "fix" a couple of http -> https redirects
Found with
urli-fix . -a http: -i pytest
2021-04-26 17:44:27 +02:00
Bruno Oliveira
1e2c2d972d Merge pull request #8588 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-asyncio-0.15.1
Bump pytest-asyncio from 0.15.0 to 0.15.1 in /testing/plugins_integration
2021-04-26 10:44:01 -03:00
Bruno Oliveira
0d0e5ed74a Merge pull request #8589 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--3.0.0
Bump anyio[curio,trio] from 2.2.0 to 3.0.0 in /testing/plugins_integration
2021-04-26 10:43:55 -03:00
Bruno Oliveira
ff24dfbc9f Merge pull request #8590 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-mock-3.6.0
Bump pytest-mock from 3.5.1 to 3.6.0 in /testing/plugins_integration
2021-04-26 10:43:41 -03:00
dependabot[bot]
8d93f6ff0b Bump pytest-mock from 3.5.1 to 3.6.0 in /testing/plugins_integration
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.5.1 to 3.6.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.5.1...v3.6.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-26 03:01:18 +00:00
dependabot[bot]
11f6dc9de6 Bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 2.2.0 to 3.0.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/2.2.0...3.0.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-26 03:01:15 +00:00
dependabot[bot]
5a7be03285 Bump pytest-asyncio in /testing/plugins_integration
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.15.0 to 0.15.1.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.15.0...v0.15.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-26 03:01:13 +00:00
Anthony Sottile
0341893512 Merge pull request #8584 from nicoddemus/pygments-testing-extra
Make pygments part of 'testing' extras
2021-04-24 19:55:13 -07:00
Anthony Sottile
67af623d9e Merge pull request #8227 from encukou/defensive-get_source
Make code.FormattedExcinfo.get_source more defensive
2021-04-24 19:42:53 -07:00
Bruno Oliveira
aead41e449 Merge pull request #8586 from pytest-dev/update-plugin-list/patch-35c8139
[automated] Update plugin list
2021-04-24 22:51:32 -03:00
pytest bot
788d445b7b [automated] Update plugin list 2021-04-25 00:20:16 +00:00
Bruno Oliveira
35c8139e09 Merge pull request #8575 from domdfcoding/domdfcoding-patch-1
Remove "upload_sphinx" section from setup.cfg
2021-04-24 11:02:58 -03:00
Bruno Oliveira
c9e30a7035 Make pygments part of 'testing' extras
Tests in test_terminalwriter depend on pygments being installed
to work, so it should be installed with the `testing` extras.
2021-04-24 10:11:47 -03:00
Miro Hrončok
0a75c8e57b Add a regression test for a more defensive code.FormattedExcinfo.get_source 2021-04-22 19:17:54 +02:00
Dominic Davis-Foster
f9d1fa4c4b Remove "upload_sphinx" section from setup.cfg
The `Sphinx-PyPI-upload` tool the section corresponds to hasn't been updated since 2009, and the new (c. 2018) PyPI doesn't support documentation uploads anyway.
2021-04-21 16:46:28 +01:00
Ran Benita
4764c85275 Merge pull request #8570 from soxofaan/main
Logging docs: fix reference to pytest.LogCaptureFixture.
2021-04-20 16:42:54 +03:00
Ran Benita
c772d6d6a3 Merge pull request #8563 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-20 16:28:01 +03:00
Ran Benita
e5292ed8dc Merge pull request #8561 from pytest-dev/update-plugin-list/patch-9078c3c
[automated] Update plugin list
2021-04-20 16:26:23 +03:00
Ran Benita
513247863a Merge pull request #8562 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-asyncio-0.15.0
Bump pytest-asyncio from 0.14.0 to 0.15.0 in /testing/plugins_integration
2021-04-20 16:25:57 +03:00
Ran Benita
c7e146da0f Merge pull request #8567 from codingjoe/patch-1
Fix typos & missing commas in CONTRIBUTING.rst
2021-04-20 16:25:30 +03:00
Stefaan Lippens
7e82f6fc38 Logging docs: fix reference to pytest.LogCaptureFixture. 2021-04-20 15:21:30 +02:00
Johannes Maron
3cbbb0bb0d Fix typos & missing commas in CONTRIBUTING.rst 2021-04-20 12:30:27 +02:00
Miroslav Šedivý
fbe66244b8 Fix some typos, remove redundant words and escapes (#8564)
* doc: Fix typos, remove double words

* Remove redundant escapes in regex
2021-04-19 20:39:08 +00:00
pre-commit-ci[bot]
5d7fe91bd5 [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 3.9.0 → 3.9.1](https://github.com/PyCQA/flake8/compare/3.9.0...3.9.1)
2021-04-19 17:11:11 +00:00
dependabot[bot]
fb35851440 Bump pytest-asyncio in /testing/plugins_integration
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.14.0 to 0.15.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.14.0...v0.15.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-19 03:01:33 +00:00
pytest bot
c117bc350e [automated] Update plugin list 2021-04-18 00:18:53 +00:00
Abdelrahman Elbehery
9078c3ce23 fix #8464 wrong root dir when -c is passed (#8537)
fix #8464 wrong root dir when -c is passed
2021-04-16 14:38:35 -03:00
Florian Bruhin
d2f3d40510 doc: Update open trainings (#8551) 2021-04-15 19:09:06 +02:00
Bruno Oliveira
af31c60db1 Merge pull request #8540 from hauntsaninja/assert310 2021-04-15 08:55:42 -03:00
Ran Benita
8dd64622ca Merge pull request #8538 from pytest-dev/update-plugin-list/patch-9653a0e
[automated] Update plugin list
2021-04-14 12:52:29 +03:00
Ran Benita
3c451751af Merge pull request #8542 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-django-4.2.0
Bump pytest-django from 4.1.0 to 4.2.0 in /testing/plugins_integration
2021-04-14 12:50:28 +03:00
Ran Benita
6152135c29 Merge pull request #8541 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.2
Bump django from 3.1.8 to 3.2 in /testing/plugins_integration
2021-04-14 12:50:01 +03:00
pre-commit-ci[bot]
d200598de9 [pre-commit.ci] pre-commit autoupdate (#8547)
* [pre-commit.ci] pre-commit autoupdate

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2021-04-14 12:49:09 +03:00
Albert Villanova del Moral
4b214a6049 Add tmp_path_factory methods to the docs (#8550)
* Add tmp_path_factory methods to the docs

Add the methods of tmp_path_factory to the docs.

Currently, only the class description appears in the docs.

* Add tmpdir_factory methods to the docs
2021-04-14 12:06:35 +03:00
hauntsaninja
e3dc34ee41 fixup comments 2021-04-12 11:34:14 -07:00
dependabot[bot]
22a17dba4e Bump pytest-django from 4.1.0 to 4.2.0 in /testing/plugins_integration
Bumps [pytest-django](https://github.com/pytest-dev/pytest-django) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/pytest-dev/pytest-django/releases)
- [Changelog](https://github.com/pytest-dev/pytest-django/blob/master/docs/changelog.rst)
- [Commits](https://github.com/pytest-dev/pytest-django/compare/v4.1.0...v4.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-12 03:01:33 +00:00
dependabot[bot]
e14bd4a480 Bump django from 3.1.8 to 3.2 in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.8 to 3.2.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.8...3.2)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-12 03:01:30 +00:00
pre-commit-ci[bot]
da66f00413 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-04-11 22:44:33 +00:00
hauntsaninja
8be1628042 Fix assertion rewriting on Python 3.10
Fixes https://github.com/pytest-dev/pytest/issues/8539

This seems to have been the result of https://bugs.python.org/issue43798
2021-04-11 15:42:42 -07:00
pytest bot
67d61e56e9 [automated] Update plugin list 2021-04-11 00:20:34 +00:00
Ran Benita
9653a0e9f4 Merge pull request #8531 from pytest-dev/graingert-patch-1
fix pytest 6.2.3 #8414 changelog entry grammar
2021-04-10 19:05:19 +03:00
Bruno Oliveira
047c9603f6 Merge pull request #8535 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.8
Bump django from 3.1.7 to 3.1.8 in /testing/plugins_integration
2021-04-08 22:15:45 -03:00
Daniele Procida
70daa279a7 Further rationalised "how to invoke pytest" material. (#8536)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-04-08 21:19:30 -03:00
dependabot[bot]
207c07285f Bump django from 3.1.7 to 3.1.8 in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.7 to 3.1.8.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.7...3.1.8)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-08 20:05:44 +00:00
Thomas Grainger
97a61916a6 fix pytest 6.2.3 #8414 changelog entry grammar 2021-04-08 15:40:58 +01:00
Ronny Pfannschmidt
41a90cd9fe Merge pull request #8463 from RonnyPfannschmidt/workaround-8361
address #8361 - introduce hook caller wrappers that enable backward compat
2021-04-05 22:50:31 +02:00
Tadeu Manoel
b706a2c048 Fix error with --import-mode=importlib and modules containing dataclasses or pickle (#7870)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Fixes #7856, fixes #7859
2021-04-05 17:10:03 -03:00
Anthony Sottile
366c36a168 Merge pull request #8522 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-04-05 10:52:33 -07:00
pre-commit-ci[bot]
0b299044d1 [pre-commit.ci] pre-commit autoupdate 2021-04-05 17:10:40 +00:00
Ran Benita
43b547a1cb Merge pull request #8521 from pytest-dev/update-plugin-list/patch-07c6b3f
[automated] Update plugin list
2021-04-04 13:40:37 +03:00
Ran Benita
00f4cfe403 Merge pull request #8520 from bluetech/cherry-pick-release
Cherry pick 6.2.3 release notes
2021-04-04 13:40:18 +03:00
pytest bot
f3337c1854 [automated] Update plugin list 2021-04-04 00:19:23 +00:00
Ran Benita
5d2fad5362 Merge pull request #8519 from pytest-dev/release-6.2.3
Prepare release 6.2.3

(cherry picked from commit 724e22cb00)
2021-04-04 01:08:26 +03:00
Ran Benita
07c6b3fb21 Merge pull request #8516 from bluetech/mktmp
Fix minor temporary directory security issue
2021-04-04 00:33:53 +03:00
Ran Benita
c49100cef8 tmpdir: prevent using a non-private root temp directory
pytest uses a root temp directory named `/tmp/pytest-of-<username>`. The
name is predictable, and the directory might already exists from a
previous run, so that's allowed.

This makes it possible for my_user to pre-create
`/tmp/pytest-of-another_user`, thus giving my_user control of
another_user's tempdir.

Prevent this scenario by adding a couple of safety checks. I believe
they are sufficient.

Testing the first check requires changing the owner, which requires
root permissions, so can't be unit-tested easily, but I checked it
manually.
2021-04-03 23:42:53 +03:00
Ran Benita
1278f8b97e tmpdir: fix temporary directories created with world-readable permissions
(Written for a Unix system, but might be applicable to Windows as well).

pytest creates a root temporary directory under /tmp, named
`pytest-of-<username>`, and creates tmp_path's and other under it.
/tmp is shared between all users of the system.

This root temporary directory was created with 0o777&~umask permissions,
which usually becomes 0o755, meaning any user in the system could list
and read the files, which is undesirable.

Use 0o700 permissions instead. Also for subdirectories, because the root
dir is adjustable.
2021-04-03 23:42:53 +03:00
Ran Benita
0dd1e5b4f4 pathlib: inline ensure_reset_dir()
This is only used in TempPathFactory.getbasetemp(). We'll be wanting
further control/care there, so move it into there.
2021-04-03 23:42:53 +03:00
Ran Benita
78122a5304 pathlib: remove useless temporary variable 2021-04-03 23:42:53 +03:00
Ronny Pfannschmidt
aa10bff750 fix deprecation test for path/fspath hook args 2021-04-03 14:51:36 +02:00
Ronny Pfannschmidt
53ebe34ca2 Apply suggestions from code review
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-04-03 12:46:50 +02:00
Ronny Pfannschmidt
deb5b5bd96 fix #8371: fix stack-level 2021-04-02 00:58:05 +02:00
Ronny Pfannschmidt
9c151a65c8 Merge pull request #8503 from pytest-dev/require_setuptools
monkeypatch.syspath_prepend: Skip fixup_namespace_packages if pkg_resources not imported
2021-04-01 21:49:29 +02:00
Miro Hrončok
778d2b2499 monkeypatch.syspath_prepend: Skip fixup_namespace_packages if pkg_resources not imported
Calling pkg_resources.fixup_namespace_packages() is only needed for packages
that use pkg_resources.declare_namespace() and hence they already imported
pkg_resources. When pkg_resources is not imported, we don't need to use it.

This avoids an unneeded runtime dependency on setuptools.
The code is tested by test_syspath_prepend_with_namespace_packages,
behavior should remain unchanged, hence no new test was added.

When people drop pkg_resources from sys.modules, they are on their own.
If someone has a actual use case making this valid to support,
they can come in and provide a test, a reference and a fix.
2021-04-01 20:24:21 +02:00
Mehera Emrich
0061ec5555 Fix typo (#8504) 2021-04-01 15:13:12 +02:00
Bruno Oliveira
b96e229c95 Fix plugin-list label in the docs (#8505)
Last time I "fixed" this I left a `\` at the start of the string
to avoid an initial newline, but didn't realize it was a raw string.

This should fix it now for good.
2021-04-01 15:12:46 +02:00
Ronny Pfannschmidt
bad1963697 fix #8361: address review/quality comments 2021-03-29 22:29:35 +02:00
Bruno Oliveira
ca4a7a085e Merge pull request #8496 from pytest-dev/update-plugin-list/patch-9052a9e
[automated] Update plugin list
2021-03-27 22:53:43 -03:00
pytest bot
bfdfab00dd [automated] Update plugin list 2021-03-28 00:18:38 +00:00
Ronny Pfannschmidt
9052a9e313 Merge pull request #8462 from RonnyPfannschmidt/main_fixup_followup
port the rest of the scripts/docs over to the main branch
2021-03-27 15:49:20 +01:00
Bruno Oliveira
c1bdff9e69 Merge pull request #8494 from nicoddemus/python-3.10 2021-03-27 11:32:31 -03:00
Bruno Oliveira
a7416a535a Add classifier for Python 3.10 and CHANGELOG entry 2021-03-27 11:13:16 -03:00
Bruno Oliveira
913cffa45f Add warnings filter for disutils deprecation
Deprecated in 3.10, scheduled for removal in 3.12
2021-03-27 11:13:16 -03:00
Bruno Oliveira
b2954e85d6 Adjust message for Python 3.10
Now the message includes the class name ("Skip.__init__() got multiple...").
2021-03-27 11:13:16 -03:00
Bruno Oliveira
878a51ef53 Merge pull request #8493 from pytest-dev/docs-fix
tweak documentation of report's sections attribute
2021-03-26 07:47:38 -03:00
Bruno Oliveira
d9f4cedf17 Merge pull request #8472 from bluetech/rm-unnecessary-py-path-4
testing: stop relying on comparing to py.path in fnmatcher tests
2021-03-26 07:43:37 -03:00
Bruno Oliveira
8c65a4f174 Configure support for Python 3.10 2021-03-26 07:33:24 -03:00
Bruno Oliveira
ddbc00d61e Merge pull request #8391 from nicoddemus/ellipsis-verbose-6682
Increase truncation threshold with -v, disable with -vv
2021-03-26 07:29:36 -03:00
Bruno Oliveira
c1e057065c Fix plugin-list label and script
This was changed during the current docs restructing and
we missed that it changed the label.
2021-03-26 07:13:52 -03:00
Bruno Oliveira
be8d63e33b Increase truncation threshold with -v, disable with -vv
Fix #6682
Fix #8403
2021-03-26 07:05:30 -03:00
Bruno Oliveira
9e8a6b6eeb Merge pull request #8477 from evildmp/evolutionary-documentation-restructure 2021-03-26 06:32:26 -03:00
wim glenn
76ab94e4a0 fix some bunk formatting in the CollectReport, and reword the description of the 'sections' attribute 2021-03-25 22:25:19 -05:00
Bruno Oliveira
8d21df0dc6 Merge pull request #8473 from pytest-dev/update-plugin-list/patch-35df3e6
[automated] Update plugin list
2021-03-25 17:36:25 -03:00
Bruno Oliveira
7dfaaa1e16 Merge pull request #8476 from symonk/cmdline-main-docs
Remove note on conftest.py files as part of pytest_cmdline_main hookspec
2021-03-25 17:23:24 -03:00
pre-commit-ci[bot]
f28421cc70 [pre-commit.ci] pre-commit autoupdate (#8480)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-03-23 19:05:19 +00:00
Daniele Procida
a7d528e058 Restructured 'How to invoke pytest' guide 2021-03-22 22:47:13 +00:00
Simon K
a6cf0a0a0e rename master to main in PULL_REQUEST_TEMPLATE.md (#8481) 2021-03-22 22:06:46 +00:00
Florian Bruhin
bc055e8e69 Fix required_plugins with prereleases (#8469)
* Fix required_plugins with prereleases

Fixes #8456

* Fix existing tests

* Update changelog/8456.bugfix.rst

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-03-21 22:51:12 +01:00
symonk
42ece0ca81 remove conftest note on pytest_cmdline_main, the hook is invoked 2021-03-21 20:06:18 +00:00
pytest bot
3add1a4d0f [automated] Update plugin list 2021-03-21 00:50:28 +00:00
Ronny Pfannschmidt
7ac7610089 add tresting for implication 2021-03-20 23:44:36 +01:00
Ronny Pfannschmidt
4ddf6c647c test warnings and fix invocation bugs 2021-03-20 23:39:38 +01:00
Ronny Pfannschmidt
2994022753 reshape typing for hook invocation proxying 2021-03-20 23:02:03 +01:00
Ronny Pfannschmidt
a550db4b6c drop internal py.path.local objects from hook calls 2021-03-20 21:50:40 +01:00
Ran Benita
945cc0b5a1 testing: stop relying on comparing to py.path in fnmatcher tests 2021-03-20 21:58:45 +02:00
Ronny Pfannschmidt
30f1b81eb2 address #8361 - introduce hook caller wrappers that enable backward compat 2021-03-18 23:08:03 +01:00
Ronny Pfannschmidt
ff6d5ae278 port the rest of the scripts/docs over to the main branch 2021-03-18 22:13:12 +01:00
Bruno Oliveira
35df3e68d5 Merge pull request #8459 from bluetech/unnecessary-py-path-3 2021-03-18 09:05:45 -03:00
Jürgen Gmach
fb481c7e6f fix typo (#8460) 2021-03-18 12:34:01 +01:00
Ran Benita
4690e4c510 reports: support any PathLike instead of only Path, py.path
The goal is to avoid referring to the legacy py.path.
2021-03-18 10:23:48 +02:00
Ran Benita
202dd9f423 pytester: add & use our own copytree instead of py.path's
Fixes the TODO note.
2021-03-18 10:23:48 +02:00
Ran Benita
ccdadb64ea main: add Session.startpath, make Session.startdir a property that can be deprecated
Same as in Config.
2021-03-18 10:23:48 +02:00
Ran Benita
6a174afdfe terminal: move startdir attribute to a property that can be deprecated
Same as in Config.
2021-03-18 10:23:48 +02:00
Ran Benita
e515264eb1 Remove yet more unnecessary py.path uses 2021-03-18 10:23:48 +02:00
Ran Benita
fe215bda6b Merge pull request #8446 from bluetech/unnecessary-py-path-2
More py.path removal work
2021-03-18 10:20:59 +02:00
Ran Benita
f7efb9a01c Merge pull request #8455 from evildmp/evolutionary-documentation-restructure
Explicitly listed the four documentation sections on index.rst
2021-03-18 09:52:31 +02:00
Ronny Pfannschmidt
6071b2c647 Merge pull request #8449 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-17 15:09:46 +01:00
Kale Kundert
dd3709718d Merge pull request #8453 from encukou/rel-error-message
Fix value in error message about negative relative tolerance
2021-03-16 16:43:31 -04:00
Daniele Procida
6ab461f460 Explicitly listed the four documentation sections on index.rst 2021-03-16 20:26:05 +00:00
pre-commit-ci[bot]
da4abd1c82 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-03-16 19:10:55 +00:00
Petr Viktorin
43b451e95e Add tests for the error message 2021-03-16 20:09:17 +01:00
Petr Viktorin
1f131afb07 Fix value in error message about negative relative tolerance 2021-03-16 18:54:52 +01:00
Bruno Oliveira
2ce446a75f Merge pull request #8451 from evildmp/evolutionary-documentation-restructure 2021-03-16 10:52:49 -03:00
Daniele Procida
7781582d52 Restructured global TOC
* Changed "Table Of Contents" link to a plain heading.
* Removed Customize, API Reference, 3rd party plugins links altogether.
* Added an "About the project" heading
2021-03-15 23:20:55 +00:00
Daniele Procida
c83b05af6b Merge remote-tracking branch 'origin/main' into evolutionary-documentation-restructure 2021-03-15 22:28:50 +00:00
pre-commit-ci[bot]
584fd0f387 [pre-commit.ci] pre-commit autoupdate 2021-03-15 17:01:35 +00:00
Ran Benita
f0c7043138 Remove/replace some more unnecessary uses of py.path 2021-03-15 10:39:44 +02:00
Ran Benita
a03ee02817 config: make collect_ignore accept any PathLike
The main reason is to remove a reference to `py.path`.
2021-03-15 10:39:32 +02:00
Ran Benita
b26d1bb18f cacheprovider: add cache.mkdir() as a Path-returning replacement to makedir()
It is not possible to change a return type in a compatible way, so a new
method is added.
2021-03-15 10:39:31 +02:00
Daniele Procida
2641761c1c Merge pull request #8441 from evildmp/evolutionary-documentation-restructure
Moved more sections from reference to how-to.
2021-03-15 10:22:11 +02:00
Daniele Procida
64107be443 Amended plugin list script for moved file. 2021-03-14 22:44:20 +00:00
Daniele Procida
d171a3f52d Moved more sections from reference to how-to.
* re-ordered and grouped how-to guides in how-to landing page
* retitled moved documents appropriately
* separated writing plugins/writing hook functions into two documents
2021-03-14 19:33:43 +00:00
Ran Benita
63bc49de70 Merge pull request #8440 from bluetech/unnecessary-py-path
Remove/replace some unneeded usages of py.path
2021-03-14 15:56:07 +02:00
Ran Benita
59251e8a2a Remove/replace some unneeded usages of py.path 2021-03-14 14:12:28 +02:00
Bruno Oliveira
cdbeb03aef Merge pull request #8442 from pytest-dev/update-plugin-list/patch-ba0193a
[automated] Update plugin list
2021-03-14 07:18:15 -03:00
pytest bot
493b54e21e [automated] Update plugin list 2021-03-14 00:49:15 +00:00
Ran Benita
ba0193ad06 Merge pull request #8439 from bluetech/doc-tmpdir-reduce
doc/tmpdir: significantly reduce space dedicated to tmpdir/tmpdir_factory
2021-03-13 21:35:00 +02:00
Ran Benita
3075078498 Merge pull request #8438 from bluetech/setuptools-dash-deprecation
setup.cfg: fix setuptools dash-separator warnings
2021-03-13 20:56:13 +02:00
Ran Benita
ba7bd3d77c doc/tmpdir: significantly reduce space dedicated to tmpdir/tmpdir_factory
Emphasize tmp_path/tmp_path_factory and just note the legacy ones.
2021-03-13 20:44:23 +02:00
Ran Benita
8c350b9837 setup.cfg: fix setuptools dash-separator warnings
Warnings like this:

python3.9/site-packages/setuptools/dist.py:634: UserWarning: Usage of
dash-separated 'upload-dir' will not be supported in future versions.
Please use the underscore name 'upload_dir' instead
2021-03-13 20:30:24 +02:00
Bruno Oliveira
ef1308c23b Merge pull request #8407 from nicoddemus/type-annotations-description-8405
Add type annotations to the description instead of signature
2021-03-13 14:46:37 -03:00
Ran Benita
db539ed2b0 Merge pull request #8437 from bluetech/rm-typevar-prefix
Remove `_` prefix from TypeVars, expose ExceptionInfo
2021-03-13 19:01:29 +02:00
Bruno Oliveira
9fa6673222 Merge pull request #8434 from evildmp/evolutionary-documentation-restructure 2021-03-13 12:50:45 -03:00
Pierre Mourlanne
af9f27a874 Approx decimal sequence mapping (#8422) 2021-03-13 16:01:23 +02:00
Ran Benita
f2d65c85f4 code: export ExceptionInfo for typing purposes
This type is most prominent in `pytest.raises` and we should allow to
refer to it by a public name.

The type is not in a perfectly "exposable" state. In particular:

- The `traceback` property with type `Traceback` which is derived from
  the `py.code` API and exposes a bunch more types transitively. This
  stuff is *not* exported and probably won't be.

- The `getrepr` method which probably should be private.

But they're already used in the wild so no point in just hiding them
now.

The __init__ API is hidden -- the public API for this are the `from_*`
classmethods.
2021-03-13 15:59:44 +02:00
Ran Benita
96ef7d678b code: fix outdated reference in ExceptionInfo.exconly docstring
No such thing as `_pytest._code.AssertionError`, it's just the built-in
`AssertionError`.
2021-03-13 14:44:50 +02:00
Ran Benita
5bbfb4e058 Remove _ prefix from TypeVars which appear in public API
The prefixes make the API Reference docs (for e.g. `pytest.raises`,
`pytest.fixture`) uglier.

Being under `_pytest` is sufficient from a privacy perspective, so let's
drop them.
2021-03-13 14:44:50 +02:00
Daniele Procida
dd576509e1 Merge branch 'main' into evolutionary-documentation-restructure 2021-03-13 12:09:36 +00:00
Bruno Oliveira
146eda93e7 Merge pull request #8436 from pytest-dev/doc-fix-toc
doc: fix broken links in left-hand TOC
2021-03-13 08:24:35 -03:00
Ran Benita
639c4e64a1 doc: fix broken links in left-hand TOC
Due to recent renamings.
2021-03-13 12:44:30 +02:00
Daniele Procida
843e9eac2c Added myself to AUTHORS 2021-03-12 23:14:18 +00:00
Daniele Procida
8410d9ac54 Created a new Explanation section and new landing pages for main sections.
Added landing pages for:

How-to guides
Reference guides
Explanation

Added links to the main landing pages to the sidebar.
2021-03-12 22:57:53 +00:00
Daniele Procida
ff2ee96b8c Split fixtures documentation into separate documents.
Sections have been moved to:

* reference/fixtures.rst
* how-to/fixtures.rst
* fixtures.rst

according to their function. Further refinement and rewriting will be required.

Some material has been moved to a new "Anatomy of a test" document, in
anticipation that material from other sections will also find a natural
home there later.

Removed several unneeded reference targets from fixtures documentation.
2021-03-12 22:16:47 +00:00
Bruno Oliveira
32ad70dea8 Merge pull request #8433 from evildmp/evolutionary-documentation-restructure
Added how-to and reference directories.
2021-03-11 19:26:09 -03:00
Daniele Procida
d8695410a4 Added how-to and reference directories.
Moved various documents into subdirectories, how-to and
reference.

Updated multiple links to use `:ref:` instead of `:doc:`,
meaning that files can henceforth be moved around without
breaking references.
2021-03-11 22:13:01 +00:00
Bruno Oliveira
4b7edef08f Merge pull request #8431 from evildmp/evolutionary-documentation-restructure
Moved documentation topics to group them by theme.
2021-03-11 16:32:16 -03:00
Daniele Procida
a362200d47 Moved documentation topics to group them by theme.
Reordered items in:

* _templates/globaltoc.html
* contents.rst
2021-03-11 17:22:54 +00:00
Ran Benita
2a789b9e3a Merge pull request #8409 from pytest-dev/update-plugin-list/patch-620e819
[automated] Update plugin list
2021-03-11 18:26:12 +02:00
Ran Benita
c9867bcc9d Merge pull request #8416 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-11 09:17:40 +02:00
Ran Benita
ce2ad8ebd4 Merge pull request #8430 from evildmp/evolutionary-documentation-restructure
Renamed Install to Getting started; moved notes to index.
2021-03-11 09:17:03 +02:00
Daniele Procida
d2d975d6cf Reworded titles of some clear how-to guides
Files retitled:

assert.rst
bash-completion.rst
capture.rst
existingtestsuite.rst
mark.rst
monkeypatch.rst
nose.rst
parametrize.rst
plugins.rst
skipping.rst
tmpdir.rst
usage.rst
2021-03-10 20:26:06 +00:00
Daniele Procida
4a19533ba5 Renamed Install to Getting started; moved notes to index 2021-03-10 19:20:32 +00:00
Ronny Pfannschmidt
bfbf733a3e Merge pull request #8425 from RonnyPfannschmidt/main-fixes
reconfigure everything for main
2021-03-09 22:54:01 +01:00
Ronny Pfannschmidt
dbed1ff68f adopt main terminology in the configs
ref pytest-dev/meta#8
2021-03-09 22:35:34 +01:00
Anthony Sottile
38d8deb74d Merge pull request #8419 from pytest-dev/all-repos_autofix_all-repos-manual
clean up mkdtemp usage
2021-03-09 07:04:32 -08:00
Anthony Sottile
7a6ec5616d clean up mkdtemp usage
Committed via https://github.com/asottile/all-repos
2021-03-08 19:12:08 -08:00
pre-commit-ci[bot]
ddde3266c6 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-03-08 16:55:59 +00:00
pre-commit-ci[bot]
125633728f [pre-commit.ci] pre-commit autoupdate 2021-03-08 16:54:31 +00:00
Anthony Sottile
79b03ce8db Merge pull request #8411 from RonnyPfannschmidt/example-outcomes-check
fix bug in test for issue 519
2021-03-07 08:17:34 -08:00
Bruno Oliveira
fc651fb158 Merge pull request #8251 from RonnyPfannschmidt/pathlib-node-path 2021-03-07 11:10:07 -03:00
Ronny Pfannschmidt
412fc001a0 fix bug in test for issue 519
assert the actual outcome and fix the filename
2021-03-07 15:01:39 +01:00
pytest bot
f0ad73c4b0 [automated] Update plugin list 2021-03-07 00:48:50 +00:00
Florian Bruhin
620e819656 Add enterPy training (#8396) 2021-03-06 22:59:33 +01:00
Ronny Pfannschmidt
77cb110258 drop usage of py.path.local calls
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-03-06 21:32:03 +01:00
Ronny Pfannschmidt
22dad53a24 implement Node.path as pathlib.Path
* reorganize lastfailed node sort

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-03-06 21:32:03 +01:00
Bruno Oliveira
7c792e96c6 Add type annotations to the description instead of signature
This configures Sphinx autodoc to include the type annotations
along with the description of the function/method, instead of including
it into the signature.

Fix #8405
2021-03-05 22:22:53 -03:00
Alexandros Tzannes
19a2f7425d Merge pull request #8399 from atzannes/master
closes #8394

Generated fixture names for unittest/xunit/nose should start with underscore
2021-03-04 22:45:57 +02:00
Ran Benita
6e7dc8bac8 Merge pull request #8357 from matthewhughes934/remove-tmpdir-from-tests
Remove tmpdir from tests
2021-03-04 18:34:19 +02:00
Florian Bruhin
c14a9adba3 Fix skip signature (#8392)
* Fix test_strict_and_skip

The `--strict` argument was removed in #2552, but the removal wasn't
actually correct - see #1472.

* Fix argument handling in pytest.mark.skip

See #8384

* Raise from None

* Fix test name
2021-03-04 11:56:21 +01:00
Bruno Oliveira
4dbb29431a Merge pull request #8385 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-03-02 17:33:55 -03:00
Bruno Oliveira
bc0af99e5e Merge pull request #8383 from pytest-dev/dependabot/pip/testing/plugins_integration/twisted-21.2.0
build(deps): bump twisted from 20.3.0 to 21.2.0 in /testing/plugins_integration
2021-03-02 17:33:35 -03:00
Bruno Oliveira
284b9dba9d Merge pull request #8382 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--2.2.0
build(deps): bump anyio[curio,trio] from 2.1.0 to 2.2.0 in /testing/plugins_integration
2021-03-02 17:33:09 -03:00
pre-commit-ci[bot]
decca74788 [pre-commit.ci] pre-commit autoupdate 2021-03-01 16:53:28 +00:00
dependabot[bot]
897b5a3bd6 build(deps): bump twisted in /testing/plugins_integration
Bumps [twisted](https://github.com/twisted/twisted) from 20.3.0 to 21.2.0.
- [Release notes](https://github.com/twisted/twisted/releases)
- [Changelog](https://github.com/twisted/twisted/blob/twisted-21.2.0/NEWS.rst)
- [Commits](https://github.com/twisted/twisted/compare/twisted-20.3.0...twisted-21.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 03:02:50 +00:00
dependabot[bot]
62ef875796 build(deps): bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/2.1.0...2.2.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-01 03:02:48 +00:00
Bruno Oliveira
cd783eba03 Merge pull request #8376 from pytest-dev/update-plugin-list/patch-22c0dac
[automated] Update plugin list
2021-02-28 07:55:43 -03:00
pytest bot
a623b1b086 [automated] Update plugin list 2021-02-28 00:48:46 +00:00
Simon K
22c0dace3b change istestfunction to callable() (#8374) 2021-02-25 20:32:27 +00:00
Simon K
b7f2d7ca61 Fixed an issue where getpass.getuser() contained illegal characters for file directories (#8365)
* retry writing pytest-of dir when invalid chars are in directory name

* add unit tests for getbasetemp() and changelog

* patch _basetemp & _given_basetemp for testing basetemp()

* Tweak changelog for #8317, tidy up comments
2021-02-25 08:28:57 +00:00
Matthew Hughes
514f8e0680 fixup! Rename variables 'tmpdir'->'tmp_path' 2021-02-24 20:55:35 +00:00
Bruno Oliveira
bbea18d7f9 Merge pull request #8367 from The-Compiler/class-fromparent-kw 2021-02-23 16:25:14 -03:00
Bruno Oliveira
690fb26ec7 Merge pull request #8368 from The-Compiler/fromparent-changelog
Fix typo in changelog
2021-02-23 16:24:24 -03:00
Florian Bruhin
9d09d19911 Fix typo in changelog
See #7143
2021-02-23 18:03:10 +01:00
pre-commit-ci[bot]
3b7fc2c9c8 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2021-02-23 17:02:50 +00:00
Florian Bruhin
54a154c86f Allow Class.from_parent to forward custom parameters to the constructor
Similarly to #7143, at work we have a project with a custom pytest.Class
subclass, adding an additional argument to the constructor.

All from_parent implementations in pytest accept and forward *kw, except
Class (before this change) and DoctestItem - since I'm not familiar with
doctest support, I've left the latter as-is.
2021-02-23 18:00:56 +01:00
Bruno Oliveira
d6522b517b Merge pull request #8364 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-22 18:36:43 -03:00
Bruno Oliveira
d37fe13af5 Merge pull request #8362 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.7
build(deps): bump django from 3.1.6 to 3.1.7 in /testing/plugins_integration
2021-02-22 17:36:58 -03:00
Bruno Oliveira
d76f7b3039 Merge pull request #8359 from pytest-dev/update-plugin-list/patch-4964b46
[automated] Update plugin list
2021-02-22 17:34:40 -03:00
pre-commit-ci[bot]
e503e27579 [pre-commit.ci] pre-commit autoupdate 2021-02-22 17:04:30 +00:00
dependabot[bot]
060cbef260 build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.6 to 3.1.7.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.6...3.1.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-22 03:01:27 +00:00
Matthew Hughes
c9bb4c418f fixup! Rename variables 'tmpdir'->'tmp_path'
* Add some more of these
* Also reintroduce+rename instances of fixture usages that were
'tmpdir'->'tmp_path'
2021-02-21 13:10:07 +00:00
pytest bot
56421aed01 [automated] Update plugin list 2021-02-21 00:46:01 +00:00
Matthew Hughes
09d4c5e30a Rename variables 'tmpdir'->'tmp_path'
Rename this variables reflecting the migrations made with 3bcd316f0 and
ed658d682
2021-02-20 18:24:58 +00:00
Matthew Hughes
0e5e4e03e6 Remove some unused 'tmpdir's 2021-02-20 18:01:42 +00:00
Ran Benita
4964b468c8 Merge pull request #8354 from feanil/patch-1
Remove a redundant paragraph
2021-02-20 17:19:54 +02:00
Feanil Patel
e6012612b9 Remove a redundant paragraph
doc This paragraph looks like it is a more verbose version of the sentence right above it.  Removing it doesn't reduce the amount of information here but does make the section flow a little better.
2021-02-19 13:46:29 -05:00
Ran Benita
a44dcf5ece Merge pull request #8351 from vpoulailleau/patch-1
Update number of plugins
2021-02-18 17:28:44 +02:00
Vincent Poulailleau
565fe0fb7d Update number of plugins
According to the source, there are 801 plugins now!
2021-02-18 15:27:39 +01:00
Bruno Oliveira
c9d623971a Merge pull request #8349 from maskypy40/patch-1
Removes 2 empty lines from example code
2021-02-18 08:16:54 -03:00
maskypy40
532543b4ef Remove empty lines from code-block
In assert.rst at line 175 and further there is an example of an assert encountering comparisons. The code-block for this example starts with a comment (line 177)  and then it has 2 empty lines. Comparing this example code (test_assert2.py) with the previously mentioned example code on the same page (i.e. test_assert1.py) you can see that there should not be 2 empty lines after the comment. These 2 empty lines are removed.
2021-02-17 09:33:04 +01:00
Ran Benita
ab2eb94054 Merge pull request #8345 from pytest-dev/update-plugin-list/patch-16e21c2
[automated] Update plugin list
2021-02-15 15:08:17 +02:00
pytest bot
a0ae5fd652 [automated] Update plugin list 2021-02-14 00:45:06 +00:00
Bruno Oliveira
16e21c22a3 Merge pull request #8336 from sbellem/typos/setup.cfg
Remove duplicate '>=' in setup.cfg
2021-02-11 07:53:02 -03:00
Sylvain Bellemare
3d831225bb Remove duplicate '>=' in setup.cfg 2021-02-10 22:17:39 +00:00
Anthony Sottile
92959fe236 Merge pull request #8329 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-08 09:38:02 -08:00
pre-commit-ci[bot]
6432fc2302 [pre-commit.ci] pre-commit autoupdate 2021-02-08 16:50:48 +00:00
Ran Benita
1003beaffa Merge pull request #8323 from bluetech/setupstate-refactor-3
runner: a few more tweaks to SetupState
2021-02-08 13:56:04 +02:00
Bruno Oliveira
f85427b92a Merge pull request #8326 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.6
build(deps): bump django from 3.1.5 to 3.1.6 in /testing/plugins_integration
2021-02-08 08:09:23 -03:00
Bruno Oliveira
e9d554c5f5 Merge pull request #8324 from pytest-dev/update-plugin-list/patch-bcfe253
[automated] Update plugin list
2021-02-08 08:04:16 -03:00
Bruno Oliveira
7b91302b33 Merge branch 'master' into dependabot/pip/testing/plugins_integration/django-3.1.6 2021-02-08 08:03:23 -03:00
Bruno Oliveira
ee5afb2a8f Merge pull request #8325 from pytest-dev/dependabot/pip/testing/plugins_integration/anyio-curiotrio--2.1.0
build(deps): bump anyio[curio,trio] from 2.0.2 to 2.1.0 in /testing/plugins_integration
2021-02-08 08:02:41 -03:00
dependabot[bot]
ef14f286a3 build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.5 to 3.1.6.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.5...3.1.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-08 03:02:01 +00:00
dependabot[bot]
e8d7a7b843 build(deps): bump anyio[curio,trio] in /testing/plugins_integration
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 2.0.2 to 2.1.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/2.0.2...2.1.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-08 03:01:58 +00:00
Ronny Pfannschmidt
325d701f6e Merge pull request #8248 from RonnyPfannschmidt/mixin-mro-position
alter the PyObjMixin to carry over typing information from Node
2021-02-07 18:44:44 +01:00
pytest bot
3c6bd7eb27 [automated] Update plugin list 2021-02-07 00:44:13 +00:00
Ran Benita
5822888d73 runner: add clarifying comments on why runtestprotocol re-inits the FixtureRequest 2021-02-06 20:46:08 +02:00
Ran Benita
f42b68ccaa runner: rename SetupState.prepare -> setup
This is the usual terminology we use, and matches better with
`teardown_exact()` and `pytest_runtest_setup()`.
2021-02-06 20:46:08 +02:00
Ran Benita
f674f6da9f runner: add a safety assert to SetupState.prepare
This ensures that the teardown for the previous item was done properly
for this (next) item, i.e. there are no leftover teardowns.
2021-02-06 20:46:08 +02:00
Pax
bcfe253f5b Type annotation for request.param (#8319) 2021-02-05 22:03:58 +02:00
Bruno Oliveira
150bdceb7a Merge pull request #8322 from pytest-dev/fixture-docs
doc: Remove confusing fixture sentence
2021-02-05 15:11:17 -03:00
Florian Bruhin
c604f3f0c5 doc: Remove confusing fixture sentence
There is no previous `test_ehlo` example (it follows much later) - and the same thing is described further down in ""Requesting" fixtures" already.
2021-02-05 17:47:37 +01:00
Bruno Oliveira
ed8cabe4fd Merge pull request #8320 from nicoddemus/change-update-plugins-cron
Update plugin-list every Sunday instead of everyday
2021-02-05 07:48:31 -03:00
Bruno Oliveira
e3c0fd3203 Update plugin-list every Sunday instead of everyday
Every day seems a bit excessive lately, let's make it less frequent.
2021-02-05 07:29:12 -03:00
Bruno Oliveira
375e95180c Merge pull request #8318 from pytest-dev/update-plugin-list/patch-b3115c1
[automated] Update plugin list
2021-02-04 23:10:54 -03:00
pytest bot
16af1a31fd [automated] Update plugin list 2021-02-05 00:24:50 +00:00
Ran Benita
b3115c1b06 Merge pull request #8315 from bluetech/parser-proper-deprecation
config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
2021-02-05 00:37:38 +02:00
Ran Benita
d358a060ad config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
Proper for removing this in the next major pytest release.
2021-02-05 00:05:47 +02:00
Hong Xu
80c223474c Type annotation polishing for symbols around Pytester.run (#8298)
* Type annotation polishing for symbols around Pytester.run

Hopefully these will help document readers understand pertinent methods
and constants better.

Following up #8294

* Use NOTSET instead of object
2021-02-04 23:44:22 +02:00
Bruno Oliveira
bebb6953eb Merge pull request #8312 from matthewhughes934/add-regendoc-runs-for-fixture-docs 2021-02-04 15:50:48 -03:00
Matthew Hughes
709c211e68 Run regendoc over fixture docs
This is the result of running:

    $ cd doc/en && make regen REGENDOC_FILES=fixture.rst
2021-02-04 18:32:52 +00:00
Matthew Hughes
97cfd66806 Add regendoc runs for emaillib tests in fixture
Also update these tests ensure they pass, and be explicit about the test
file called in an existing test to avoid unintentional calls to the
added tests
2021-02-04 18:32:28 +00:00
Bruno Oliveira
287bab09a4 Merge pull request #8314 from pytest-dev/update-plugin-list/patch-275174e
[automated] Update plugin list
2021-02-04 11:54:29 -03:00
Bruno Oliveira
7c622d7462 Merge pull request #8316 from The-Compiler/training-update
doc: Remove past training
2021-02-04 10:02:02 -03:00
Florian Bruhin
b77f071bef doc: Remove past training 2021-02-04 11:40:28 +01:00
Ran Benita
3907856cb3 Merge pull request #8297 from pytest-dev/monkeypatch-docs
doc: Point out two-argument form of monkeypatch.setattr
2021-02-04 10:13:27 +02:00
pytest bot
1d895dd46c [automated] Update plugin list 2021-02-04 00:26:06 +00:00
Matthew Hughes
298541f540 Add basic emaillib for tests in fixture.rst
This will be used to power regendoc runs for later tests
2021-02-03 13:14:31 +00:00
Matthew Hughes
100c8deab5 Fix various typos in fixture docs 2021-02-03 13:14:31 +00:00
Bruno Oliveira
275174e147 Merge pull request #8308 from pytest-dev/update-plugin-list/patch-c26dddc
[automated] Update plugin list
2021-02-02 09:05:04 -03:00
Bruno Oliveira
3568df22b0 Merge pull request #8302 from pytest-dev/update-plugin-list/patch-ed8f424
[automated] Update plugin list
2021-02-02 08:43:51 -03:00
pytest bot
3165b1e323 [automated] Update plugin list 2021-02-02 00:31:11 +00:00
Bruno Oliveira
c26dddc651 Merge pull request #8306 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-02-01 17:37:14 -03:00
pre-commit-ci[bot]
1b2ca22e9b [pre-commit.ci] pre-commit autoupdate 2021-02-01 16:49:41 +00:00
pytest bot
5c61d60b0d [automated] Update plugin list 2021-02-01 00:32:44 +00:00
Ran Benita
ed8f424bcb Merge pull request #8299 from pytest-dev/update-plugin-list/patch-38a3e30
[automated] Update plugin list
2021-01-30 15:13:22 +02:00
Ran Benita
c971f2f474 ci: give pytest bot the credit for updating the plugin list 2021-01-30 13:04:10 +02:00
bluetech
de06f468ed [automated] Update plugin list 2021-01-30 00:30:28 +00:00
Florian Bruhin
f0f19aa8d9 doc: Point out two-argument form of monkeypatch.setattr
See the "for convenience" part here: https://docs.pytest.org/en/stable/reference.html#pytest.MonkeyPatch.setattr
2021-01-29 21:08:37 +01:00
Bruno Oliveira
38a3e30cd9 Merge pull request #8296 from bluetech/mypy-800-ignores
Remove some no longer needed type-ignores
2021-01-29 16:35:33 -03:00
Ran Benita
afea190797 Remove some no longer needed type-ignores 2021-01-29 20:40:43 +02:00
Hong Xu
07f0eb26b4 Doc: Clarify pytester.run (#8294)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-01-29 12:54:06 -03:00
Ran Benita
63ea727bc2 changelog: fix missing tick (#8295)
Messes with the rendering.
2021-01-29 16:21:25 +02:00
Maximilian Cosmo Sitter
beda7a8a31 Add plugin list 2021-01-29 16:19:54 +02:00
Ran Benita
0b510bcc51 changelog: fix missing tick
Messes with the rendering.
2021-01-29 16:06:36 +02:00
Bruno Oliveira
6a5d47a243 Merge pull request #8260 from nicoddemus/faulthandler-mode-X-8258 2021-01-28 13:03:24 -03:00
Bruno Oliveira
7b4ee65bdc Merge pull request #8284 from encukou/patch-1
Doc: Fix typo
2021-01-27 09:40:55 -03:00
Bruno Oliveira
0365b1be64 Merge pull request #8280 from xuhdev/module
Doc: Move the module declaration to index.rst
2021-01-27 09:05:36 -03:00
Petr Viktorin
56cea26445 Doc: Fix typo 2021-01-27 10:23:18 +01:00
Ran Benita
0939c3e022 Merge pull request #8279 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2021-01-26 11:17:58 +02:00
Hong Xu
8bb3977cb6 Doc: Move the module declaration to index.rst
When the declaration stays in reference.rst, it creates duplicated
"pytest" symbols such as `pytest.pytest.mark.filterwarnings`.
2021-01-26 00:48:01 -08:00
Bruno Oliveira
dfe933cdb4 Remove mypy workaround after 0.800 update 2021-01-25 15:23:13 -03:00
pre-commit-ci[bot]
6806091b93 [pre-commit.ci] pre-commit autoupdate 2021-01-25 16:41:17 +00:00
Bruno Oliveira
33861098d9 Only re-enable fauthandler during unconfigure if it was enabled before 2021-01-25 12:28:00 -03:00
Christian Steinmeyer
781b73bb52 Mention that class variables are shared between tests
Close #8252
2021-01-25 12:02:59 -03:00
Bruno Oliveira
f3efc4e049 Merge pull request #8277 from nicoddemus/cherry-pick-release
Merge pull request #8275 from pytest-dev/release-6.2.2
2021-01-25 12:02:49 -03:00
Bruno Oliveira
2a890286f8 Merge pull request #8275 from pytest-dev/release-6.2.2
Prepare release 6.2.2

(cherry picked from commit 8220eca963)
2021-01-25 11:53:05 -03:00
Ran Benita
fff9f28fdd Merge pull request #8272 from bluetech/setupstate-refactor-2
runner: avoid using node's store in SetupState
2021-01-25 16:00:05 +02:00
Bruno Oliveira
5cc295e74b Merge pull request #8273 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-cov-2.11.1
build(deps): bump pytest-cov from 2.10.1 to 2.11.1 in /testing/plugins_integration
2021-01-25 09:12:14 -03:00
dependabot[bot]
83ee1a1f3b build(deps): bump pytest-cov in /testing/plugins_integration
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.10.1 to 2.11.1.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.10.1...v2.11.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-25 03:16:50 +00:00
Ran Benita
48fb989a71 runner: avoid using node's store in SetupState
SetupState maintains its own state, so it can store the exception
itself, instead of using the node's store, which is better avoided when
possible.

This also reduces the lifetime of the reference-cycle-inducing exception
objects which is never a bad thing.
2021-01-24 15:05:03 +02:00
Ran Benita
d5df8f99ab Merge pull request #8219 from bluetech/setupstate-refactor
runner: refactor SetupState
2021-01-24 14:51:58 +02:00
Ran Benita
c30feeef8b runner: add docstring to SetupState and improve variable naming a bit 2021-01-24 14:29:54 +02:00
Ran Benita
0d19aff562 runner: schedule node.teardown() call already at setup
This is more elegant.
2021-01-24 14:08:39 +02:00
Ran Benita
1db78bec31 runner: use insertion-ordered dict instead of stack, dict pair
Since dicts are now ordered, we can use the finalizers dict itself as
the dict, simplifying the code.
2021-01-24 14:08:39 +02:00
Ran Benita
03c3a90c68 runner: replace setdefault with an unconditional set
The already-exists case is not supposed to happen.
2021-01-24 14:08:39 +02:00
Ran Benita
960ebae943 runner: enable a commented assertion in SetupState.addfinalizer
The assertion ensures that when `addfinalizer(finalizer, node)` is
called, the node is in the stack. This then would ensure that the
finalization is actually properly executed properly during the node's
teardown. Anything else indicates something is wrong.

Previous commits fixed all of the tests which previously failed this, so
can be reenabeld now.
2021-01-24 14:08:39 +02:00
Ran Benita
6db082a448 fixtures: make sure to properly setup stack for _fill_fixtures_impl
This code is weird, dead, deprecated and will be removed in pytest 7,
but for now some tests execute it, so fix it up in preparation for
some changes.
2021-01-24 14:08:39 +02:00
Ran Benita
637300d13d testing: fix some tests to be more realistic
Perform the operations in the order and context in which they can
legally occur.
2021-01-24 14:08:39 +02:00
Ran Benita
c83d030028 testing/test_runner: make SetupState tests use a proper SetupState
Previously the tests (probably unintentionally) mixed a fresh SetupState
and the generated item Session's SetupState, which led to some serious
head scratching when prodding it a bit.
2021-01-24 14:08:39 +02:00
Ran Benita
0d4121d24b runner: collapse exception handling in SetupState.teardown_exact()
This is equivalent but simpler.
2021-01-24 14:08:39 +02:00
Ran Benita
bb3d43c9a6 runner: ensure item.teardown() is called even if a finalizer raised
If one finalizer fails, all of the subsequent finalizers still run, so
the `teardown()` method should behave the same.
2021-01-24 14:08:39 +02:00
Ran Benita
14d71b2c22 runner: make sure SetupState._finalizers is always set for a node in the stack
This makes the stack <-> _finalizers correspondence clearer.
2021-01-24 14:08:39 +02:00
Ran Benita
d1fcd425a3 runner: inline SetupState._pop_and_teardown()
This will enable a simplification in the next commit.
2021-01-24 14:08:39 +02:00
Ran Benita
2b14edb108 runner: express SetupState.teardown_all() in terms of teardown_exact() and remove it
Makes it easier to understand with fewer methods.
2021-01-24 14:08:39 +02:00
Ran Benita
ceb4d6f6d5 runner: inline a couple of SetupState methods
Code is clearer this way.
2021-01-24 14:08:39 +02:00
Ran Benita
5f4e55fb6d runner: remove dead code in teardown_all()
When the stack is empty, the finalizers which are supposed to be
attached to nodes in the stack really ought to be empty as well. So the
code here is dead. If this doesn't happen, the assert will trigger.
2021-01-24 14:08:39 +02:00
Ran Benita
42ae8180dd runner: inline SetupState._teardown_towards()
Doesn't add much.
2021-01-24 14:08:39 +02:00
Ran Benita
410622f719 runner: reorder SetupState method to make more sense
The setup stuff happens before the teardown stuff, so put it first so
that reading the code from top to bottom makes more sense.
2021-01-24 14:08:39 +02:00
Ran Benita
f7b0b1dd1f runner: use node's Store to keep private SetupState state instead of an attribute
This way it gets proper typing and decoupling.
2021-01-24 14:08:39 +02:00
Ran Benita
da70f61f67 runner: complete type annotations of SetupState 2021-01-24 14:08:39 +02:00
Hong Xu
d4f8e4b40c Explain how to create binary files in the doc of pytest.makefile. (#8255) 2021-01-21 09:58:52 -03:00
Bruno Oliveira
adc0f29b8f Always handle faulthandler stderr even if already enabled
It seems the code that would not install pytest's faulthandler support
if it was already enabled is not really needed at all, and even detrimental
when using `python -X dev -m pytest` to run Python in "dev" mode.

Also simplified the plugin by removing the hook class, now the hooks
will always be active so there's no need to delay the hook definitions anymore.

Fix #8258
2021-01-20 10:29:05 -03:00
Bruno Oliveira
bda9ce4e0f Merge pull request #8250 from daq-tools/fix-twisted-capture 2021-01-20 09:45:58 -03:00
Jeff Widman
eef2d1a8e2 Fix pep8 import order in docs (#8253) 2021-01-19 11:45:45 -03:00
Andreas Motl
9ba1821e91 Fix faulthandler for Twisted Logger when used with "--capture=no"
The Twisted Logger will return an invalid file descriptor since it is
not backed by an FD. So, let's also forward this to the same code path
as with `pytest-xdist`.
2021-01-18 17:51:08 +01:00
Ran Benita
7f782c72ba Merge pull request #8242 from bluetech/deprecate-unittest-skip-collection
Deprecate raising unittest.SkipTest to skip tests during collection
2021-01-18 17:46:00 +02:00
Ronny Pfannschmidt
a9e43152bc alter the PyObjMixin to carry over typing information from Node
as PyObjMixin is always supposed to be mixed in the mro
before nodes.Node the behavior doesn't change,
but all the typing information carry over to help mypy.

extracted from #8037
2021-01-17 14:36:28 +01:00
Ran Benita
c9e9a599fe Merge pull request #8241 from bluetech/skip-improvements
Minor code improvements in nose, unittest, skipping
2021-01-15 15:35:57 +02:00
Ran Benita
25e657bfc1 Deprecate raising unittest.SkipTest to skip tests during collection
It is not very clear why this code exists -- we are not running any
unittest or nose code during collection, and really these frameworks
don't have the concept of collection at all, and just raising these
exceptions at e.g. the module level would cause an error. So unless I'm
missing something, I don't think anyone is using this.

Deprecate it so we can eventually clear up this code and keep unittest
more tightly restricted to its plugin.
2021-01-15 00:05:33 +02:00
Ran Benita
7f989203ed Improve way in which skip location is fixed up when skipped by mark
When `pytest.skip()` is called inside a test function, the skip location
should be reported as the line that made the call, however when
`pytest.skip()` is called by the `pytest.mark.skip` and similar
mechanisms, the location should be reported at the item's location,
because the exact location is some irrelevant internal code.

Currently the item-location case is implemented by the caller setting a
boolean key on the item's store and the `skipping` plugin checking it
and fixing up the location if needed. This is really roundabout IMO and
breaks encapsulation.

Instead, allow the caller to specify directly on the skip exception
whether to use the item's location or not. For now, this is entirely
private.
2021-01-14 18:07:25 +02:00
Ran Benita
3dde519f53 nose: type annotate with some resulting refactoring 2021-01-14 17:42:38 +02:00
Ran Benita
096bae6c68 unittest: add clarifying comment on unittest.SkipTest -> pytest.skip code
I was tempted to remove it, until I figured out why it was there.
2021-01-14 17:06:14 +02:00
Ran Benita
addbd3161e nose,fixtures: use the public item API for adding finalizers 2021-01-14 16:53:07 +02:00
Anton
42d5545f42 unittest: cleanup unexpected success handling (#8231)
* unittest: cleanup unexpected success handling

* update comment
2021-01-13 17:02:26 -08:00
Bruno Oliveira
7a5a6cb51c Merge pull request #8235 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.5
build(deps): bump django from 3.1.4 to 3.1.5 in /testing/plugins_integration
2021-01-11 08:24:47 -03:00
Bruno Oliveira
203a9b3ab2 Merge pull request #8234 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-mock-3.5.1
build(deps): bump pytest-mock from 3.4.0 to 3.5.1 in /testing/plugins_integration
2021-01-11 08:24:33 -03:00
dependabot[bot]
cfa0c3b0d9 build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.4...3.1.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 03:16:03 +00:00
dependabot[bot]
af78efc7fa build(deps): bump pytest-mock in /testing/plugins_integration
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.4.0 to 3.5.1.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.4.0...v3.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 03:15:59 +00:00
Ran Benita
f6529fd3a1 Merge pull request #8232 from imrehg/doc
Add missing import into example script in documentation
2021-01-08 14:08:47 +02:00
Gergely Imreh
80c33c8178 Add missing import into example script in documentation 2021-01-08 11:43:51 +00:00
Petr Viktorin
78fb97105f Make code.FormattedExcinfo.get_source more defensive
When line_index was a large negative number, get_source failed
on `source.lines[line_index]`.
Use the same dummy Source as with a large positive line_index.
2021-01-06 13:33:33 +01:00
Bruno Oliveira
31ae4e1764 Merge pull request #8225 from The-Compiler/training-update
doc: Add note about training early bird discount
2021-01-05 16:31:04 -03:00
Florian Bruhin
65b8391ead doc: Add note about training early bird discount 2021-01-05 19:39:50 +01:00
Bruno Oliveira
329fff69a3 Merge pull request #8220 from xuhdev/module-doc
DOC: Mark pytest module
2021-01-05 13:25:02 -03:00
Ran Benita
5336ba28cc Merge pull request #8218 from bluetech/reports2
Misc small code improvements
2021-01-04 22:47:32 +02:00
bengartner
8e00df4c4b Add dot prefix if file makefile extension is invalid for pathlib (#8222) 2021-01-04 15:58:11 +02:00
Ran Benita
8d16bec329 Merge pull request #8216 from xuhdev/testdir-pytester
DOC: Update multiple references to testdir to pytester
2021-01-02 11:58:59 +02:00
Hong Xu
14b5f5e528 DOC: Mark pytest module
Pytest document currently does not index the top-level package name
`pytest`, which causes some trouble when building documentation that
cross-refers to the pytest package via ``:mod:`pytest` ``.
2021-01-02 00:34:52 -08:00
Ran Benita
2ff88098a7 python: inline a simple method
I don't think it adds much value!
2021-01-01 23:23:08 +02:00
Ran Benita
8ee6d0a866 Always use getfixturemarker() to access _pytestfixturefunction
Keep knowledge of how the marker is stored encapsulated in one place.
2021-01-01 23:22:10 +02:00
Ran Benita
ade253c790 fixtures: type annotate FixtureRequest.keywords 2021-01-01 23:18:17 +02:00
Ran Benita
6c575ad8c8 fixtures: simplify FixtureRequest._get_fixturestack() 2021-01-01 23:15:57 +02:00
Hong Xu
b02f1c8ae7 DOC: Update multiple references to testdir to pytester
In https://docs.pytest.org/en/stable/reference.html#testdir, it is
suggested:

> New code should avoid using testdir in favor of pytester.

Multiple spots in the documents still use testdir and they can be quite
confusing (especially the plugin writing guide).
2021-01-01 12:21:39 -08:00
Ran Benita
bbd22e1769 Merge pull request #8214 from sousajf1/sousajo_patch_8204_1
pytest-dev#8204 migrate tests on testing/code/test_source to tmp_path
2021-01-01 20:44:40 +02:00
sousajo
ac428f67eb pytest-dev#8204 migrate tests on testing/code/test_source to tmp_path 2021-01-01 16:55:03 +00:00
sousajf1
20c59e3aa4 pytest-dev#8204 migrate some tests to tmp_path fixture (#8209)
migrating some tests from tmpdir to tmp_path fixture
2021-01-01 17:25:11 +02:00
Ran Benita
73c4105230 reports: improve a type annotation 2021-01-01 15:22:05 +02:00
Ran Benita
7d306e9e86 reports: BaseReport.{passed,failed,skipped} more friendly to mypy
Not smart enough to understand the previous code.
2021-01-01 15:22:05 +02:00
mefmund
5f11a35b99 Add missing fixture (#8207)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-12-31 15:25:44 -03:00
Anton
48c9a96a03 Fix failing staticmethod tests if they are inherited (#8205)
* Fix failing staticmethod tests if they are inherited

* add comments, set default=None
2020-12-30 19:00:37 -08:00
Ran Benita
7585221d55 Merge pull request #8195 from christophebedard/add-missing-space-version-option-help-message
Add missing space in '--version' help message
2020-12-30 11:57:02 +02:00
pre-commit-ci[bot]
ee03e31831 [pre-commit.ci] pre-commit autoupdate (#8201)
* [pre-commit.ci] pre-commit autoupdate

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* manual fixes after configuration update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anthony Sottile <asottile@umich.edu>
2020-12-30 11:56:09 +02:00
Ran Benita
7751904875 Merge pull request #8194 from bluetech/typing-public-3
Export pytest.Metafunc and pytest.Callinfo, hide NodeKeywords
2020-12-29 18:22:02 +02:00
Ran Benita
e772f02d15 Merge pull request #8188 from antonblr/subprocess-coverage
coverage: Include code that runs in subprocesses
2020-12-28 19:05:33 +02:00
Christophe Bedard
bf9b59b3c8 Add missing space in '--version' help message 2020-12-28 10:50:06 -05:00
antonblr
8550c29180 coverage: Include code that runs in subprocesses 2020-12-26 16:59:07 -08:00
Ran Benita
96ea867fec runner: export pytest.CallInfo for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.

This also documents `from_call` as public, because at least
pytest-forked uses it, so we must treat it as public already anyway.
2020-12-26 21:38:37 +02:00
Ran Benita
bd76042344 python: export pytest.Metafunc for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.
2020-12-26 21:05:02 +02:00
Ran Benita
6d3a66d947 nodes: avoid needing to expose NodeKeywords for typing
It adds no value over exporting just the ABC so do that to reduce the
API surface.
2020-12-26 19:54:07 +02:00
Ran Benita
d8d2df7e6f Merge pull request #8174 from bluetech/py-to-pathlib-5
More py.path -> pathlib conversions
2020-12-26 15:01:07 +02:00
Bruno Oliveira
da01ee0a4b Merge pull request #8185 from bluetech/revert-docs-pygments-workaround
Revert "doc: temporary workaround for pytest-pygments lexing error"
2020-12-22 20:36:29 -03:00
Bruno Oliveira
af5da977e3 Merge pull request #8187 from pytest-dev/asottile-patch-1
Add badge for pre-commit.ci
2020-12-22 20:08:01 -03:00
Anthony Sottile
35d6a7e78e Add badge for pre-commit.ci
See #8186
2020-12-22 14:57:04 -08:00
Ran Benita
5e323becb7 Revert "doc: temporary workaround for pytest-pygments lexing error"
Support was added in pytest-pygments 2.2.0.

This reverts commit 0feeddf8ed.
2020-12-22 21:15:27 +02:00
Ran Benita
ca4effc822 Convert most of the collection code from py.path to pathlib 2020-12-22 21:09:36 +02:00
Ran Benita
4faed28261 testing: convert some tmpdir to tmp_path
The tmpdir fixture (and its factory variant) is soft-deprecated in favor
of the tmp_path fixture.
2020-12-22 21:08:25 +02:00
Ran Benita
a218413008 pathlib: missing type annotation for fnmatch_ex 2020-12-22 21:08:25 +02:00
Ran Benita
170a2c5040 testing/test_config: check inipath instead of inifile
inifile is soft-deprecated in favor of inipath.
2020-12-22 21:08:25 +02:00
Ran Benita
8b220fad4d testing/test_helpconfig: remove unclear comment 2020-12-22 21:08:25 +02:00
Ran Benita
92ba96b061 code: convert from py.path to pathlib 2020-12-22 21:08:25 +02:00
Ran Benita
813ce45985 Merge pull request #8179 from bluetech/typing-public-mark
mark: expose Mark, MarkDecorator, MarkGenerator under pytest for typing purposes
2020-12-22 16:32:02 +02:00
Bruno Oliveira
d64706c33d Merge pull request #8180 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-mock-3.4.0
build(deps): bump pytest-mock from 3.3.1 to 3.4.0 in /testing/plugins_integration
2020-12-21 09:38:00 -03:00
dependabot[bot]
1839713b71 build(deps): bump pytest-mock in /testing/plugins_integration
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.3.1 to 3.4.0.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.3.1...v3.4.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-21 03:07:23 +00:00
Ran Benita
6aa4d1c7ab mark: export pytest.MarkGenerator for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.
2020-12-20 15:59:20 +02:00
Ran Benita
69c302479e mark: export pytest.MarkDecorator for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.
2020-12-20 15:59:06 +02:00
Ran Benita
2ec372df8b mark: export pytest.Mark for typing purposes
The type cannot be constructed directly, but is exported for use in type
annotations, since it is reachable through existing public API.
2020-12-20 15:58:49 +02:00
Ran Benita
7aa2240832 testing/test_nodes: fix fake session to be more accurate
The type of _initialpaths is `FrozenSet[Path]`.
2020-12-19 14:52:40 +02:00
Ran Benita
042d12fae6 doctest: use Path instead of py.path where possible 2020-12-19 14:52:40 +02:00
Ran Benita
2c05a7babb config: let main() accept any os.PathLike instead of just py.path.local
Really it ought to only take the List[str], but for backward
compatibility, at least get rid of the explicit py.path.local check.
2020-12-19 14:52:40 +02:00
Ran Benita
73586be08f terminal: remove unused union arm in WarningReport.fslocation 2020-12-19 13:33:34 +02:00
Ran Benita
89dcfbf293 Merge pull request #8168 from antonblr/testdir-to-pytester-incr2
tests: Migrate to pytester - final update
2020-12-19 13:32:20 +02:00
antonblr
196b173c8a address comments 2020-12-18 12:36:20 -08:00
antonblr
15156e94c4 tests: Migrate to pytester - final update 2020-12-18 11:02:38 -08:00
Anthony Sottile
f14ab08de3 Merge pull request #8172 from pytest-dev/revert-8171-fix-ci-setup-python
Use new pypy3 github actions syntax
2020-12-18 11:01:48 -08:00
Anthony Sottile
293a7c962d Use new pypy3 github actions syntax 2020-12-18 10:45:28 -08:00
Anthony Sottile
4da445dc2e Revert "infra: Temporary pin setup-python GH action to v2.1.4" 2020-12-18 10:44:20 -08:00
Bruno Oliveira
403424d60b Merge pull request #8171 from antonblr/fix-ci-setup-python
infra: Temporary pin setup-python GH action to v2.1.4
2020-12-18 08:02:44 -03:00
antonblr
1264404fe7 infra: Temporary pin setup-python GH action to v2.1.4 2020-12-17 21:01:20 -08:00
Adam Johnson
bd894e3065 Add Changelog to setup.cfg (#8166)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-12-17 13:55:36 -03:00
Bruno Oliveira
ce206ae462 Merge pull request #8162 from nicoddemus/rm-travis-badge 2020-12-17 09:10:21 -03:00
Bruno Oliveira
3eef150f2e Remove other references to Travis 2020-12-17 08:19:50 -03:00
Ran Benita
02e69e5cdc Merge pull request #8152 from bluetech/empty-skip
terminal: fix "(<Skipped instance>)" skip reason in test status line
2020-12-17 12:58:00 +02:00
Bruno Oliveira
8255effc5b Remove Travis badge from README
Since we stopped testing Python 3.5, we no longer use Travis.
2020-12-16 15:43:58 -03:00
Chris NeJame
534d174fd2 Clarify fixture execution order and provide visual aids (#7381)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-12-16 13:53:14 -03:00
Bruno Oliveira
cab16f3aac Use transparent PNG for logo (#8159) 2020-12-16 11:19:45 -03:00
Bruno Oliveira
a1c5111a40 Fix events variable in prepare-release-pr.yml 2020-12-16 07:53:05 -03:00
Bruno Oliveira
f1a1de2257 Use manual trigger to prepare release PRs (#8150)
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-12-16 07:50:02 -03:00
Ran Benita
d46ecbc18b terminal: fix "(<Skipped instance>)" skip reason in test status line 2020-12-15 22:24:25 +02:00
Bruno Oliveira
950fbbc326 Merge pull request #8151 from nicoddemus/cherry-pick-release
Merge pull request #8149 from pytest-dev/release-6.2.1
2020-12-15 15:58:13 -03:00
Bruno Oliveira
56600414df Merge pull request #8149 from pytest-dev/release-6.2.1
Prepare release 6.2.1

(cherry picked from commit a566eb9c70)
2020-12-15 12:41:02 -03:00
Jakob van Santen
9ccbf5b899 python_api: handle array-like args in approx() (#8137) 2020-12-15 08:49:29 -03:00
Ran Benita
6c899a0afa Merge pull request #8144 from bluetech/py-to-pathlib-4
hookspec: add pathlib.Path alternatives to py.path.local parameters in hooks
2020-12-15 13:06:06 +02:00
Anton
8eef8c6004 tests: Migrate to pytester - incremental update (#8145) 2020-12-15 13:02:32 +02:00
Ran Benita
592b32bd69 hookspec: add pathlib.Path alternatives to py.path.local parameters in hooks
As part of the ongoing migration for py.path to pathlib, make sure all
hooks which take a py.path.local also take an equivalent pathlib.Path.
2020-12-15 00:34:23 +02:00
Ran Benita
2cb34a99cb Some py.path.local -> pathlib.Path 2020-12-15 00:29:13 +02:00
Bruno Oliveira
cb8142b8ec Merge pull request #8139 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-html-3.1.1
build(deps): bump pytest-html from 3.1.0 to 3.1.1 in /testing/plugins_integration
2020-12-14 08:13:44 -03:00
Bruno Oliveira
382cb2aae1 Merge pull request #8138 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-bdd-4.0.2
build(deps): bump pytest-bdd from 4.0.1 to 4.0.2 in /testing/plugins_integration
2020-12-14 08:13:22 -03:00
dependabot[bot]
a09d8b1599 build(deps): bump pytest-html in /testing/plugins_integration
Bumps [pytest-html](https://github.com/pytest-dev/pytest-html) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/pytest-dev/pytest-html/releases)
- [Changelog](https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-html/compare/v3.1.0...v3.1.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-14 03:07:30 +00:00
dependabot[bot]
92b444a914 build(deps): bump pytest-bdd in /testing/plugins_integration
Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 4.0.1 to 4.0.2.
- [Release notes](https://github.com/pytest-dev/pytest-bdd/releases)
- [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-bdd/compare/4.0.1...4.0.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-14 03:07:27 +00:00
Ran Benita
ad65e816e4 Merge pull request #8111 from antonblr/testdir-to-pytester-python
tests: Migrate testing/python to pytester fixture
2020-12-13 23:19:31 +02:00
antonblr
4ed9a38519 tests: Migrate testing/python to pytester fixture 2020-12-13 07:42:12 -08:00
Bruno Oliveira
7e2e6630ad Merge pull request #8123 from nicoddemus/import-mismatch-unc
Compare also paths on Windows when considering ImportPathMismatchError
2020-12-13 10:35:11 -03:00
Ran Benita
fa784e1436 Merge pull request #8104 from bot2x/patch-1
migrates test_warnings.py from testdir to pytester
2020-12-13 15:21:37 +02:00
bot2x
28588bf535 migrates test_warnings.py from testdir to pytester 2020-12-13 14:13:49 +02:00
Ran Benita
37b154b1ec Merge pull request #8122 from bluetech/py-to-pathlib-3
Some py.path.local -> pathlib.Path
2020-12-13 10:54:19 +02:00
Ran Benita
ed658d6829 Some py.path.local -> pathlib.Path
- Some conftest related functions
- _confcutdir
- Allow arbitrary os.PathLike[str] in gethookproxy.
2020-12-12 17:33:28 +02:00
Bruno Oliveira
572dfcd160 Compare also paths on Windows when considering ImportPathMismatchError
On Windows, os.path.samefile returns false for paths mounted in UNC paths which
point to the same location.

I couldn't reproduce the actual case reported, but looking at the code it seems
this commit should fix the issue.

Fix #7678
Fix #8076
2020-12-12 08:54:49 -03:00
276 changed files with 26468 additions and 10815 deletions

View File

@@ -25,6 +25,7 @@ exclude_lines =
^\s*raise NotImplementedError\b
^\s*return NotImplemented\b
^\s*assert False(,|$)
^\s*assert_never\(
^\s*if TYPE_CHECKING:
^\s*@overload( |$)

View File

@@ -13,7 +13,7 @@ If this change fixes an issue, 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.
- [ ] 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/main/changelog/README.rst) for details.
Write sentences in the **past or present tense**, examples:

View File

@@ -3,7 +3,7 @@ name: main
on:
push:
branches:
- master
- main
- "[0-9]+.[0-9]+.x"
tags:
- "[0-9]+.[0-9]+.[0-9]+"
@@ -11,13 +11,21 @@ on:
pull_request:
branches:
- master
- main
- "[0-9]+.[0-9]+.x"
env:
PYTEST_ADDOPTS: "--color=yes"
# Set permissions at the job level.
permissions: {}
jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
timeout-minutes: 45
permissions:
contents: read
strategy:
fail-fast: false
@@ -27,6 +35,9 @@ jobs:
"windows-py37",
"windows-py37-pluggy",
"windows-py38",
"windows-py39",
"windows-py310",
"windows-py311",
"ubuntu-py36",
"ubuntu-py37",
@@ -34,6 +45,8 @@ jobs:
"ubuntu-py37-freeze",
"ubuntu-py38",
"ubuntu-py39",
"ubuntu-py310",
"ubuntu-py311",
"ubuntu-pypy3",
"macos-py37",
@@ -56,12 +69,24 @@ jobs:
- name: "windows-py37-pluggy"
python: "3.7"
os: windows-latest
tox_env: "py37-pluggymaster-xdist"
tox_env: "py37-pluggymain-xdist"
- name: "windows-py38"
python: "3.8"
os: windows-latest
tox_env: "py38-unittestextras"
use_coverage: true
- name: "windows-py39"
python: "3.9"
os: windows-latest
tox_env: "py39-xdist"
- name: "windows-py310"
python: "3.10"
os: windows-latest
tox_env: "py310-xdist"
- name: "windows-py311"
python: "3.11-dev"
os: windows-latest
tox_env: "py311"
- name: "ubuntu-py36"
python: "3.6"
@@ -75,7 +100,7 @@ jobs:
- name: "ubuntu-py37-pluggy"
python: "3.7"
os: ubuntu-latest
tox_env: "py37-pluggymaster-xdist"
tox_env: "py37-pluggymain-xdist"
- name: "ubuntu-py37-freeze"
python: "3.7"
os: ubuntu-latest
@@ -88,8 +113,16 @@ jobs:
python: "3.9"
os: ubuntu-latest
tox_env: "py39-xdist"
- name: "ubuntu-py310"
python: "3.10"
os: ubuntu-latest
tox_env: "py310-xdist"
- name: "ubuntu-py311"
python: "3.11-dev"
os: ubuntu-latest
tox_env: "py311"
- name: "ubuntu-pypy3"
python: "pypy3"
python: "pypy-3.7"
os: ubuntu-latest
tox_env: "pypy3-xdist"
@@ -122,10 +155,13 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
@@ -137,45 +173,27 @@ jobs:
- name: Test with coverage
if: "matrix.use_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 }}"
run: "tox -e ${{ matrix.tox_env }}-coverage"
- name: Prepare coverage token
if: (matrix.use_coverage && ( github.repository == 'pytest-dev/pytest' || github.event_name == 'pull_request' ))
run: |
python scripts/append_codecov_token.py
- name: Generate coverage report
if: "matrix.use_coverage"
run: python -m coverage xml
- name: Report coverage
if: (matrix.use_coverage)
env:
CODECOV_NAME: ${{ matrix.name }}
run: bash scripts/report-coverage.sh -F GHA,${{ runner.os }}
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: set PY
run: echo "name=PY::$(python -c 'import hashlib, sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- uses: actions/cache@v2
- name: Upload coverage to Codecov
if: "matrix.use_coverage"
uses: codecov/codecov-action@v2
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- run: tox -e linting
fail_ci_if_error: true
files: ./coverage.xml
verbose: true
deploy:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') && github.repository == 'pytest-dev/pytest'
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
needs: [build]
@@ -183,25 +201,31 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools tox
pip install --upgrade build tox
- name: Build package
run: |
python setup.py sdist bdist_wheel
python -m build
- 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 }}
GH_RELEASE_NOTES_TOKEN: ${{ github.token }}
run: |
sudo apt-get install pandoc
tox -e publish-gh-release-notes

View File

@@ -0,0 +1,52 @@
name: prepare release pr
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to base the release from'
required: true
default: ''
major:
description: 'Major release? (yes/no)'
required: true
default: 'no'
prerelease:
description: 'Prerelease (ex: rc1). Leave empty if not a pre-release.'
required: false
default: ''
# Set permissions at the job level.
permissions: {}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools tox
- name: Prepare release PR (minor/patch release)
if: github.event.inputs.major == 'no'
run: |
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --prerelease='${{ github.event.inputs.prerelease }}'
- name: Prepare release PR (major release)
if: github.event.inputs.major == 'yes'
run: |
tox -e prepare-release-pr -- ${{ github.event.inputs.branch }} ${{ github.token }} --major --prerelease='${{ github.event.inputs.prerelease }}'

View File

@@ -1,31 +0,0 @@
# part of our release process, see `release-on-comment.py`
name: release on comment
on:
issues:
types: [opened, edited]
issue_comment:
types: [created, edited]
jobs:
build:
runs-on: ubuntu-latest
if: (github.event.comment && startsWith(github.event.comment.body, '@pytestbot please')) || (github.event.issue && !github.event.comment && startsWith(github.event.issue.body, '@pytestbot please'))
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade setuptools tox
- name: Prepare release
run: |
tox -e release-on-comment -- $GITHUB_EVENT_PATH ${{ secrets.chatops }}

View File

@@ -0,0 +1,49 @@
name: Update Plugin List
on:
schedule:
# At 00:00 on Sunday.
# https://crontab.guru
- cron: '0 0 * * 0'
workflow_dispatch:
# Set permissions at the job level.
permissions: {}
jobs:
createPullRequest:
if: github.repository_owner == 'pytest-dev'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install packaging requests tabulate[widechars] tqdm
- name: Update Plugin List
run: python scripts/update-plugin-list.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@2455e1596942c2902952003bbb574afbbe2ab2e6
with:
commit-message: '[automated] Update plugin list'
author: 'pytest bot <pytestbot@users.noreply.github.com>'
branch: update-plugin-list/patch
delete-branch: true
branch-suffix: short-commit-hash
title: '[automated] Update plugin list'
body: '[automated] Update plugin list'

3
.gitignore vendored
View File

@@ -53,3 +53,6 @@ coverage.xml
# generated by pip
pip-wheel-metadata/
# pytest debug logs generated via --debug
pytestdebug.log

View File

@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 21.11b1
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.8.0
rev: v1.12.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.10b0]
additional_dependencies: [black==20.8b1]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.0.1
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -20,8 +20,8 @@ repos:
- id: debug-statements
exclude: _pytest/(debugging|hookspec).py
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
language_version: python3
@@ -29,27 +29,26 @@ repos:
- flake8-typing-imports==1.9.0
- flake8-docstrings==1.5.0
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.3.5
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: ['--application-directories=.:src', --py36-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
rev: v2.29.1
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.11.0
rev: v1.20.0
hooks:
- id: setup-cfg-fmt
# TODO: when upgrading setup-cfg-fmt this can be removed
args: [--max-py-version=3.9]
args: [--max-py-version=3.10]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.6.0
rev: v1.9.0
hooks:
- id: python-use-type-annotations
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v0.910-1
hooks:
- id: mypy
files: ^(src/|testing/)
@@ -59,6 +58,9 @@ repos:
- py>=1.8.2
- attrs>=19.2.0
- packaging
- tomli
- types-atomicwrites
- types-pkg_resources
- repo: local
hooks:
- id: rst
@@ -89,3 +91,9 @@ repos:
xml\.
)
types: [python]
- id: py-path-deprecated
name: py.path usage is deprecated
exclude: docs|src/_pytest/deprecated.py|testing/deprecated_test.py
language: pygrep
entry: \bpy\.path\.local
types: [python]

View File

@@ -1,12 +1,19 @@
version: 2
python:
version: 3.7
install:
- requirements: doc/en/requirements.txt
- method: pip
path: .
build:
os: ubuntu-20.04
tools:
python: "3.9"
apt_packages:
- inkscape
formats:
- epub
- pdf
- htmlzip

30
AUTHORS
View File

@@ -5,6 +5,7 @@ Contributors include::
Aaron Coleman
Abdeali JK
Abdelrahman Elbehery
Abhijeet Kasurde
Adam Johnson
Adam Uhlir
@@ -12,6 +13,7 @@ Ahn Ki-Wook
Akiomi Kamakura
Alan Velasco
Alexander Johnson
Alexander King
Alexei Kozlenok
Allan Feldman
Aly Sivji
@@ -21,7 +23,9 @@ Anders Hovmöller
Andras Mitzki
Andras Tim
Andrea Cimatoribus
Andreas Motl
Andreas Zeidler
Andrew Shapton
Andrey Paramonov
Andrzej Klajnert
Andrzej Ostrowski
@@ -29,9 +33,11 @@ Andy Freeland
Anthon van der Neut
Anthony Shaw
Anthony Sottile
Anton Grinevich
Anton Lodder
Antony Lee
Arel Cordero
Arias Emmanuel
Ariel Pillemer
Armin Rigo
Aron Coyle
@@ -39,6 +45,7 @@ Aron Curzon
Aviral Verma
Aviv Palivoda
Barney Gale
Ben Gartner
Ben Webb
Benjamin Peterson
Bernard Pratz
@@ -56,6 +63,8 @@ Charles Cloud
Charles Machalow
Charnjit SiNGH (CCSJ)
Chris Lamb
Chris NeJame
Chris Rose
Christian Boelsen
Christian Fetzer
Christian Neumüller
@@ -68,12 +77,14 @@ Christopher Gilling
Claire Cecil
Claudio Madotto
CrazyMerlyn
Cristian Vera
Cyrus Maden
Damian Skrzypczak
Daniel Grana
Daniel Hahler
Daniel Nuri
Daniel Wandschneider
Daniele Procida
Danielle Jenkins
Daniil Galiev
Dave Hunt
@@ -85,6 +96,7 @@ David Vierra
Daw-Ran Liou
Debi Mishra
Denis Kirisov
Denivy Braiam Rück
Dhiren Serai
Diego Russo
Dmitry Dygalo
@@ -93,11 +105,14 @@ Dominic Mortlock
Duncan Betts
Edison Gustavo Muenz
Edoardo Batini
Edson Tadeu M. Manoel
Eduardo Schettino
Eli Boyarski
Elizaveta Shashkova
Éloi Rivard
Endre Galaczi
Eric Hunsberger
Eric Liu
Eric Siegerman
Erik Aronesty
Erik M. Bray
@@ -114,7 +129,9 @@ Garvit Shubham
Gene Wood
George Kussumoto
Georgy Dyuldin
Gergely Kalmár
Gleb Nikonorov
Graeme Smecher
Graham Horler
Greg Price
Gregory Lee
@@ -123,6 +140,7 @@ Grigorii Eremeev (budulianin)
Guido Wesdorp
Guoqiang Zhang
Harald Armin Massa
Harshna
Henk-Jaap Wagenaar
Holger Kohr
Hugo van Kemenade
@@ -135,6 +153,7 @@ Iwan Briquemont
Jaap Broekhuizen
Jakob van Santen
Jakub Mitoraj
James Bourbeau
Jan Balster
Janne Vanhala
Jason R. Coombs
@@ -155,6 +174,7 @@ Josh Karpel
Joshua Bronson
Jurko Gospodnetić
Justyna Janczyszyn
Justice Ndou
Kale Kundert
Kamran Ahmad
Karl O. Pinc
@@ -165,6 +185,7 @@ Katerina Koukiou
Keri Volans
Kevin Cox
Kevin J. Foley
Kian-Meng Ang
Kodi B. Arfer
Kostis Anagnostopoulos
Kristoffer Nordström
@@ -209,6 +230,7 @@ Michael Goerz
Michael Krebs
Michael Seifert
Michal Wajszczuk
Michał Zięba
Mihai Capotă
Mike Hoyle (hoylemd)
Mike Lundy
@@ -222,6 +244,7 @@ Nicholas Murphy
Niclas Olofsson
Nicolas Delaby
Nikolay Kondratyev
Olga Matoula
Oleg Pidsadnyi
Oleg Sushchenko
Oliver Bestwalter
@@ -229,6 +252,7 @@ Omar Kohl
Omer Hadari
Ondřej Súkup
Oscar Benjamin
Parth Patel
Patrick Hayes
Pauli Virtanen
Pavel Karateev
@@ -263,6 +287,7 @@ Ross Lawley
Ruaridh Williamson
Russel Winder
Ryan Wooden
Saiprasad Kale
Samuel Dion-Girardeau
Samuel Searles-Bryant
Samuele Pedroni
@@ -271,6 +296,7 @@ Sankt Petersbug
Segev Finer
Serhii Mozghovyi
Seth Junot
Shantanu Jain
Shubham Adep
Simon Gomizelj
Simon Kerr
@@ -286,10 +312,12 @@ Sven-Hendrik Haase
Sylvain Marié
Tadek Teleżyński
Takafumi Arakaki
Taneli Hukkinen
Tanvi Mehta
Tarcisio Fischer
Tareq Alayan
Ted Xiao
Terje Runde
Thomas Grainger
Thomas Hisch
Tim Hoffmann
@@ -321,6 +349,8 @@ Xixi Zhao
Xuan Luong
Xuecong Liao
Yoav Caspi
Yuval Shimon
Zac Hatfield-Dodds
Zachary Kneupper
Zoltán Máté
Zsolt Cserna

View File

@@ -4,4 +4,4 @@ Changelog
The pytest CHANGELOG is located `here <https://docs.pytest.org/en/stable/changelog.html>`__.
The source document can be found at: https://github.com/pytest-dev/pytest/blob/master/doc/en/changelog.rst
The source document can be found at: https://github.com/pytest-dev/pytest/blob/main/doc/en/changelog.rst

View File

@@ -160,7 +160,7 @@ the following:
- an issue tracker for bug reports and enhancement requests.
- a `changelog <http://keepachangelog.com/>`_.
- a `changelog <https://keepachangelog.com/>`_.
If no contributor strongly objects and two agree, the repository can then be
transferred to the ``pytest-dev`` organisation.
@@ -234,9 +234,9 @@ Here is a simple overview, with pytest-specific bits:
$ git clone git@github.com:YOUR_GITHUB_USERNAME/pytest.git
$ cd pytest
# now, create your own branch off "master":
# now, create your own branch off "main":
$ git checkout -b your-bugfix-branch-name master
$ git checkout -b your-bugfix-branch-name main
Given we have "major.minor.micro" version numbers, bug fixes will usually
be released in micro releases whereas features will be released in
@@ -259,7 +259,7 @@ Here is a simple overview, with pytest-specific bits:
Tox is used to run all the tests and will automatically setup virtualenvs
to run the tests in.
(will implicitly use http://www.virtualenv.org/en/latest/)::
(will implicitly use https://virtualenv.pypa.io/en/latest/)::
$ pip install tox
@@ -318,26 +318,26 @@ Here is a simple overview, with pytest-specific bits:
compare: your-branch-name
base-fork: pytest-dev/pytest
base: master
base: main
Writing Tests
~~~~~~~~~~~~~
Writing tests for plugins or for pytest itself is often done using the `testdir fixture <https://docs.pytest.org/en/stable/reference.html#testdir>`_, as a "black-box" test.
Writing tests for plugins or for pytest itself is often done using the `pytester fixture <https://docs.pytest.org/en/stable/reference/reference.html#pytester>`_, as a "black-box" test.
For example, to ensure a simple test passes you can write:
.. code-block:: python
def test_true_assertion(testdir):
testdir.makepyfile(
def test_true_assertion(pytester):
pytester.makepyfile(
"""
def test_foo():
assert True
"""
)
result = testdir.runpytest()
result = pytester.runpytest()
result.assert_outcomes(failed=0, passed=1)
@@ -346,14 +346,14 @@ Alternatively, it is possible to make checks based on the actual output of the t
.. code-block:: python
def test_true_assertion(testdir):
testdir.makepyfile(
def test_true_assertion(pytester):
pytester.makepyfile(
"""
def test_foo():
assert False
"""
)
result = testdir.runpytest()
result = pytester.runpytest()
result.stdout.fnmatch_lines(["*assert False*", "*1 failed*"])
When choosing a file where to write a new test, take a look at the existing files and see if there's
@@ -387,15 +387,15 @@ Suppose for example that the latest release was 1.2.3, and you want to include
a bug fix in 1.2.4 (check https://github.com/pytest-dev/pytest/releases for the
actual latest release). The procedure for this is:
#. First, make sure the bug is fixed the ``master`` branch, with a regular pull
#. First, make sure the bug is fixed the ``main`` branch, with a regular pull
request, as described above. An exception to this is if the bug fix is not
applicable to ``master`` anymore.
applicable to ``main`` anymore.
#. ``git checkout origin/1.2.x -b backport-XXXX`` # use the master PR number here
#. ``git checkout origin/1.2.x -b backport-XXXX`` # use the main PR number here
#. Locate the merge commit on the PR, in the *merged* message, for example:
nicoddemus merged commit 0f8b462 into pytest-dev:master
nicoddemus merged commit 0f8b462 into pytest-dev:main
#. ``git cherry-pick -x -m1 REVISION`` # use the revision you found above (``0f8b462``).
@@ -408,8 +408,8 @@ actual latest release). The procedure for this is:
Who does the backporting
~~~~~~~~~~~~~~~~~~~~~~~~
As mentioned above, bugs should first be fixed on ``master`` (except in rare occasions
that a bug only happens in a previous release). So who should do the backport procedure described
As mentioned above, bugs should first be fixed on ``main`` (except in rare occasions
that a bug only happens in a previous release). So, who should do the backport procedure described
above?
1. If the bug was fixed by a core developer, it is the main responsibility of that core developer
@@ -417,8 +417,8 @@ above?
2. However, often the merge is done by another maintainer, in which case it is nice of them to
do the backport procedure if they have the time.
3. For bugs submitted by non-maintainers, it is expected that a core developer will to do
the backport, normally the one that merged the PR on ``master``.
4. If a non-maintainers notices a bug which is fixed on ``master`` but has not been backported
the backport, normally the one that merged the PR on ``main``.
4. If a non-maintainers notices a bug which is fixed on ``main`` but has not been backported
(due to maintainers forgetting to apply the *needs backport* label, or just plain missing it),
they are also welcome to open a PR with the backport. The procedure is simple and really
helps with the maintenance of the project.
@@ -447,7 +447,7 @@ can always reopen the issue/pull request in their own time later if it makes sen
When to close
~~~~~~~~~~~~~
Here are a few general rules the maintainers use to decide when to close issues/PRs because
Here are a few general rules the maintainers use deciding when to close issues/PRs because
of lack of inactivity:
* Issues labeled ``question`` or ``needs information``: closed after 14 days inactive.
@@ -459,15 +459,15 @@ The above are **not hard rules**, but merely **guidelines**, and can be (and oft
Closing pull requests
~~~~~~~~~~~~~~~~~~~~~
When closing a Pull Request, it needs to be acknowledge the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale:
When closing a Pull Request, it needs to be acknowledging the time, effort, and interest demonstrated by the person which submitted it. As mentioned previously, it is not the intent of the team to dismiss a stalled pull request entirely but to merely to clear up our queue, so a message like the one below is warranted when closing a pull request that went stale:
Hi <contributor>,
First of all we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it.
First of all, we would like to thank you for your time and effort on working on this, the pytest team deeply appreciates it.
We noticed it has been awhile since you have updated this PR, however. pytest is a high activity project, with many issues/PRs being opened daily, so it is hard for us maintainers to track which PRs are ready for merging, for review, or need more attention.
So for those reasons we think it is best to close the PR for now, but with the only intention to cleanup our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it.
So for those reasons we, think it is best to close the PR for now, but with the only intention to clean up our queue, it is by no means a rejection of your changes. We still encourage you to re-open this PR (it is just a click of a button away) when you are ready to get back to it.
Again we appreciate your time for working on this, and hope you might get back to this at a later time!

View File

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

View File

@@ -1,6 +1,7 @@
.. image:: https://docs.pytest.org/en/stable/_static/pytest1.png
.. image:: https://github.com/pytest-dev/pytest/raw/main/doc/en/img/pytest_logo_curves.svg
:target: https://docs.pytest.org/en/stable/
:align: center
:height: 200
:alt: pytest
@@ -15,16 +16,17 @@
.. image:: https://img.shields.io/pypi/pyversions/pytest.svg
:target: https://pypi.org/project/pytest/
.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/master/graph/badge.svg
.. image:: https://codecov.io/gh/pytest-dev/pytest/branch/main/graph/badge.svg
:target: https://codecov.io/gh/pytest-dev/pytest
:alt: Code coverage Status
.. image:: https://travis-ci.org/pytest-dev/pytest.svg?branch=master
:target: https://travis-ci.org/pytest-dev/pytest
.. image:: https://github.com/pytest-dev/pytest/workflows/main/badge.svg
:target: https://github.com/pytest-dev/pytest/actions?query=workflow%3Amain
.. image:: https://results.pre-commit.ci/badge/github/pytest-dev/pytest/main.svg
:target: https://results.pre-commit.ci/latest/github/pytest-dev/pytest/main
:alt: pre-commit.ci status
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
@@ -35,6 +37,15 @@
:target: https://pytest.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/badge/Discord-pytest--dev-blue
:target: https://discord.com/invite/pytest-dev
:alt: Discord
.. image:: https://img.shields.io/badge/Libera%20chat-%23pytest-orange
:target: https://web.libera.chat/#pytest
:alt: Libera chat
The ``pytest`` framework makes it easy to write small tests, yet
scales to support complex functional testing for applications and libraries.
@@ -77,21 +88,21 @@ Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` stat
Features
--------
- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/assert.html>`_ (no need to remember ``self.assert*`` names)
- Detailed info on failing `assert statements <https://docs.pytest.org/en/stable/how-to/assert.html>`_ (no need to remember ``self.assert*`` names)
- `Auto-discovery
<https://docs.pytest.org/en/stable/goodpractices.html#python-test-discovery>`_
<https://docs.pytest.org/en/stable/explanation/goodpractices.html#python-test-discovery>`_
of test modules and functions
- `Modular fixtures <https://docs.pytest.org/en/stable/fixture.html>`_ for
- `Modular fixtures <https://docs.pytest.org/en/stable/explanation/fixtures.html>`_ for
managing small or parametrized long-lived test resources
- Can run `unittest <https://docs.pytest.org/en/stable/unittest.html>`_ (or trial),
`nose <https://docs.pytest.org/en/stable/nose.html>`_ test suites out of the box
- Can run `unittest <https://docs.pytest.org/en/stable/how-to/unittest.html>`_ (or trial),
`nose <https://docs.pytest.org/en/stable/how-to/nose.html>`_ test suites out of the box
- Python 3.6+ and PyPy3
- Rich plugin architecture, with over 850+ `external plugins <http://plugincompat.herokuapp.com>`_ and thriving community
- Rich plugin architecture, with over 850+ `external plugins <https://docs.pytest.org/en/latest/reference/plugin_list.html>`_ and thriving community
Documentation
@@ -149,8 +160,8 @@ Tidelift will coordinate the fix and disclosure.
License
-------
Copyright Holger Krekel and others, 2004-2020.
Copyright Holger Krekel and others, 2004.
Distributed under the terms of the `MIT`_ license, pytest is free and open source software.
.. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
.. _`MIT`: https://github.com/pytest-dev/pytest/blob/main/LICENSE

View File

@@ -14,59 +14,89 @@ Preparing: Automatic Method
~~~~~~~~~~~~~~~~~~~~~~~~~~~
We have developed an automated workflow for releases, that uses GitHub workflows and is triggered
by opening an issue.
by `manually running <https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow>`__
the `prepare-release-pr workflow <https://github.com/pytest-dev/pytest/actions/workflows/prepare-release-pr.yml>`__
on GitHub Actions.
Bug-fix releases
^^^^^^^^^^^^^^^^
The automation will decide the new version number based on the following criteria:
A bug-fix release is always done from a maintenance branch, so for example to release bug-fix
``5.1.2``, open a new issue and add this comment to the body::
- If the "major release" input is set to "yes", release a new major release
(e.g. 7.0.0 -> 8.0.0)
- If there are any ``.feature.rst`` or ``.breaking.rst`` files in the
``changelog`` directory, release a new minor release (e.g. 7.0.0 -> 7.1.0)
- Otherwise, release a bugfix release (e.g. 7.0.0 -> 7.0.1)
- If the "prerelease" input is set, append the string to the version number
(e.g. 7.0.0 -> 8.0.0rc1), if "major" is set, and "prerelease" is set to `rc1`)
@pytestbot please prepare release from 5.1.x
Bug-fix and minor releases
^^^^^^^^^^^^^^^^^^^^^^^^^^
Where ``5.1.x`` is the maintenance branch for the ``5.1`` series.
Bug-fix and minor releases are always done from a maintenance branch. First,
consider double-checking the ``changelog`` directory to see if there are any
breaking changes or new features.
The automated workflow will publish a PR for a branch ``release-5.1.2``
and notify it as a comment in the issue.
For a new minor release, first create a new maintenance branch from ``main``::
Minor releases
git fetch --all
git branch 7.1.x upstream/main
git push upstream 7.1.x
Then, trigger the workflow with the following inputs:
- branch: **7.1.x**
- major release: **no**
- prerelease: empty
Or via the commandline using `GitHub's cli <https://github.com/cli/cli>`__::
gh workflow run prepare-release-pr.yml -f branch=7.1.x -f major=no -f prerelease=
Where ``7.1.x`` is the maintenance branch for the ``7.1`` series. The automated
workflow will publish a PR for a branch ``release-7.1.0``.
Similarly, for a bug-fix release, use the existing maintenance branch and
trigger the workflow with e.g. ``branch: 7.0.x`` to get a new ``release-7.0.1``
PR.
Major releases
^^^^^^^^^^^^^^
1. Create a new maintenance branch from ``master``::
1. Create a new maintenance branch from ``main``::
git fetch --all
git branch 5.2.x upstream/master
git push upstream 5.2.x
git branch 8.0.x upstream/main
git push upstream 8.0.x
2. Open a new issue and add this comment to the body::
2. Trigger the workflow with the following inputs:
@pytestbot please prepare release from 5.2.x
- branch: **8.0.x**
- major release: **yes**
- prerelease: empty
The automated workflow will publish a PR for a branch ``release-5.2.0`` and
notify it as a comment in the issue.
Or via the commandline::
Major and release candidates
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=
1. Create a new maintenance branch from ``master``::
git fetch --all
git branch 6.0.x upstream/master
git push upstream 6.0.x
2. For a **major release**, open a new issue and add this comment in the body::
@pytestbot please prepare major release from 6.0.x
For a **release candidate**, the comment must be (TODO: `#7551 <https://github.com/pytest-dev/pytest/issues/7551>`__)::
@pytestbot please prepare release candidate from 6.0.x
The automated workflow will publish a PR for a branch ``release-6.0.0`` and
notify it as a comment in the issue.
The automated workflow will publish a PR for a branch ``release-8.0.0``.
At this point on, this follows the same workflow as other maintenance branches: bug-fixes are merged
into ``master`` and ported back to the maintenance branch, even for release candidates.
into ``main`` and ported back to the maintenance branch, even for release candidates.
Release candidates
^^^^^^^^^^^^^^^^^^
To release a release candidate, set the "prerelease" input to the version number
suffix to use. To release a ``8.0.0rc1``, proceed like under "major releases", but set:
- branch: 8.0.x
- major release: yes
- prerelease: **rc1**
Or via the commandline::
gh workflow run prepare-release-pr.yml -f branch=8.0.x -f major=yes -f prerelease=rc1
The automated workflow will publish a PR for a branch ``release-8.0.0rc1``.
**A note about release candidates**
@@ -83,7 +113,7 @@ to be executed on that platform.
To release a version ``MAJOR.MINOR.PATCH``, follow these steps:
#. For major and minor releases, create a new branch ``MAJOR.MINOR.x`` from
``upstream/master`` and push it to ``upstream``.
``upstream/main`` and push it to ``upstream``.
#. Create a branch ``release-MAJOR.MINOR.PATCH`` from the ``MAJOR.MINOR.x`` branch.
@@ -114,18 +144,18 @@ Both automatic and manual processes described above follow the same steps from t
#. Merge the PR.
#. Cherry-pick the CHANGELOG / announce files to the ``master`` branch::
#. Cherry-pick the CHANGELOG / announce files to the ``main`` branch::
git fetch --all --prune
git checkout origin/master -b cherry-pick-release
git checkout upstream/main -b cherry-pick-release
git cherry-pick -x -m1 upstream/MAJOR.MINOR.x
#. Open a PR for ``cherry-pick-release`` and merge it once CI passes. No need to wait for approvals if there were no conflicts on the previous step.
#. For major and minor releases, tag the release cherry-pick merge commit in master with
#. For major and minor releases, tag the release cherry-pick merge commit in main with
a dev tag for the next feature release::
git checkout master
git checkout main
git pull
git tag MAJOR.{MINOR+1}.0.dev0
git push git@github.com:pytest-dev/pytest.git MAJOR.{MINOR+1}.0.dev0

View File

@@ -25,6 +25,7 @@ The current list of contributors receiving funding are:
* `@asottile`_
* `@nicoddemus`_
* `@The-Compiler`_
Contributors interested in receiving a part of the funds just need to submit a PR adding their
name to the list. Contributors that want to stop receiving the funds should also submit a PR
@@ -56,3 +57,4 @@ funds. Just drop a line to one of the `@pytest-dev/tidelift-admins`_ or use the
.. _`@asottile`: https://github.com/asottile
.. _`@nicoddemus`: https://github.com/nicoddemus
.. _`@The-Compiler`: https://github.com/The-Compiler

View File

@@ -34,6 +34,10 @@ REGENDOC_ARGS := \
regen: REGENDOC_FILES:=*.rst */*.rst
regen:
PYTHONDONTWRITEBYTECODE=1 PYTEST_ADDOPTS="-pno:hypothesis -Wignore::pytest.PytestUnknownMarkWarning" COLUMNS=76 regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
# need to reset cachedir to the non-tox default
PYTHONDONTWRITEBYTECODE=1 \
PYTEST_ADDOPTS="-pno:hypothesis -p no:hypothesispytest -Wignore::pytest.PytestUnknownMarkWarning -o cache_dir=.pytest_cache" \
COLUMNS=76 \
regendoc --update ${REGENDOC_FILES} ${REGENDOC_ARGS}
.PHONY: regen

View File

@@ -1,12 +1,19 @@
<h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
<h3>Contents</h3>
<ul>
<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') }}">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('getting-started') }}">Get started</a></li>
<li><a href="{{ pathto('how-to/index') }}">How-to guides</a></li>
<li><a href="{{ pathto('reference/index') }}">Reference guides</a></li>
<li><a href="{{ pathto('explanation/index') }}">Explanation</a></li>
<li><a href="{{ pathto('contents') }}">Complete table of contents</a></li>
<li><a href="{{ pathto('example/index') }}">Library of examples</a></li>
</ul>
<h3>About the project</h3>
<ul>
<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>

View File

@@ -2,7 +2,6 @@
<ul>
<li><a href="https://pypi.org/project/pytest/">pytest @ PyPI</a></li>
<li><a href="https://github.com/pytest-dev/pytest/">pytest @ GitHub</a></li>
<li><a href="http://plugincompat.herokuapp.com/">3rd party plugins</a></li>
<li><a href="https://github.com/pytest-dev/pytest/issues">Issue Tracker</a></li>
<li><a href="https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf">PDF Documentation</a>
</ul>

View File

@@ -10,10 +10,9 @@ Are you an enthusiastic pytest user, the local testing guru in your workplace? O
We will pair experienced pytest users with open source projects, for a month's effort of getting new development teams started with pytest.
In 2015 we are trying this for the first time. In February and March 2015 we will gather volunteers on both sides, in April we will do the work, and in May we will evaluate how it went. This effort is being coordinated by Brianna Laugher. If you have any questions or comments, you can raise them on the `@pytestdotorg twitter account <https://twitter.com/pytestdotorg>`_ the `issue tracker`_ or the `pytest-dev mailing list`_.
In 2015 we are trying this for the first time. In February and March 2015 we will gather volunteers on both sides, in April we will do the work, and in May we will evaluate how it went. This effort is being coordinated by Brianna Laugher. If you have any questions or comments, you can raise them on the `@pytestdotorg twitter account <https://twitter.com/pytestdotorg>`_\, the :issue:`issue tracker <676>` or the `pytest-dev mailing list`_.
.. _`issue tracker`: https://github.com/pytest-dev/pytest/issues/676
.. _`pytest-dev mailing list`: https://mail.python.org/mailman/listinfo/pytest-dev

View File

@@ -6,6 +6,14 @@ Release announcements
:maxdepth: 2
release-7.0.1
release-7.0.0
release-7.0.0rc1
release-6.2.5
release-6.2.4
release-6.2.3
release-6.2.2
release-6.2.1
release-6.2.0
release-6.1.2
release-6.1.1

View File

@@ -36,12 +36,12 @@ New Features
import pytest ; pytest.main(arglist, pluginlist)
see http://pytest.org/en/stable/usage.html for details.
see http://pytest.org/en/stable/how-to/usage.html for details.
- new and better reporting information in assert expressions
if comparing lists, sequences or strings.
see http://pytest.org/en/stable/assert.html#newreport
see http://pytest.org/en/stable/how-to/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/en/stable/customize.html
see http://pytest.org/en/stable/reference/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/en/stable/plugins.html#cmdunregister
command line, see http://pytest.org/en/stable/how-to/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 https://docs.pytest.org/en/stable/assert.html for
See https://docs.pytest.org/en/stable/how-to/assert.html for
detailed information. The work has been partly sponsored by my company,
merlinux GmbH.
@@ -24,7 +24,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest
best,
holger krekel / http://merlinux.eu
holger krekel / https://merlinux.eu/
Changes between 2.0.3 and 2.1.0
----------------------------------------------

View File

@@ -20,7 +20,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest
best,
holger krekel / http://merlinux.eu
holger krekel / https://merlinux.eu/
Changes between 2.1.0 and 2.1.1
----------------------------------------------

View File

@@ -19,7 +19,7 @@ If you want to install or upgrade pytest, just type one of::
easy_install -U pytest
best,
holger krekel / http://merlinux.eu
holger krekel / https://merlinux.eu/
Changes between 2.1.1 and 2.1.2
----------------------------------------

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/en/stable/example/parametrize.html
- see examples at http://pytest.org/en/stable/example/how-to/parametrize.html
- NOTE that parametrize() related APIs are still a bit experimental
and might change in future releases.
@@ -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/en/stable/mark.html
for your test suite. See examples at http://pytest.org/en/stable/how-to/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

@@ -13,12 +13,12 @@ re-usable fixture design.
For detailed info and tutorial-style examples, see:
http://pytest.org/en/stable/fixture.html
http://pytest.org/en/stable/explanation/fixtures.html
Moreover, there is now support for using pytest fixtures/funcargs with
unittest-style suites, see here for examples:
http://pytest.org/en/stable/unittest.html
http://pytest.org/en/stable/how-to/unittest.html
Besides, more unittest-test suites are now expected to "simply work"
with pytest.

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/en/stable/example/parametrize.html
http://pytest.org/en/stable/example/how-to/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

@@ -23,14 +23,13 @@ a full list of details. A few feature highlights:
called if the corresponding setup method succeeded.
- integrate tab-completion on command line options if you
have `argcomplete <https://pypi.org/project/argcomplete/>`_
configured.
have :pypi:`argcomplete` configured.
- allow boolean expression directly with skipif/xfail
if a "reason" is also specified.
- a new hook ``pytest_load_initial_conftests`` allows plugins like
`pytest-django <https://pypi.org/project/pytest-django/>`_ to
:pypi:`pytest-django` to
influence the environment before conftest files import ``django``.
- reporting: color the last line red or green depending if

View File

@@ -11,7 +11,7 @@ clear information about the circumstances and a simple example which
reproduces the problem.
The issue tracker is of course not empty now. We have many remaining
"enhacement" issues which we'll hopefully can tackle in 2014 with your
"enhancement" issues which we'll hopefully can tackle in 2014 with your
help.
For those who use older Python versions, please note that pytest is not

View File

@@ -45,29 +45,29 @@ The py.test Development Team
**New Features**
* New ``pytest.mark.skip`` mark, which unconditionally skips marked tests.
Thanks `@MichaelAquilina`_ for the complete PR (`#1040`_).
Thanks :user:`MichaelAquilina` for the complete PR (:pull:`1040`).
* ``--doctest-glob`` may now be passed multiple times in the command-line.
Thanks `@jab`_ and `@nicoddemus`_ for the PR.
Thanks :user:`jab` and :user:`nicoddemus` for the PR.
* New ``-rp`` and ``-rP`` reporting options give the summary and full output
of passing tests, respectively. Thanks to `@codewarrior0`_ for the PR.
of passing tests, respectively. Thanks to :user:`codewarrior0` for the PR.
* ``pytest.mark.xfail`` now has a ``strict`` option which makes ``XPASS``
tests to fail the test suite, defaulting to ``False``. There's also a
``xfail_strict`` ini option that can be used to configure it project-wise.
Thanks `@rabbbit`_ for the request and `@nicoddemus`_ for the PR (`#1355`_).
Thanks :user:`rabbbit` for the request and :user:`nicoddemus` for the PR (:issue:`1355`).
* ``Parser.addini`` now supports options of type ``bool``. Thanks
`@nicoddemus`_ for the PR.
:user:`nicoddemus` for the PR.
* New ``ALLOW_BYTES`` doctest option strips ``b`` prefixes from byte strings
in doctest output (similar to ``ALLOW_UNICODE``).
Thanks `@jaraco`_ for the request and `@nicoddemus`_ for the PR (`#1287`_).
Thanks :user:`jaraco` for the request and :user:`nicoddemus` for the PR (:issue:`1287`).
* give a hint on KeyboardInterrupt to use the --fulltrace option to show the errors,
this fixes `#1366`_.
Thanks to `@hpk42`_ for the report and `@RonnyPfannschmidt`_ for the PR.
this fixes :issue:`1366`.
Thanks to :user:`hpk42` for the report and :user:`RonnyPfannschmidt` for the PR.
* catch IndexError exceptions when getting exception source location. This fixes
pytest internal error for dynamically generated code (fixtures and tests)
@@ -91,69 +91,44 @@ The py.test Development Team
`pylib <https://pylib.readthedocs.io/en/stable/>`_.
* ``pytest_enter_pdb`` now optionally receives the pytest config object.
Thanks `@nicoddemus`_ for the PR.
Thanks :user:`nicoddemus` for the PR.
* Removed code and documentation for Python 2.5 or lower versions,
including removal of the obsolete ``_pytest.assertion.oldinterpret`` module.
Thanks `@nicoddemus`_ for the PR (`#1226`_).
Thanks :user:`nicoddemus` for the PR (:issue:`1226`).
* Comparisons now always show up in full when ``CI`` or ``BUILD_NUMBER`` is
found in the environment, even when -vv isn't used.
Thanks `@The-Compiler`_ for the PR.
Thanks :user:`The-Compiler` for the PR.
* ``--lf`` and ``--ff`` now support long names: ``--last-failed`` and
``--failed-first`` respectively.
Thanks `@MichaelAquilina`_ for the PR.
Thanks :user:`MichaelAquilina` for the PR.
* Added expected exceptions to pytest.raises fail message
* Collection only displays progress ("collecting X items") when in a terminal.
This avoids cluttering the output when using ``--color=yes`` to obtain
colors in CI integrations systems (`#1397`_).
colors in CI integrations systems (:issue:`1397`).
**Bug Fixes**
* The ``-s`` and ``-c`` options should now work under ``xdist``;
``Config.fromdictargs`` now represents its input much more faithfully.
Thanks to `@bukzor`_ for the complete PR (`#680`_).
Thanks to :user:`bukzor` for the complete PR (:issue:`680`).
* Fix (`#1290`_): support Python 3.5's ``@`` operator in assertion rewriting.
Thanks `@Shinkenjoe`_ for report with test case and `@tomviner`_ for the PR.
* Fix (:issue:`1290`): support Python 3.5's ``@`` operator in assertion rewriting.
Thanks :user:`Shinkenjoe` for report with test case and :user:`tomviner` for the PR.
* Fix formatting utf-8 explanation messages (`#1379`_).
Thanks `@biern`_ for the PR.
* Fix formatting utf-8 explanation messages (:issue:`1379`).
Thanks :user:`biern` for the PR.
* Fix `traceback style docs`_ to describe all of the available options
(auto/long/short/line/native/no), with ``auto`` being the default since v2.6.
Thanks `@hackebrot`_ for the PR.
Thanks :user:`hackebrot` for the PR.
* Fix (`#1422`_): junit record_xml_property doesn't allow multiple records
* Fix (:issue:`1422`): junit record_xml_property doesn't allow multiple records
with same name.
.. _`traceback style docs`: https://pytest.org/en/stable/usage.html#modifying-python-traceback-printing
.. _#1422: https://github.com/pytest-dev/pytest/issues/1422
.. _#1379: https://github.com/pytest-dev/pytest/issues/1379
.. _#1366: https://github.com/pytest-dev/pytest/issues/1366
.. _#1040: https://github.com/pytest-dev/pytest/pull/1040
.. _#680: https://github.com/pytest-dev/pytest/issues/680
.. _#1287: https://github.com/pytest-dev/pytest/pull/1287
.. _#1226: https://github.com/pytest-dev/pytest/pull/1226
.. _#1290: https://github.com/pytest-dev/pytest/pull/1290
.. _#1355: https://github.com/pytest-dev/pytest/pull/1355
.. _#1397: https://github.com/pytest-dev/pytest/issues/1397
.. _@biern: https://github.com/biern
.. _@MichaelAquilina: https://github.com/MichaelAquilina
.. _@bukzor: https://github.com/bukzor
.. _@hpk42: https://github.com/hpk42
.. _@nicoddemus: https://github.com/nicoddemus
.. _@jab: https://github.com/jab
.. _@codewarrior0: https://github.com/codewarrior0
.. _@jaraco: https://github.com/jaraco
.. _@The-Compiler: https://github.com/The-Compiler
.. _@Shinkenjoe: https://github.com/Shinkenjoe
.. _@tomviner: https://github.com/tomviner
.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
.. _@rabbbit: https://github.com/rabbbit
.. _@hackebrot: https://github.com/hackebrot
.. _`traceback style docs`: https://pytest.org/en/stable/how-to/output.html#modifying-python-traceback-printing

View File

@@ -37,31 +37,21 @@ The py.test Development Team
**Bug Fixes**
* Improve error message when a plugin fails to load.
Thanks `@nicoddemus`_ for the PR.
Thanks :user:`nicoddemus` for the PR.
* Fix (`#1178 <https://github.com/pytest-dev/pytest/issues/1178>`_):
* Fix (:issue:`1178`):
``pytest.fail`` with non-ascii characters raises an internal pytest error.
Thanks `@nicoddemus`_ for the PR.
Thanks :user:`nicoddemus` for the PR.
* Fix (`#469`_): junit parses report.nodeid incorrectly, when params IDs
contain ``::``. Thanks `@tomviner`_ for the PR (`#1431`_).
* Fix (:issue:`469`): junit parses report.nodeid incorrectly, when params IDs
contain ``::``. Thanks :user:`tomviner` for the PR (:pull:`1431`).
* Fix (`#578 <https://github.com/pytest-dev/pytest/issues/578>`_): SyntaxErrors
* Fix (:issue:`578`): SyntaxErrors
containing non-ascii lines at the point of failure generated an internal
py.test error.
Thanks `@asottile`_ for the report and `@nicoddemus`_ for the PR.
Thanks :user:`asottile` for the report and :user:`nicoddemus` for the PR.
* Fix (`#1437`_): When passing in a bytestring regex pattern to parameterize
* Fix (:issue:`1437`): When passing in a bytestring regex pattern to parameterize
attempt to decode it as utf-8 ignoring errors.
* Fix (`#649`_): parametrized test nodes cannot be specified to run on the command line.
.. _#1437: https://github.com/pytest-dev/pytest/issues/1437
.. _#469: https://github.com/pytest-dev/pytest/issues/469
.. _#1431: https://github.com/pytest-dev/pytest/pull/1431
.. _#649: https://github.com/pytest-dev/pytest/issues/649
.. _@asottile: https://github.com/asottile
.. _@nicoddemus: https://github.com/nicoddemus
.. _@tomviner: https://github.com/tomviner
* Fix (:issue:`649`): parametrized test nodes cannot be specified to run on the command line.

View File

@@ -39,40 +39,27 @@ The py.test Development Team
**Bug Fixes**
* fix `#510`_: skip tests where one parameterize dimension was empty
thanks Alex Stapleton for the Report and `@RonnyPfannschmidt`_ for the PR
* fix :issue:`510`: skip tests where one parameterize dimension was empty
thanks Alex Stapleton for the Report and :user:`RonnyPfannschmidt` for the PR
* Fix Xfail does not work with condition keyword argument.
Thanks `@astraw38`_ for reporting the issue (`#1496`_) and `@tomviner`_
for PR the (`#1524`_).
Thanks :user:`astraw38` for reporting the issue (:issue:`1496`) and :user:`tomviner`
for PR the (:pull:`1524`).
* Fix win32 path issue when putting custom config file with absolute path
in ``pytest.main("-c your_absolute_path")``.
* Fix maximum recursion depth detection when raised error class is not aware
of unicode/encoded bytes.
Thanks `@prusse-martin`_ for the PR (`#1506`_).
Thanks :user:`prusse-martin` for the PR (:pull:`1506`).
* Fix ``pytest.mark.skip`` mark when used in strict mode.
Thanks `@pquentin`_ for the PR and `@RonnyPfannschmidt`_ for
Thanks :user:`pquentin` for the PR and :user:`RonnyPfannschmidt` for
showing how to fix the bug.
* Minor improvements and fixes to the documentation.
Thanks `@omarkohl`_ for the PR.
Thanks :user:`omarkohl` for the PR.
* Fix ``--fixtures`` to show all fixture definitions as opposed to just
one per fixture name.
Thanks to `@hackebrot`_ for the PR.
.. _#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/issues/1496
.. _#1524: https://github.com/pytest-dev/pytest/pull/1524
.. _@astraw38: https://github.com/astraw38
.. _@hackebrot: https://github.com/hackebrot
.. _@omarkohl: https://github.com/omarkohl
.. _@pquentin: https://github.com/pquentin
.. _@prusse-martin: https://github.com/prusse-martin
.. _@RonnyPfannschmidt: https://github.com/RonnyPfannschmidt
.. _@tomviner: https://github.com/tomviner
Thanks to :user:`hackebrot` for the PR.

View File

@@ -0,0 +1,20 @@
pytest-6.2.1
=======================================
pytest 6.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Bruno Oliveira
* Jakob van Santen
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,21 @@
pytest-6.2.2
=======================================
pytest 6.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Adam Johnson
* Bruno Oliveira
* Chris NeJame
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,19 @@
pytest-6.2.3
=======================================
pytest 6.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Bruno Oliveira
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,22 @@
pytest-6.2.4
=======================================
pytest 6.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Anthony Sottile
* Bruno Oliveira
* Christian Maurer
* Florian Bruhin
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,30 @@
pytest-6.2.5
=======================================
pytest 6.2.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Anthony Sottile
* Bruno Oliveira
* Brylie Christopher Oxley
* Daniel Asztalos
* Florian Bruhin
* Jason Haugen
* MapleCCC
* Michał Górny
* Miro Hrončok
* Ran Benita
* Ronny Pfannschmidt
* Sylvain Bellemare
* Thomas Güttler
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,74 @@
pytest-7.0.0
=======================================
The pytest team is proud to announce the 7.0.0 release!
This release contains new features, improvements, bug fixes, and breaking changes, so users
are encouraged to take a look at the CHANGELOG carefully:
https://docs.pytest.org/en/stable/changelog.html
For complete documentation, please visit:
https://docs.pytest.org/en/stable/
As usual, you can upgrade from PyPI via:
pip install -U pytest
Thanks to all of the contributors to this release:
* Adam J. Stewart
* Alexander King
* Amin Alaee
* Andrew Neitsch
* Anthony Sottile
* Ben Davies
* Bernát Gábor
* Brian Okken
* Bruno Oliveira
* Cristian Vera
* Dan Alvizu
* David Szotten
* Eddie
* Emmanuel Arias
* Emmanuel Meric de Bellefon
* Eric Liu
* Florian Bruhin
* GergelyKalmar
* Graeme Smecher
* Harshna
* Hugo van Kemenade
* Jakub Kulík
* James Myatt
* Jeff Rasley
* Kale Kundert
* Kian Meng, Ang
* Miro Hrončok
* Naveen-Pratap
* Oleg Höfling
* Olga Matoula
* Ran Benita
* Ronny Pfannschmidt
* Simon K
* Srip
* Sören Wegener
* Taneli Hukkinen
* Terje Runde
* Thomas Grainger
* Thomas Hisch
* William Jamir Silva
* Yuval Shimon
* Zac Hatfield-Dodds
* andrewdotn
* denivyruck
* ericluoliu
* oleg.hoefling
* symonk
* ziebam
* Éloi Rivard
* Éric
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,74 @@
pytest-7.0.0rc1
=======================================
The pytest team is proud to announce the 7.0.0rc1 prerelease!
This is a prerelease, not intended for production use, but to test the upcoming features and improvements
in order to catch any major problems before the final version is released to the major public.
We appreciate your help testing this out before the final release, making sure to report any
regressions to our issue tracker:
https://github.com/pytest-dev/pytest/issues
When doing so, please include the string ``[prerelease]`` in the title.
You can upgrade from PyPI via:
pip install pytest==7.0.0rc1
Users are encouraged to take a look at the CHANGELOG carefully:
https://docs.pytest.org/en/7.0.x/changelog.html
Thanks to all the contributors to this release:
* Adam J. Stewart
* Alexander King
* Amin Alaee
* Andrew Neitsch
* Anthony Sottile
* Ben Davies
* Bernát Gábor
* Brian Okken
* Bruno Oliveira
* Cristian Vera
* David Szotten
* Eddie
* Emmanuel Arias
* Emmanuel Meric de Bellefon
* Eric Liu
* Florian Bruhin
* GergelyKalmar
* Graeme Smecher
* Harshna
* Hugo van Kemenade
* Jakub Kulík
* James Myatt
* Jeff Rasley
* Kale Kundert
* Miro Hrončok
* Naveen-Pratap
* Oleg Höfling
* Ran Benita
* Ronny Pfannschmidt
* Simon K
* Srip
* Sören Wegener
* Taneli Hukkinen
* Terje Runde
* Thomas Grainger
* Thomas Hisch
* William Jamir Silva
* Zac Hatfield-Dodds
* andrewdotn
* denivyruck
* ericluoliu
* oleg.hoefling
* symonk
* ziebam
* Éloi Rivard
Happy testing,
The pytest Development Team

View File

@@ -0,0 +1,20 @@
pytest-7.0.1
=======================================
pytest 7.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/stable/changelog.html.
Thanks to all of the contributors to this release:
* Anthony Sottile
* Bruno Oliveira
* Ran Benita
Happy testing,
The pytest Development Team

View File

@@ -22,7 +22,9 @@ b) transitional: the old and new API don't conflict
We will only start the removal of deprecated functionality in major releases (e.g. if we deprecate something in 3.0 we will start to remove it in 4.0), and keep it around for at least two minor releases (e.g. if we deprecate something in 3.9 and 4.0 is the next release, we start to remove it in 5.0, not in 4.0).
When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn them into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
A deprecated feature scheduled to be removed in major version X will use the warning class `PytestRemovedInXWarning` (a subclass of :class:`~pytest.PytestDeprecationwarning`).
When the deprecation expires (e.g. 4.0 is released), we won't remove the deprecated functionality immediately, but will use the standard warning filters to turn `PytestRemovedInXWarning` (e.g. `PytestRemovedIn4Warning`) into **errors** by default. This approach makes it explicit that removal is imminent, and still gives you time to turn the deprecated feature into a warning instead of an error so it can be dealt with in your own time. In the next minor release (e.g. 4.1), the feature will be effectively removed.
c) true breakage: should only be considered when normal transition is unreasonably unsustainable and would offset important development/features by years.
@@ -30,15 +32,15 @@ c) true breakage: should only be considered when normal transition is unreasonab
Examples for such upcoming changes:
* removal of ``pytest_runtest_protocol/nextitem`` - `#895`_
* removal of ``pytest_runtest_protocol/nextitem`` - :issue:`895`
* rearranging of the node tree to include ``FunctionDefinition``
* rearranging of ``SetupState`` `#895`_
* rearranging of ``SetupState`` :issue:`895`
True breakages must be announced first in an issue containing:
* Detailed description of the change
* Rationale
* Expected impact on users and plugin authors (example in `#895`_)
* Expected impact on users and plugin authors (example in :issue:`895`)
After there's no hard *-1* on the issue it should be followed up by an initial proof-of-concept Pull Request.
@@ -75,6 +77,3 @@ Deprecation Roadmap
Features currently deprecated and removed in previous releases can be found in :ref:`deprecations`.
We track future deprecation and removal of features using milestones and the `deprecation <https://github.com/pytest-dev/pytest/issues?q=label%3A%22type%3A+deprecation%22>`_ and `removal <https://github.com/pytest-dev/pytest/labels/type%3A%20removal>`_ labels on GitHub.
.. _`#895`: https://github.com/pytest-dev/pytest/issues/895

View File

@@ -6,7 +6,7 @@ Pytest API and builtin fixtures
================================================
Most of the information of this page has been moved over to :ref:`reference`.
Most of the information of this page has been moved over to :ref:`api-reference`.
For information on plugin hooks and objects, see :ref:`plugins`.
@@ -16,8 +16,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
.. code-block:: pytest
$ pytest -q --fixtures
cache
$ pytest --fixtures -v
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collected 0 items
cache -- .../_pytest/cacheprovider.py:510
Return a cache object that can persist state between testing sessions.
cache.get(key, default)
@@ -28,40 +33,41 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
Values can be any object handled by the json stdlib module.
capsys
capsys -- .../_pytest/capture.py:878
Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
The captured output is made available via ``capsys.readouterr()`` method
calls, which return a ``(out, err)`` namedtuple.
``out`` and ``err`` will be ``text`` objects.
capsysbinary
capsysbinary -- .../_pytest/capture.py:895
Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
The captured output is made available via ``capsysbinary.readouterr()``
method calls, which return a ``(out, err)`` namedtuple.
``out`` and ``err`` will be ``bytes`` objects.
capfd
capfd -- .../_pytest/capture.py:912
Enable text capturing of writes to file descriptors ``1`` and ``2``.
The captured output is made available via ``capfd.readouterr()`` method
calls, which return a ``(out, err)`` namedtuple.
``out`` and ``err`` will be ``text`` objects.
capfdbinary
capfdbinary -- .../_pytest/capture.py:929
Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
The captured output is made available via ``capfd.readouterr()`` method
calls, which return a ``(out, err)`` namedtuple.
``out`` and ``err`` will be ``byte`` objects.
doctest_namespace [session scope]
doctest_namespace [session scope] -- .../_pytest/doctest.py:731
Fixture that returns a :py:class:`dict` that will be injected into the
namespace of doctests.
pytestconfig [session scope]
Session-scoped fixture that returns the :class:`_pytest.config.Config` object.
pytestconfig [session scope] -- .../_pytest/fixtures.py:1365
Session-scoped fixture that returns the session's :class:`pytest.Config`
object.
Example::
@@ -69,7 +75,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
if pytestconfig.getoption("verbose") > 0:
...
record_property
record_property -- .../_pytest/junitxml.py:282
Add extra properties to the calling test.
User properties become part of the test report and are available to the
@@ -83,13 +89,13 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
def test_function(record_property):
record_property("example_key", 1)
record_xml_attribute
record_xml_attribute -- .../_pytest/junitxml.py:305
Add extra xml attributes to the tag for the calling test.
The fixture is callable with ``name, value``. The value is
automatically XML-encoded.
record_testsuite_property [session scope]
record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
Record a new ``<property>`` tag as child of the root ``<testsuite>``.
This is suitable to writing global information regarding the entire test
@@ -108,10 +114,27 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
.. warning::
Currently this fixture **does not work** with the
`pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See issue
`#7767 <https://github.com/pytest-dev/pytest/issues/7767>`__ for details.
`pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
:issue:`7767` for details.
caplog
tmpdir_factory [session scope] -- .../_pytest/legacypath.py:295
Return a :class:`pytest.TempdirFactory` instance for the test session.
tmpdir -- .../_pytest/legacypath.py:302
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
By default, a new base temporary directory is created each test session,
and old bases are removed after 3 sessions, to aid in debugging. If
``--basetemp`` is used then it is cleared each session. See :ref:`base
temporary directory`.
The returned object is a `legacy_path`_ object.
.. _legacy_path: https://py.readthedocs.io/en/latest/path.html
caplog -- .../_pytest/logging.py:483
Access and control log capturing.
Captured logs are available through the following properties/methods::
@@ -122,7 +145,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
* caplog.record_tuples -> list of (logger_name, level, message) tuples
* caplog.clear() -> clear captured records and formatted log output string
monkeypatch
monkeypatch -- .../_pytest/monkeypatch.py:29
A convenient fixture for monkey-patching.
The fixture provides these methods to modify objects, dictionaries or
@@ -132,7 +155,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
monkeypatch.delattr(obj, name, raising=True)
monkeypatch.setitem(mapping, name, value)
monkeypatch.delitem(obj, name, raising=True)
monkeypatch.setenv(name, value, prepend=False)
monkeypatch.setenv(name, value, prepend=None)
monkeypatch.delenv(name, raising=True)
monkeypatch.syspath_prepend(path)
monkeypatch.chdir(path)
@@ -141,33 +164,16 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
fixture has finished. The ``raising`` parameter determines if a KeyError
or AttributeError will be raised if the set/deletion operation has no target.
recwarn
recwarn -- .../_pytest/recwarn.py:29
Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
See http://docs.python.org/library/warnings.html for information
See https://docs.python.org/library/how-to/capture-warnings.html for information
on warning categories.
tmpdir_factory [session scope]
Return a :class:`_pytest.tmpdir.TempdirFactory` instance for the test session.
tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:183
Return a :class:`pytest.TempPathFactory` instance for the test session.
tmp_path_factory [session scope]
Return a :class:`_pytest.tmpdir.TempPathFactory` instance for the test session.
tmpdir
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
By default, a new base temporary directory is created each test session,
and old bases are removed after 3 sessions, to aid in debugging. If
``--basetemp`` is used then it is cleared each session. See :ref:`base
temporary directory`.
The returned object is a `py.path.local`_ path object.
.. _`py.path.local`: https://py.readthedocs.io/en/latest/path.html
tmp_path
tmp_path -- .../_pytest/tmpdir.py:198
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.
@@ -180,7 +186,7 @@ For information about fixtures, see :ref:`fixtures`. To see a complete list of a
The returned object is a :class:`pathlib.Path` object.
no tests ran in 0.12s
========================== no tests ran in 0.12s ===========================
You can also interactively ask for help, e.g. by typing on the Python interactive prompt something like:

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,9 @@
# The short X.Y version.
import ast
import os
import shutil
import sys
from textwrap import dedent
from typing import List
from typing import TYPE_CHECKING
@@ -35,8 +37,26 @@ release = ".".join(version.split(".")[:2])
# sys.path.insert(0, os.path.abspath('.'))
autodoc_member_order = "bysource"
autodoc_typehints = "description"
todo_include_todos = 1
latex_engine = "lualatex"
latex_elements = {
"preamble": dedent(
r"""
\directlua{
luaotfload.add_fallback("fallbacks", {
"Noto Serif CJK SC:style=Regular;",
"Symbola:Style=Regular;"
})
}
\setmainfont{FreeSerif}[RawFeature={fallback=fallbacks}]
"""
)
}
# -- General configuration -----------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
@@ -49,6 +69,7 @@ extensions = [
"pygments_pytest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
@@ -56,6 +77,13 @@ extensions = [
"sphinxcontrib_trio",
]
# Building PDF docs on readthedocs requires inkscape for svg to pdf
# conversion. The relevant plugin is not useful for normal HTML builds, but
# it still raises warnings and fails CI if inkscape is not available. So
# only use the plugin if inkscape is actually available.
if shutil.which("inkscape"):
extensions.append("sphinxcontrib.inkscapeconverter")
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
@@ -70,7 +98,7 @@ master_doc = "contents"
# General information about the project.
project = "pytest"
copyright = "20152020, holger krekel and pytest-dev team"
copyright = "2015, holger krekel and pytest-dev team"
# The language for content autogenerated by Sphinx. Refer to documentation
@@ -122,7 +150,6 @@ pygments_style = "sphinx"
# 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+",
@@ -133,6 +160,16 @@ linkcheck_ignore = [
linkcheck_workers = 5
_repo = "https://github.com/pytest-dev/pytest"
extlinks = {
"bpo": ("https://bugs.python.org/issue%s", "bpo-"),
"pypi": ("https://pypi.org/project/%s/", ""),
"issue": (f"{_repo}/issues/%s", "issue #"),
"pull": (f"{_repo}/pull/%s", "pull request #"),
"user": ("https://github.com/%s", "@"),
}
# -- Options for HTML output ---------------------------------------------------
sys.path.append(os.path.abspath("_themes"))
@@ -159,7 +196,7 @@ html_short_title = "pytest-%s" % release
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = "img/pytest1.png"
html_logo = "img/pytest_logo_curves.svg"
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -251,7 +288,7 @@ latex_documents = [
"contents",
"pytest.tex",
"pytest Documentation",
"holger krekel, trainer and consultant, http://merlinux.eu",
"holger krekel, trainer and consultant, https://merlinux.eu/",
"manual",
)
]
@@ -292,7 +329,7 @@ man_pages = [("usage", "pytest", "pytest usage", ["holger krekel at merlinux eu"
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"
epub_copyright = "2013, holger krekel et alii"
# The language of the text. It defaults to the language option
# or en if the language is not set.
@@ -347,8 +384,17 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"pluggy": ("https://pluggy.readthedocs.io/en/latest", None),
"pluggy": ("https://pluggy.readthedocs.io/en/stable", None),
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable", None),
"pip": ("https://pip.pypa.io/en/stable", None),
"tox": ("https://tox.wiki/en/stable", None),
"virtualenv": ("https://virtualenv.pypa.io/en/stable", None),
"django": (
"http://docs.djangoproject.com/en/stable",
"http://docs.djangoproject.com/en/stable/_objects",
),
"setuptools": ("https://setuptools.pypa.io/en/stable", None),
}
@@ -399,6 +445,13 @@ def setup(app: "sphinx.application.Sphinx") -> None:
indextemplate="pair: %s; global variable interpreted by pytest",
)
app.add_crossref_type(
directivename="hook",
rolename="hook",
objname="pytest hook",
indextemplate="pair: %s; hook",
)
configure_logging(app)
# Make Sphinx mark classes with "final" when decorated with @final.
@@ -419,3 +472,7 @@ def setup(app: "sphinx.application.Sphinx") -> None:
)
sphinx.pycode.parser.VariableCommentPicker.is_final = patched_is_final
# legacypath.py monkey-patches pytest.Testdir in. Import the file so
# that autodoc can discover references to it.
import _pytest.legacypath # noqa: F401

View File

@@ -7,21 +7,24 @@ Contact channels
- `pytest issue tracker`_ to report bugs or suggest features (for version
2.0 and above).
- `pytest discussions`_ at github for general questions.
- `pytest discord server <https://discord.com/invite/pytest-dev>`_
for pytest development visibility and general assistance.
- `pytest on stackoverflow.com <http://stackoverflow.com/search?q=pytest>`_
to post questions with the tag ``pytest``. New Questions will usually
to post precise questions with the tag ``pytest``. New Questions will usually
be seen by pytest users or developers and answered quickly.
- `Testing In Python`_: a mailing list for Python testing tools and discussion.
- `pytest-dev at python.org (mailing list)`_ pytest specific announcements and discussions.
- `pytest-commit at python.org (mailing list)`_: for commits and new issues
- :doc:`contribution guide <contributing>` for help on submitting pull
requests to GitHub.
- ``#pylib`` on irc.freenode.net IRC channel for random questions.
- ``#pytest`` `on irc.libera.chat <ircs://irc.libera.chat:6697/#pytest>`_ IRC
channel for random questions (using an IRC client, `via webchat
<https://web.libera.chat/#pytest>`_, or `via Matrix
<https://matrix.to/#/%23pytest:libera.chat>`_).
- private mail to Holger.Krekel at gmail com if you want to communicate sensitive issues
@@ -30,19 +33,21 @@ Contact channels
consulting.
.. _`pytest issue tracker`: https://github.com/pytest-dev/pytest/issues
.. _`old issue tracker`: http://bitbucket.org/hpk42/py-trunk/issues/
.. _`old issue tracker`: https://bitbucket.org/hpk42/py-trunk/issues/
.. _`merlinux.eu`: http://merlinux.eu
.. _`pytest discussions`: https://github.com/pytest-dev/pytest/discussions
.. _`merlinux.eu`: https://merlinux.eu/
.. _`get an account`:
.. _tetamap: http://tetamap.wordpress.com
.. _tetamap: https://tetamap.wordpress.com/
.. _`@pylibcommit`: http://twitter.com/pylibcommit
.. _`@pylibcommit`: https://twitter.com/pylibcommit
.. _`Testing in Python`: http://lists.idyll.org/listinfo/testing-in-python
.. _FOAF: http://en.wikipedia.org/wiki/FOAF
.. _FOAF: https://en.wikipedia.org/wiki/FOAF
.. _`py-dev`:
.. _`development mailing list`:
.. _`pytest-dev at python.org (mailing list)`: http://mail.python.org/mailman/listinfo/pytest-dev

View File

@@ -7,37 +7,81 @@ Full pytest documentation
.. `Download latest version as EPUB <http://media.readthedocs.org/epub/pytest/latest/pytest.epub>`_
Start here
-----------
.. toctree::
:maxdepth: 2
getting-started
usage
existingtestsuite
assert
fixture
mark
monkeypatch
tmpdir
capture
warnings
doctest
skipping
parametrize
cache
unittest
nose
xunit_setup
plugins
writing_plugins
logging
reference
goodpractices
flaky
pythonpath
customize
How-to guides
-------------
.. toctree::
:maxdepth: 2
how-to/usage
how-to/assert
how-to/fixtures
how-to/mark
how-to/parametrize
how-to/tmp_path
how-to/monkeypatch
how-to/doctest
how-to/cache
how-to/logging
how-to/capture-stdout-stderr
how-to/capture-warnings
how-to/skipping
how-to/plugins
how-to/writing_plugins
how-to/writing_hook_functions
how-to/existingtestsuite
how-to/unittest
how-to/nose
how-to/xunit_setup
how-to/bash-completion
Reference guides
-----------------
.. toctree::
:maxdepth: 2
reference/fixtures
reference/plugin_list
reference/customize
reference/reference
Explanation
-----------------
.. toctree::
:maxdepth: 2
explanation/anatomy
explanation/fixtures
explanation/goodpractices
explanation/flaky
explanation/pythonpath
Further topics
-----------------
.. toctree::
:maxdepth: 2
example/index
bash-completion
backwards-compatibility
deprecations
@@ -51,9 +95,9 @@ Full pytest documentation
license
contact
history
historical-notes
talks
projects
.. only:: html

View File

@@ -18,6 +18,253 @@ Deprecated Features
Below is a complete list of all pytest features which are considered deprecated. Using those features will issue
:class:`PytestWarning` or subclasses, which can be filtered using :ref:`standard warning filters <warnings>`.
.. _instance-collector-deprecation:
The ``pytest.Instance`` collector
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionremoved:: 7.0
The ``pytest.Instance`` collector type has been removed.
Previously, Python test methods were collected as :class:`~pytest.Class` -> ``Instance`` -> :class:`~pytest.Function`.
Now :class:`~pytest.Class` collects the test methods directly.
Most plugins which reference ``Instance`` do so in order to ignore or skip it,
using a check such as ``if isinstance(node, Instance): return``.
Such plugins should simply remove consideration of ``Instance`` on pytest>=7.
However, to keep such uses working, a dummy type has been instanted in ``pytest.Instance`` and ``_pytest.python.Instance``,
and importing it emits a deprecation warning. This will be removed in pytest 8.
.. _node-ctor-fspath-deprecation:
``fspath`` argument for Node constructors replaced with ``pathlib.Path``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
In order to support the transition from ``py.path.local`` to :mod:`pathlib`,
the ``fspath`` argument to :class:`~_pytest.nodes.Node` constructors like
:func:`pytest.Function.from_parent()` and :func:`pytest.Class.from_parent()`
is now deprecated.
Plugins which construct nodes should pass the ``path`` argument, of type
:class:`pathlib.Path`, instead of the ``fspath`` argument.
Plugins which implement custom items and collectors are encouraged to replace
``fspath`` parameters (``py.path.local``) with ``path`` parameters
(``pathlib.Path``), and drop any other usage of the ``py`` library if possible.
If possible, plugins with custom items should use :ref:`cooperative
constructors <uncooperative-constructors-deprecated>` to avoid hardcoding
arguments they only pass on to the superclass.
.. note::
The name of the :class:`~_pytest.nodes.Node` arguments and attributes (the
new attribute being ``path``) is **the opposite** of the situation for
hooks, :ref:`outlined below <legacy-path-hooks-deprecated>` (the old
argument being ``path``).
This is an unfortunate artifact due to historical reasons, which should be
resolved in future versions as we slowly get rid of the :pypi:`py`
dependency (see :issue:`9283` for a longer discussion).
Due to the ongoing migration of methods like :meth:`~_pytest.Item.reportinfo`
which still is expected to return a ``py.path.local`` object, nodes still have
both ``fspath`` (``py.path.local``) and ``path`` (``pathlib.Path``) attributes,
no matter what argument was used in the constructor. We expect to deprecate the
``fspath`` attribute in a future release.
.. _legacy-path-hooks-deprecated:
``py.path.local`` arguments for hooks replaced with ``pathlib.Path``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
In order to support the transition from ``py.path.local`` to :mod:`pathlib`, the following hooks now receive additional arguments:
* :hook:`pytest_ignore_collect(collection_path: pathlib.Path) <pytest_ignore_collect>` as equivalent to ``path``
* :hook:`pytest_collect_file(file_path: pathlib.Path) <pytest_collect_file>` as equivalent to ``path``
* :hook:`pytest_pycollect_makemodule(module_path: pathlib.Path) <pytest_pycollect_makemodule>` as equivalent to ``path``
* :hook:`pytest_report_header(start_path: pathlib.Path) <pytest_report_header>` as equivalent to ``startdir``
* :hook:`pytest_report_collectionfinish(start_path: pathlib.Path) <pytest_report_collectionfinish>` as equivalent to ``startdir``
The accompanying ``py.path.local`` based paths have been deprecated: plugins which manually invoke those hooks should only pass the new ``pathlib.Path`` arguments, and users should change their hook implementations to use the new ``pathlib.Path`` arguments.
.. note::
The name of the :class:`~_pytest.nodes.Node` arguments and attributes,
:ref:`outlined above <node-ctor-fspath-deprecation>` (the new attribute
being ``path``) is **the opposite** of the situation for hooks (the old
argument being ``path``).
This is an unfortunate artifact due to historical reasons, which should be
resolved in future versions as we slowly get rid of the :pypi:`py`
dependency (see :issue:`9283` for a longer discussion).
Directly constructing internal classes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Directly constructing the following classes is now deprecated:
- ``_pytest.mark.structures.Mark``
- ``_pytest.mark.structures.MarkDecorator``
- ``_pytest.mark.structures.MarkGenerator``
- ``_pytest.python.Metafunc``
- ``_pytest.runner.CallInfo``
- ``_pytest._code.ExceptionInfo``
- ``_pytest.config.argparsing.Parser``
- ``_pytest.config.argparsing.OptionGroup``
- ``_pytest.pytester.HookRecorder``
These constructors have always been considered private, but now issue a deprecation warning, which may become a hard error in pytest 8.
.. _cmdline-preparse-deprecated:
Passing ``msg=`` to ``pytest.skip``, ``pytest.fail`` or ``pytest.exit``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Passing the keyword argument ``msg`` to :func:`pytest.skip`, :func:`pytest.fail` or :func:`pytest.exit`
is now deprecated and ``reason`` should be used instead. This change is to bring consistency between these
functions and the ``@pytest.mark.skip`` and ``@pytest.mark.xfail`` markers which already accept a ``reason`` argument.
.. code-block:: python
def test_fail_example():
# old
pytest.fail(msg="foo")
# new
pytest.fail(reason="bar")
def test_skip_example():
# old
pytest.skip(msg="foo")
# new
pytest.skip(reason="bar")
def test_exit_example():
# old
pytest.exit(msg="foo")
# new
pytest.exit(reason="bar")
Implementing the ``pytest_cmdline_preparse`` hook
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Implementing the :hook:`pytest_cmdline_preparse` hook has been officially deprecated.
Implement the :hook:`pytest_load_initial_conftests` hook instead.
.. code-block:: python
def pytest_cmdline_preparse(config: Config, args: List[str]) -> None:
...
# becomes:
def pytest_load_initial_conftests(
early_config: Config, parser: Parser, args: List[str]
) -> None:
...
.. _diamond-inheritance-deprecated:
Diamond inheritance between :class:`pytest.Collector` and :class:`pytest.Item`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Defining a custom pytest node type which is both an :class:`pytest.Item <Item>` and a :class:`pytest.Collector <Collector>` (e.g. :class:`pytest.File <File>`) now issues a warning.
It was never sanely supported and triggers hard to debug errors.
Some plugins providing linting/code analysis have been using this as a hack.
Instead, a separate collector node should be used, which collects the item. See
:ref:`non-python tests` for an example, as well as an `example pr fixing inheritance`_.
.. _example pr fixing inheritance: https://github.com/asmeurer/pytest-flakes/pull/40/files
.. _uncooperative-constructors-deprecated:
Constructors of custom :class:`pytest.Node` subclasses should take ``**kwargs``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
If custom subclasses of nodes like :class:`pytest.Item` override the
``__init__`` method, they should take ``**kwargs``. Thus,
.. code-block:: python
class CustomItem(pytest.Item):
def __init__(self, name, parent, additional_arg):
super().__init__(name, parent)
self.additional_arg = additional_arg
should be turned into:
.. code-block:: python
class CustomItem(pytest.Item):
def __init__(self, *, additional_arg, **kwargs):
super().__init__(**kwargs)
self.additional_arg = additional_arg
to avoid hard-coding the arguments pytest can pass to the superclass.
See :ref:`non-python tests` for a full example.
For cases without conflicts, no deprecation warning is emitted. For cases with
conflicts (such as :class:`pytest.File` now taking ``path`` instead of
``fspath``, as :ref:`outlined above <node-ctor-fspath-deprecation>`), a
deprecation warning is now raised.
Backward compatibilities in ``Parser.addoption``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 2.4
Several behaviors of :meth:`Parser.addoption <pytest.Parser.addoption>` are now
scheduled for removal in pytest 8 (deprecated since pytest 2.4.0):
- ``parser.addoption(..., help=".. %default ..")`` - use ``%(default)s`` instead.
- ``parser.addoption(..., type="int/string/float/complex")`` - use ``type=int`` etc. instead.
Raising ``unittest.SkipTest`` during collection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
Raising :class:`unittest.SkipTest` to skip collection of tests during the
pytest collection phase is deprecated. Use :func:`pytest.skip` instead.
Note: This deprecation only relates to using `unittest.SkipTest` during test
collection. You are probably not doing that. Ordinary usage of
:class:`unittest.SkipTest` / :meth:`unittest.TestCase.skipTest` /
:func:`unittest.skip` in unittest test cases is fully supported.
Using ``pytest.warns(None)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 7.0
:func:`pytest.warns(None) <pytest.warns>` is now deprecated because it was frequently misused.
Its correct usage was checking that the code emits at least one warning of any type - like ``pytest.warns()``
or ``pytest.warns(Warning)``.
See :ref:`warns use cases` for examples.
The ``--strict`` command-line option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -92,6 +339,7 @@ A ``--show-capture`` command-line option was added in ``pytest 3.5.0`` which all
display captured output when tests fail: ``no``, ``stdout``, ``stderr``, ``log`` or ``all`` (the default).
.. _resultlog deprecated:
Result log (``--result-log``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -114,8 +362,8 @@ at some point, depending on the plans for the plugins and number of users using
.. versionremoved:: 6.0
The ``pytest_collect_directory`` has not worked properly for years (it was called
but the results were ignored). Users may consider using :func:`pytest_collection_modifyitems <_pytest.hookspec.pytest_collection_modifyitems>` instead.
The ``pytest_collect_directory`` hook has not worked properly for years (it was called
but the results were ignored). Users may consider using :hook:`pytest_collection_modifyitems` instead.
TerminalReporter.writer
~~~~~~~~~~~~~~~~~~~~~~~
@@ -129,6 +377,8 @@ with ``py.io.TerminalWriter``.
Plugins that used ``TerminalReporter.writer`` directly should instead use ``TerminalReporter``
methods that provide the same functionality.
.. _junit-family changed default value:
``junit_family`` default value change to "xunit2"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -216,6 +466,8 @@ in places where we or plugin authors must distinguish between fixture names and
names supplied by non-fixture things such as ``pytest.mark.parametrize``.
.. _pytest.config global deprecated:
``pytest.config`` global
~~~~~~~~~~~~~~~~~~~~~~~~
@@ -260,7 +512,7 @@ Becomes:
If you still have concerns about this deprecation and future removal, please comment on
`issue #3974 <https://github.com/pytest-dev/pytest/issues/3974>`__.
:issue:`3974`.
.. _raises-warns-exec:
@@ -313,6 +565,8 @@ This issue should affect only advanced plugins who create new collection types,
message please contact the authors so they can change the code.
.. _marks in pytest.parametrize deprecated:
marks in ``pytest.mark.parametrize``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -361,6 +615,8 @@ To update the code, use ``pytest.param``:
...
.. _pytest_funcarg__ prefix deprecated:
``pytest_funcarg__`` prefix
~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -392,13 +648,15 @@ Switch over to the ``@pytest.fixture`` decorator:
to avoid conflicts with other distutils commands.
.. _metafunc.addcall deprecated:
Metafunc.addcall
~~~~~~~~~~~~~~~~
.. versionremoved:: 4.0
``_pytest.python.Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use
:meth:`_pytest.python.Metafunc.parametrize` instead.
``Metafunc.addcall`` was a precursor to the current parametrized mechanism. Users should use
:meth:`pytest.Metafunc.parametrize` instead.
Example:
@@ -416,6 +674,8 @@ Becomes:
metafunc.parametrize("i", [1, 2], ids=["1", "2"])
.. _cached_setup deprecated:
``cached_setup``
~~~~~~~~~~~~~~~~
@@ -444,10 +704,12 @@ This should be updated to make use of standard fixture mechanisms:
session.close()
You can consult `funcarg comparison section in the docs <https://docs.pytest.org/en/stable/funcarg_compare.html>`_ for
You can consult :std:doc:`funcarg comparison section in the docs <funcarg_compare>` for
more information.
.. _pytest_plugins in non-top-level conftest files deprecated:
pytest_plugins in non-top-level conftest files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -458,6 +720,8 @@ files because they will activate referenced plugins *globally*, which is surpris
features ``conftest.py`` files are only *active* for tests at or below it.
.. _config.warn and node.warn deprecated:
``Config.warn`` and ``Node.warn``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -485,6 +749,8 @@ Becomes:
* ``node.warn("CI", "some message")``: this code/message form has been **removed** and should be converted to the warning instance form above.
.. _record_xml_property deprecated:
record_xml_property
~~~~~~~~~~~~~~~~~~~
@@ -508,6 +774,8 @@ Change to:
...
.. _passing command-line string to pytest.main deprecated:
Passing command-line string to ``pytest.main()``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -530,6 +798,8 @@ By passing a string, users expect that pytest will interpret that command-line u
on (for example ``bash`` or ``Powershell``), but this is very hard/impossible to do in a portable way.
.. _calling fixtures directly deprecated:
Calling fixtures directly
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -583,6 +853,8 @@ with the ``name`` parameter:
return cell()
.. _yield tests deprecated:
``yield`` tests
~~~~~~~~~~~~~~~
@@ -611,6 +883,8 @@ This form of test function doesn't support fixtures properly, and users should s
def test_squared(x, y):
assert x ** x == y
.. _internal classes accessed through node deprecated:
Internal classes accessed through ``Node``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -645,6 +919,8 @@ As part of a large :ref:`marker-revamp` we already deprecated using ``MarkInfo``
the only correct way to get markers of an element is via ``node.iter_markers(name)``.
.. _pytest.namespace deprecated:
``pytest_namespace``
~~~~~~~~~~~~~~~~~~~~

View File

@@ -4,4 +4,4 @@ Development Guide
The contributing guidelines are to be found :ref:`here <contributing>`.
The release procedure for pytest is documented on
`GitHub <https://github.com/pytest-dev/pytest/blob/master/RELEASING.rst>`_.
`GitHub <https://github.com/pytest-dev/pytest/blob/main/RELEASING.rst>`_.

View File

@@ -5,9 +5,9 @@ failure_demo = os.path.join(os.path.dirname(__file__), "failure_demo.py")
pytest_plugins = ("pytester",)
def test_failure_demo_fails_properly(testdir):
target = testdir.tmpdir.join(os.path.basename(failure_demo))
def test_failure_demo_fails_properly(pytester):
target = pytester.path.joinpath(os.path.basename(failure_demo))
shutil.copy(failure_demo, target)
result = testdir.runpytest(target, syspathinsert=True)
result = pytester.runpytest(target, syspathinsert=True)
result.stdout.fnmatch_lines(["*44 failed*"])
assert result.ret != 0

View File

@@ -0,0 +1,132 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="572" height="542">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class, circle.module, circle.package {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class, text.module, text.package {
fill: #0e84b5;
}
line, path {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<!-- main scope -->
<circle class="package" r="270" cx="286" cy="271" />
<!-- scope name -->
<defs>
<path d="M 26,271 A 260 260 0 0 1 546 271" id="testp"/>
</defs>
<text class="package">
<textPath xlink:href="#testp" startOffset="50%">tests</textPath>
</text>
<!-- subpackage -->
<circle class="package" r="140" cx="186" cy="271" />
<!-- scope name -->
<defs>
<path d="M 56,271 A 130 130 0 0 1 316 271" id="subpackage"/>
</defs>
<text class="package">
<textPath xlink:href="#subpackage" startOffset="50%">subpackage</textPath>
</text>
<!-- test_subpackage.py -->
<circle class="module" r="90" cx="186" cy="311" />
<!-- scope name -->
<defs>
<path d="M 106,311 A 80 80 0 0 1 266 311" id="testSubpackage"/>
</defs>
<text class="module">
<textPath xlink:href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
</text>
<!-- innermost -->
<line x1="186" x2="186" y1="271" y2="351"/>
<!-- mid -->
<path d="M 186 351 L 136 351 L 106 331 L 106 196" />
<!-- order -->
<path d="M 186 351 L 256 351 L 316 291 L 316 136" />
<!-- top -->
<path d="M 186 351 L 186 391 L 231 436 L 331 436" />
<ellipse class="fixture" rx="50" ry="25" cx="186" cy="271" />
<text x="186" y="271">innermost</text>
<rect class="test" width="110" height="50" x="131" y="326" />
<text x="186" y="351">test_order</text>
<ellipse class="fixture" rx="50" ry="25" cx="126" cy="196" />
<text x="126" y="196">mid</text>
<!-- scope order number -->
<mask id="testSubpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="90" cx="186" cy="311" />
</mask>
<circle class="module" r="15" cx="96" cy="311" mask="url(#testSubpackageOrderMask)"/>
<text class="module" x="96" y="311">1</text>
<!-- scope order number -->
<mask id="subpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="140" cx="186" cy="271" />
</mask>
<circle class="module" r="15" cx="46" cy="271" mask="url(#subpackageOrderMask)"/>
<text class="module" x="46" y="271">2</text>
<!-- scope order number -->
<mask id="testsOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="270" cx="286" cy="271" />
</mask>
<circle class="module" r="15" cx="16" cy="271" mask="url(#testsOrderMask)"/>
<text class="module" x="16" y="271">3</text>
<!-- test_top.py -->
<circle class="module" r="85" cx="441" cy="271" />
<!-- scope name -->
<defs>
<path d="M 366,271 A 75 75 0 0 1 516 271" id="testTop"/>
</defs>
<text class="module">
<textPath xlink:href="#testTop" startOffset="50%">test_top.py</textPath>
</text>
<!-- innermost -->
<line x1="441" x2="441" y1="306" y2="236"/>
<!-- order -->
<path d="M 441 306 L 376 306 L 346 276 L 346 136" />
<!-- top -->
<path d="M 441 306 L 441 411 L 411 436 L 331 436" />
<ellipse class="fixture" rx="50" ry="25" cx="441" cy="236" />
<text x="441" y="236">innermost</text>
<rect class="test" width="110" height="50" x="386" y="281" />
<text x="441" y="306">test_order</text>
<!-- scope order number -->
<mask id="testTopOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="85" cx="441" cy="271" />
</mask>
<circle class="module" r="15" cx="526" cy="271" mask="url(#testTopOrderMask)"/>
<text class="module" x="526" y="271">1</text>
<!-- scope order number -->
<circle class="module" r="15" cx="556" cy="271" mask="url(#testsOrderMask)"/>
<text class="module" x="556" y="271">2</text>
<ellipse class="fixture" rx="50" ry="25" cx="331" cy="436" />
<text x="331" y="436">top</text>
<ellipse class="fixture" rx="50" ry="25" cx="331" cy="136" />
<text x="331" y="136">order</text>
</svg>

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

@@ -0,0 +1,142 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="587" height="382">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
alignment-baseline: center;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class, circle.module, circle.package, circle.plugin {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class, text.module, text.package, text.plugin {
fill: #0e84b5;
}
line, path {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<!-- plugin_a.py scope -->
<circle class="plugin" r="85" cx="486" cy="86" />
<!-- plugin name -->
<defs>
<path d="M 411,86 A 75 75 0 0 1 561 86" id="pluginA"/>
</defs>
<text class="plugin">
<textPath xlink:href="#pluginA" startOffset="50%">plugin_a</textPath>
</text>
<!-- scope order number -->
<mask id="pluginAOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="85" cx="486" cy="86" />
</mask>
<circle class="module" r="15" cx="571" cy="86" mask="url(#pluginAOrderMask)"/>
<text class="module" x="571" y="86">4</text>
<!-- plugin_b.py scope -->
<circle class="plugin" r="85" cx="486" cy="296" />
<!-- plugin name -->
<defs>
<path d="M 411,296 A 75 75 0 0 1 561 296" id="pluginB"/>
</defs>
<text class="plugin">
<textPath xlink:href="#pluginB" startOffset="50%">plugin_b</textPath>
</text>
<!-- scope order number -->
<mask id="pluginBOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="85" cx="486" cy="296" />
</mask>
<circle class="module" r="15" cx="571" cy="296" mask="url(#pluginBOrderMask)"/>
<text class="module" x="571" y="296">4</text>
<!-- main scope -->
<circle class="package" r="190" cx="191" cy="191" />
<!-- scope name -->
<defs>
<path d="M 11,191 A 180 180 0 0 1 371 191" id="testp"/>
</defs>
<text class="package">
<textPath xlink:href="#testp" startOffset="50%">tests</textPath>
</text>
<!-- scope order number -->
<mask id="mainOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="190" cx="191" cy="191" />
</mask>
<circle class="module" r="15" cx="381" cy="191" mask="url(#mainOrderMask)"/>
<text class="module" x="381" y="191">3</text>
<!-- subpackage -->
<circle class="package" r="140" cx="191" cy="231" />
<!-- scope name -->
<defs>
<path d="M 61,231 A 130 130 0 0 1 321 231" id="subpackage"/>
</defs>
<text class="package">
<textPath xlink:href="#subpackage" startOffset="50%">subpackage</textPath>
</text>
<!-- scope order number -->
<mask id="subpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="140" cx="191" cy="231" />
</mask>
<circle class="module" r="15" cx="331" cy="231" mask="url(#subpackageOrderMask)"/>
<text class="module" x="331" y="231">2</text>
<!-- test_subpackage.py -->
<circle class="module" r="90" cx="191" cy="271" />
<!-- scope name -->
<defs>
<path d="M 111,271 A 80 80 0 0 1 271 271" id="testSubpackage"/>
</defs>
<text class="module">
<textPath xlink:href="#testSubpackage" startOffset="50%">test_subpackage.py</textPath>
</text>
<!-- scope order number -->
<mask id="testSubpackageOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="90" cx="191" cy="271" />
</mask>
<circle class="module" r="15" cx="281" cy="271" mask="url(#testSubpackageOrderMask)"/>
<text class="module" x="281" y="271">1</text>
<!-- innermost -->
<line x1="191" x2="191" y1="231" y2="311"/>
<!-- mid -->
<path d="M 191 306 L 101 306 L 91 296 L 91 156 L 101 146 L 191 146" />
<!-- order -->
<path d="M 191 316 L 91 316 L 81 306 L 81 61 L 91 51 L 191 51" />
<!-- a_fix -->
<path d="M 191 306 L 291 306 L 301 296 L 301 96 L 311 86 L 486 86" />
<!-- b_fix -->
<path d="M 191 316 L 316 316 L 336 296 L 486 296" />
<ellipse class="fixture" rx="50" ry="25" cx="191" cy="231" />
<text x="191" y="231">inner</text>
<rect class="test" width="110" height="50" x="136" y="286" />
<text x="191" y="311">test_order</text>
<ellipse class="fixture" rx="50" ry="25" cx="191" cy="146" />
<text x="191" y="146">mid</text>
<ellipse class="fixture" rx="50" ry="25" cx="191" cy="51" />
<text x="191" y="51">order</text>
<ellipse class="fixture" rx="50" ry="25" cx="486" cy="86" />
<text x="486" y="86">a_fix</text>
<ellipse class="fixture" rx="50" ry="25" cx="486" cy="296" />
<text x="486" y="296">b_fix</text>
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@@ -1,38 +0,0 @@
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

@@ -0,0 +1,45 @@
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def a(order):
order.append("a")
@pytest.fixture
def b(a, order):
order.append("b")
@pytest.fixture(autouse=True)
def c(b, order):
order.append("c")
@pytest.fixture
def d(b, order):
order.append("d")
@pytest.fixture
def e(d, order):
order.append("e")
@pytest.fixture
def f(e, order):
order.append("f")
@pytest.fixture
def g(f, c, order):
order.append("g")
def test_order_and_g(g, order):
assert order == ["a", "b", "c", "d", "e", "f", "g"]

View File

@@ -0,0 +1,64 @@
<svg xmlns="http://www.w3.org/2000/svg" width="252" height="682">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
path, line {
stroke: black;
stroke-width: 2;
fill: none;
}
rect.autouse {
fill: #ca7f3d;
}
</style>
<path d="M126,586 L26,506 L26,236" />
<path d="M226,446 L226,236 L126,166" />
<line x1="126" x2="126" y1="656" y2="516" />
<line x1="126" x2="226" y1="516" y2="446" />
<line x1="226" x2="126" y1="446" y2="376" />
<line x1="126" x2="126" y1="376" y2="166" />
<line x1="26" x2="126" y1="236" y2="166" />
<line x1="126" x2="126" y1="166" y2="26" />
<line x1="126" x2="126" y1="96" y2="26" />
<rect class="autouse" width="251" height="40" x="0" y="286" />
<text x="126" y="306">autouse</text>
<ellipse class="fixture" rx="50" ry="25" cx="126" cy="26" />
<text x="126" y="26">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="96" />
<text x="126" y="96">a</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="166" />
<text x="126" y="166">b</text>
<ellipse class="fixture" rx="25" ry="25" cx="26" cy="236" />
<text x="26" y="236">c</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="376" />
<text x="126" y="376">d</text>
<ellipse class="fixture" rx="25" ry="25" cx="226" cy="446" />
<text x="226" y="446">e</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="516" />
<text x="126" y="516">f</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="586" />
<text x="126" y="586">g</text>
<rect class="test" width="110" height="50" x="71" y="631" />
<text x="126" y="656">test_order</text>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,56 @@
<svg xmlns="http://www.w3.org/2000/svg" width="112" height="682">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
path, line {
stroke: black;
stroke-width: 2;
fill: none;
}
rect.autouse {
fill: #ca7f3d;
}
</style>
<line x1="56" x2="56" y1="681" y2="26" />
<ellipse class="fixture" rx="50" ry="25" cx="56" cy="26" />
<text x="56" y="26">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="96" />
<text x="56" y="96">a</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="166" />
<text x="56" y="166">b</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="236" />
<text x="56" y="236">c</text>
<rect class="autouse" width="112" height="40" x="0" y="286" />
<text x="56" y="306">autouse</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="376" />
<text x="56" y="376">d</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="446" />
<text x="56" y="446">e</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="516" />
<text x="56" y="516">f</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="586" />
<text x="56" y="586">g</text>
<rect class="test" width="110" height="50" x="1" y="631" />
<text x="56" y="656">test_order</text>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,31 @@
import pytest
@pytest.fixture(scope="class")
def order():
return []
@pytest.fixture(scope="class", autouse=True)
def c1(order):
order.append("c1")
@pytest.fixture(scope="class")
def c2(order):
order.append("c2")
@pytest.fixture(scope="class")
def c3(order, c1):
order.append("c3")
class TestClassWithC1Request:
def test_order(self, order, c1, c3):
assert order == ["c1", "c3"]
class TestClassWithoutC1Request:
def test_order(self, order, c2):
assert order == ["c1", "c2"]

View File

@@ -0,0 +1,76 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="862" height="402">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
line {
stroke: black;
stroke-width: 2;
}
rect.autouse {
fill: #ca7f3d;
}
</style>
<!-- TestWithC1Request -->
<circle class="class" r="200" cx="221" cy="201" />
<line x1="221" x2="221" y1="61" y2="316"/>
<ellipse class="fixture" rx="50" ry="25" cx="221" cy="61" />
<text x="221" y="61">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="221" cy="131" />
<text x="221" y="131">c1</text>
<ellipse class="fixture" rx="25" ry="25" cx="221" cy="271" />
<text x="221" y="271">c3</text>
<rect class="test" width="110" height="50" x="166" y="316" />
<text x="221" y="341">test_order</text>
<!-- scope name -->
<defs>
<path d="M31,201 A 190 190 0 0 1 411 201" id="testClassWith"/>
</defs>
<text class="class">
<textPath xlink:href="#testClassWith" startOffset="50%">TestWithC1Request</textPath>
</text>
<!-- TestWithoutC1Request -->
<circle class="class" r="200" cx="641" cy="201" />
<line x1="641" x2="641" y1="61" y2="316"/>
<ellipse class="fixture" rx="50" ry="25" cx="641" cy="61" />
<text x="641" y="61">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="641" cy="131" />
<text x="641" y="131">c1</text>
<ellipse class="fixture" rx="25" ry="25" cx="641" cy="271" />
<text x="641" y="271">c2</text>
<rect class="test" width="110" height="50" x="586" y="316" />
<text x="641" y="341">test_order</text>
<!-- scope name -->
<defs>
<path d="M451,201 A 190 190 0 0 1 831 201" id="testClassWithout"/>
</defs>
<text class="class">
<textPath xlink:href="#testClassWithout" startOffset="50%">TestWithoutC1Request</textPath>
</text>
<rect class="autouse" width="862" height="40" x="1" y="181" />
<rect width="10" height="100" class="autouse" x="426" y="151" />
<text x="431" y="201">autouse</text>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@@ -0,0 +1,36 @@
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def c1(order):
order.append("c1")
@pytest.fixture
def c2(order):
order.append("c2")
class TestClassWithAutouse:
@pytest.fixture(autouse=True)
def c3(self, order, c2):
order.append("c3")
def test_req(self, order, c1):
assert order == ["c2", "c3", "c1"]
def test_no_req(self, order):
assert order == ["c2", "c3"]
class TestClassWithoutAutouse:
def test_req(self, order, c1):
assert order == ["c1"]
def test_no_req(self, order):
assert order == []

View File

@@ -0,0 +1,100 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="862" height="502">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
line {
stroke: black;
stroke-width: 2;
}
rect.autouse {
fill: #ca7f3d;
}
</style>
<!-- TestWithAutouse -->
<circle class="class" r="250" cx="251" cy="251" />
<!-- scope name -->
<defs>
<path d="M11,251 A 240 240 0 0 1 491 251" id="testClassWith"/>
</defs>
<text class="class">
<textPath xlink:href="#testClassWith" startOffset="50%">TestWithAutouse</textPath>
</text>
<mask id="autouseScope">
<circle fill="white" r="249" cx="251" cy="251" />
</mask>
<!-- TestWithAutouse.test_req -->
<line x1="176" x2="176" y1="76" y2="426"/>
<ellipse class="fixture" rx="50" ry="25" cx="176" cy="76" />
<text x="176" y="76">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="176" cy="146" />
<text x="176" y="146">c2</text>
<ellipse class="fixture" rx="25" ry="25" cx="176" cy="216" />
<text x="176" y="216">c3</text>
<ellipse class="fixture" rx="25" ry="25" cx="176" cy="356" />
<text x="176" y="356">c1</text>
<rect class="test" width="100" height="50" x="126" y="401" />
<text x="176" y="426">test_req</text>
<!-- TestWithAutouse.test_no_req -->
<line x1="326" x2="326" y1="76" y2="346"/>
<ellipse class="fixture" rx="50" ry="25" cx="326" cy="76" />
<text x="326" y="76">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="326" cy="146" />
<text x="326" y="146">c2</text>
<ellipse class="fixture" rx="25" ry="25" cx="326" cy="216" />
<text x="326" y="216">c3</text>
<rect class="test" width="120" height="50" x="266" y="331" />
<text x="326" y="356">test_no_req</text>
<rect class="autouse" width="500" height="40" x="1" y="266" mask="url(#autouseScope)"/>
<text x="261" y="286">autouse</text>
<!-- TestWithoutAutouse -->
<circle class="class" r="170" cx="691" cy="251" />
<!-- scope name -->
<defs>
<path d="M 531,251 A 160 160 0 0 1 851 251" id="testClassWithout"/>
</defs>
<text class="class">
<textPath xlink:href="#testClassWithout" startOffset="50%">TestWithoutAutouse</textPath>
</text>
<!-- TestWithoutAutouse.test_req -->
<line x1="616" x2="616" y1="181" y2="321"/>
<ellipse class="fixture" rx="50" ry="25" cx="616" cy="181" />
<text x="616" y="181">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="616" cy="251" />
<text x="616" y="251">c1</text>
<rect class="test" width="100" height="50" x="566" y="296" />
<text x="616" y="321">test_req</text>
<!-- TestWithoutAutouse.test_no_req -->
<line x1="766" x2="766" y1="181" y2="251"/>
<ellipse class="fixture" rx="50" ry="25" cx="766" cy="181" />
<text x="766" y="181">order</text>
<rect class="test" width="120" height="50" x="706" y="226" />
<text x="766" y="251">test_no_req</text>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -0,0 +1,45 @@
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def a(order):
order.append("a")
@pytest.fixture
def b(a, order):
order.append("b")
@pytest.fixture
def c(a, b, order):
order.append("c")
@pytest.fixture
def d(c, b, order):
order.append("d")
@pytest.fixture
def e(d, b, order):
order.append("e")
@pytest.fixture
def f(e, order):
order.append("f")
@pytest.fixture
def g(f, c, order):
order.append("g")
def test_order(g, order):
assert order == ["a", "b", "c", "d", "e", "f", "g"]

View File

@@ -0,0 +1,60 @@
<svg xmlns="http://www.w3.org/2000/svg" width="252" height="612">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
path, line {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<path d="M126,516 L26,436 L26,236" />
<path d="M226,376 L226,236 L126,166" />
<line x1="126" x2="126" y1="586" y2="446" />
<line x1="126" x2="226" y1="446" y2="376" />
<line x1="226" x2="126" y1="376" y2="306" />
<line x1="126" x2="26" y1="306" y2="236" />
<line x1="126" x2="126" y1="306" y2="166" />
<line x1="26" x2="126" y1="236" y2="166" />
<line x1="126" x2="126" y1="166" y2="26" />
<line x1="126" x2="126" y1="96" y2="26" />
<ellipse class="fixture" rx="50" ry="25" cx="126" cy="26" />
<text x="126" y="26">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="96" />
<text x="126" y="96">a</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="166" />
<text x="126" y="166">b</text>
<ellipse class="fixture" rx="25" ry="25" cx="26" cy="236" />
<text x="26" y="236">c</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="306" />
<text x="126" y="306">d</text>
<ellipse class="fixture" rx="25" ry="25" cx="226" cy="376" />
<text x="226" y="376">e</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="446" />
<text x="126" y="446">f</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="516" />
<text x="126" y="516">g</text>
<rect class="test" width="110" height="50" x="71" y="561" />
<text x="126" y="586">test_order</text>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,51 @@
<svg xmlns="http://www.w3.org/2000/svg" width="112" height="612">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
path, line {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<line x1="56" x2="56" y1="611" y2="26" />
<ellipse class="fixture" rx="50" ry="25" cx="56" cy="26" />
<text x="56" y="26">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="96" />
<text x="56" y="96">a</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="166" />
<text x="56" y="166">b</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="236" />
<text x="56" y="236">c</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="306" />
<text x="56" y="306">d</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="376" />
<text x="56" y="376">e</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="446" />
<text x="56" y="446">f</text>
<ellipse class="fixture" rx="25" ry="25" cx="56" cy="516" />
<text x="56" y="516">g</text>
<rect class="test" width="110" height="50" x="1" y="561" />
<text x="56" y="586">test_order</text>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,60 @@
<svg xmlns="http://www.w3.org/2000/svg" width="252" height="542">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
path, line {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<path d="M126,446 L26,376 L26,236" />
<path d="M226,306 L126,236 L126,166" />
<line x1="126" x2="126" y1="516" y2="446" />
<line x1="226" x2="226" y1="376" y2="306" />
<line x1="226" x2="226" y1="306" y2="236" />
<line x1="226" x2="126" y1="236" y2="166" />
<line x1="126" x2="226" y1="446" y2="376" />
<line x1="26" x2="126" y1="236" y2="166" />
<line x1="126" x2="126" y1="166" y2="96" />
<line x1="126" x2="126" y1="96" y2="26" />
<ellipse class="fixture" rx="50" ry="25" cx="126" cy="26" />
<text x="126" y="26">order</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="96" />
<text x="126" y="96">a</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="166" />
<text x="126" y="166">b</text>
<ellipse class="fixture" rx="25" ry="25" cx="26" cy="236" />
<text x="26" y="236">c</text>
<ellipse class="fixture" rx="25" ry="25" cx="226" cy="236" />
<text x="226" y="236">d</text>
<ellipse class="fixture" rx="25" ry="25" cx="226" cy="306" />
<text x="226" y="306">e</text>
<ellipse class="fixture" rx="25" ry="25" cx="226" cy="376" />
<text x="226" y="376">f</text>
<ellipse class="fixture" rx="25" ry="25" cx="126" cy="446" />
<text x="126" y="446">g</text>
<rect class="test" width="110" height="50" x="71" y="491" />
<text x="126" y="516">test_order</text>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -0,0 +1,36 @@
import pytest
@pytest.fixture(scope="session")
def order():
return []
@pytest.fixture
def func(order):
order.append("function")
@pytest.fixture(scope="class")
def cls(order):
order.append("class")
@pytest.fixture(scope="module")
def mod(order):
order.append("module")
@pytest.fixture(scope="package")
def pack(order):
order.append("package")
@pytest.fixture(scope="session")
def sess(order):
order.append("session")
class TestClass:
def test_order(self, func, cls, mod, pack, sess, order):
assert order == ["session", "package", "module", "class", "function"]

View File

@@ -0,0 +1,55 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="262" height="537">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class {
fill: #0e84b5;
}
line {
stroke: black;
stroke-width: 2;
}
</style>
<!-- TestClass -->
<circle class="class" r="130" cx="131" cy="406" />
<line x1="131" x2="131" y1="21" y2="446"/>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="26" />
<text x="131" y="26">order</text>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="96" />
<text x="131" y="96">sess</text>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="166" />
<text x="131" y="166">pack</text>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="236" />
<text x="131" y="236">mod</text>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="306" />
<text x="131" y="306">cls</text>
<ellipse class="fixture" rx="50" ry="25" cx="131" cy="376" />
<text x="131" y="376">func</text>
<rect class="test" width="110" height="50" x="76" y="421" />
<text x="131" y="446">test_order</text>
<!-- scope name -->
<defs>
<path d="M131,526 A 120 120 0 0 1 136 286" id="testClass"/>
</defs>
<text class="class">
<textPath xlink:href="#testClass" startOffset="50%">TestClass</textPath>
</text>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,29 @@
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def outer(order, inner):
order.append("outer")
class TestOne:
@pytest.fixture
def inner(self, order):
order.append("one")
def test_order(self, order, outer):
assert order == ["one", "outer"]
class TestTwo:
@pytest.fixture
def inner(self, order):
order.append("two")
def test_order(self, order, outer):
assert order == ["two", "outer"]

View File

@@ -0,0 +1,115 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="562" height="532">
<style>
text {
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
dominant-baseline: middle;
text-anchor: middle;
fill: #062886;
font-size: medium;
}
ellipse.fixture, rect.test {
fill: #eeffcc;
stroke: #007020;
stroke-width: 2;
}
text.fixture {
color: #06287e;
}
circle.class {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
circle.module {
fill: #c3e0ec;
stroke: #0e84b5;
stroke-width: 2;
}
text.class, text.module {
fill: #0e84b5;
}
line, path {
stroke: black;
stroke-width: 2;
fill: none;
}
</style>
<!-- main scope -->
<circle class="module" r="265" cx="281" cy="266" />
<!-- scope name -->
<defs>
<path d="M 26,266 A 255 255 0 0 1 536 266" id="testModule"/>
</defs>
<text class="module">
<textPath xlink:href="#testModule" startOffset="50%">test_fixtures_request_different_scope.py</textPath>
</text>
<!-- TestOne -->
<circle class="class" r="100" cx="141" cy="266" />
<!-- inner -->
<line x1="141" x2="141" y1="231" y2="301"/>
<!-- order -->
<path d="M 141 296 L 201 296 L 211 286 L 211 146 L 221 136 L 281 136" />
<!-- outer -->
<path d="M 141 306 L 201 306 L 211 316 L 211 386 L 221 396 L 281 396" />
<ellipse class="fixture" rx="50" ry="25" cx="141" cy="231" />
<text x="141" y="231">inner</text>
<rect class="test" width="110" height="50" x="86" y="276" />
<text x="141" y="301">test_order</text>
<!-- scope name -->
<defs>
<path d="M 51,266 A 90 90 0 0 1 231 266" id="testOne"/>
</defs>
<text class="class">
<textPath xlink:href="#testOne" startOffset="50%">TestOne</textPath>
</text>
<!-- scope order number -->
<mask id="testOneOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="100" cx="141" cy="266" />
</mask>
<circle class="module" r="15" cx="41" cy="266" mask="url(#testOneOrderMask)"/>
<text class="module" x="41" y="266">1</text>
<!-- scope order number -->
<mask id="testMainOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="265" cx="281" cy="266" />
</mask>
<circle class="module" r="15" cx="16" cy="266" mask="url(#testMainOrderMask)"/>
<text class="module" x="16" y="266">2</text>
<!-- TestTwo -->
<circle class="class" r="100" cx="421" cy="266" />
<!-- inner -->
<line x1="421" x2="421" y1="231" y2="301"/>
<!-- order -->
<path d="M 421 296 L 361 296 L 351 286 L 351 146 L 341 136 L 281 136" />
<!-- outer -->
<path d="M 421 306 L 361 306 L 351 316 L 351 386 L 341 396 L 281 396" />
<ellipse class="fixture" rx="50" ry="25" cx="421" cy="231" />
<text x="421" y="231">inner</text>
<rect class="test" width="110" height="50" x="366" y="276" />
<text x="421" y="301">test_order</text>
<!-- scope name -->
<defs>
<path d="M 331,266 A 90 90 0 0 1 511 266" id="testTwo"/>
</defs>
<text class="class">
<textPath xlink:href="#testTwo" startOffset="50%">TestTwo</textPath>
</text>
<!-- scope order number -->
<mask id="testTwoOrderMask">
<rect x="0" y="0" width="100%" height="100%" fill="white"/>
<circle fill="black" stroke="white" stroke-width="2" r="100" cx="421" cy="266" />
</mask>
<circle class="module" r="15" cx="521" cy="266" mask="url(#testTwoOrderMask)"/>
<text class="module" x="521" y="266">1</text>
<!-- scope order number -->
<circle class="module" r="15" cx="546" cy="266" mask="url(#testMainOrderMask)"/>
<text class="module" x="546" y="266">2</text>
<ellipse class="fixture" rx="50" ry="25" cx="281" cy="396" />
<text x="281" y="396">outer</text>
<ellipse class="fixture" rx="50" ry="25" cx="281" cy="136" />
<text x="281" y="136">order</text>
</svg>

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -13,12 +13,12 @@ answers.
For basic examples, see
- :doc:`../getting-started` for basic introductory examples
- :ref:`get-started` for basic introductory examples
- :ref:`assert` for basic assertion examples
- :ref:`Fixtures <fixtures>` for basic fixture/setup examples
- :ref:`parametrize` for basic test function parametrization
- :doc:`../unittest` for basic unittest integration
- :doc:`../nose` for basic nosetests integration
- :ref:`unittest` for basic unittest integration
- :ref:`noseintegration` for basic nosetests integration
The following examples aim at various use cases you might encounter.

View File

@@ -45,9 +45,9 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 3 deselected / 1 selected
test_server.py::test_send_http PASSED [100%]
@@ -60,9 +60,9 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 1 deselected / 3 selected
test_server.py::test_something_quick PASSED [ 33%]
@@ -82,9 +82,9 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 1 item
test_server.py::TestClass::test_method PASSED [100%]
@@ -97,9 +97,9 @@ You can also select on the class:
$ pytest -v test_server.py::TestClass
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 1 item
test_server.py::TestClass::test_method PASSED [100%]
@@ -112,9 +112,9 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 2 items
test_server.py::TestClass::test_method PASSED [ 50%]
@@ -156,9 +156,9 @@ The expression matching is now case-insensitive.
$ pytest -v -k http # running with the above defined example module
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 3 deselected / 1 selected
test_server.py::test_send_http PASSED [100%]
@@ -171,9 +171,9 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 1 deselected / 3 selected
test_server.py::test_something_quick PASSED [ 33%]
@@ -188,9 +188,9 @@ Or to select "http" and "quick" tests:
$ pytest -k "http or quick" -v
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 4 items / 2 deselected / 2 selected
test_server.py::test_send_http PASSED [ 50%]
@@ -234,17 +234,17 @@ You can ask which markers exist for your test suite - the list includes our just
@pytest.mark.slow: mark test as slow.
@pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings
@pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
@pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
@pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif
@pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
@pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail
@pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
@pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/parametrize.html for more info and examples.
@pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/fixture.html#usefixtures
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
@pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
@@ -397,9 +397,8 @@ the test needs:
$ pytest -E stage2
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_someenv.py s [100%]
@@ -412,9 +411,8 @@ and here is one that specifies exactly the environment needed:
$ pytest -E stage1
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_someenv.py . [100%]
@@ -428,17 +426,17 @@ The ``--markers`` option always gives you a list of available markers:
$ pytest --markers
@pytest.mark.env(name): mark test to run only on named environment
@pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/warnings.html#pytest-mark-filterwarnings
@pytest.mark.filterwarnings(warning): add a warning filter to the given test. see https://docs.pytest.org/en/stable/how-to/capture-warnings.html#pytest-mark-filterwarnings
@pytest.mark.skip(reason=None): skip the given test function with an optional reason. Example: skip(reason="no way of currently testing this") skips the test.
@pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif
@pytest.mark.skipif(condition, ..., *, reason=...): skip the given test function if any of the conditions evaluate to True. Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-skipif
@pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail
@pytest.mark.xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): mark the test function as an expected failure if any of the conditions evaluate to True. Optionally specify a reason for better reporting and run=False if you don't even want to execute the test function. If only specific exception(s) are expected, you can list them in raises, and if the test fails in other ways, it will be reported as a true failure. See https://docs.pytest.org/en/stable/reference/reference.html#pytest-mark-xfail
@pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/parametrize.html for more info and examples.
@pytest.mark.parametrize(argnames, argvalues): call a test function multiple times passing in different arguments in turn. argvalues generally needs to be a list of values if argnames specifies only one name or a list of tuples of values if argnames specifies multiple names. Example: @parametrize('arg1', [1,2]) would lead to two calls of the decorated test function, one with arg1=1 and another with arg1=2.see https://docs.pytest.org/en/stable/how-to/parametrize.html for more info and examples.
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/fixture.html#usefixtures
@pytest.mark.usefixtures(fixturename1, fixturename2, ...): mark tests as needing all of the specified fixtures. see https://docs.pytest.org/en/stable/explanation/fixtures.html#usefixtures
@pytest.mark.tryfirst: mark a hook implementation function such that the plugin machinery will try to call it first/as early as possible.
@@ -488,7 +486,7 @@ The output is as follows:
.. code-block:: pytest
$ pytest -q -s
Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef>,), kwargs={})
Mark(name='my_marker', args=(<function hello_world at 0xdeadbeef0001>,), kwargs={})
.
1 passed in 0.12s
@@ -605,9 +603,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items
test_plat.py s.s. [100%]
@@ -622,9 +619,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items / 3 deselected / 1 selected
test_plat.py . [100%]
@@ -686,9 +682,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items / 2 deselected / 2 selected
test_module.py FF [100%]
@@ -713,9 +708,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items / 1 deselected / 3 selected
test_module.py FFF [100%]

View File

@@ -12,8 +12,8 @@ pythonlist = ["python3.5", "python3.6", "python3.7"]
@pytest.fixture(params=pythonlist)
def python1(request, tmpdir):
picklefile = tmpdir.join("data.pickle")
def python1(request, tmp_path):
picklefile = tmp_path / "data.pickle"
return Python(request.param, picklefile)
@@ -30,8 +30,8 @@ class Python:
self.picklefile = picklefile
def dumps(self, obj):
dumpfile = self.picklefile.dirpath("dump.py")
dumpfile.write(
dumpfile = self.picklefile.with_name("dump.py")
dumpfile.write_text(
textwrap.dedent(
r"""
import pickle
@@ -46,8 +46,8 @@ class Python:
subprocess.check_call((self.pythonpath, str(dumpfile)))
def load_and_is_true(self, expression):
loadfile = self.picklefile.dirpath("load.py")
loadfile.write(
loadfile = self.picklefile.with_name("load.py")
loadfile.write_text(
textwrap.dedent(
r"""
import pickle

View File

@@ -10,7 +10,6 @@ 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 Afshar's special purpose `pytest-yamlwsgi`_ plugin). This ``conftest.py`` will collect ``test*.yaml`` files and will execute the yaml-formatted content as custom tests:
@@ -22,16 +21,15 @@ You can create a simple example file:
.. include:: nonpython/test_simple.yaml
:literal:
and if you installed `PyYAML`_ or a compatible YAML-parser you can
and if you installed :pypi:`PyYAML` or a compatible YAML-parser you can
now execute the test specification:
.. code-block:: pytest
nonpython $ pytest test_simple.yaml
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project/nonpython
collected 2 items
test_simple.yaml F. [100%]
@@ -66,9 +64,9 @@ consulted when reporting in ``verbose`` mode:
nonpython $ pytest -v
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project/nonpython
collecting ... collected 2 items
test_simple.yaml::hello FAILED [ 50%]
@@ -92,9 +90,8 @@ interesting to just look at the collection tree:
nonpython $ pytest --collect-only
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/nonpython
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project/nonpython
collected 2 items
<Package nonpython>

View File

@@ -2,9 +2,9 @@
import pytest
def pytest_collect_file(parent, path):
if path.ext == ".yaml" and path.basename.startswith("test"):
return YamlFile.from_parent(parent, fspath=path)
def pytest_collect_file(parent, file_path):
if file_path.suffix == ".yaml" and file_path.name.startswith("test"):
return YamlFile.from_parent(parent, path=file_path)
class YamlFile(pytest.File):
@@ -12,14 +12,14 @@ class YamlFile(pytest.File):
# We need a yaml parser, e.g. PyYAML.
import yaml
raw = yaml.safe_load(self.fspath.open())
raw = yaml.safe_load(self.path.open())
for name, spec in sorted(raw.items()):
yield YamlItem.from_parent(self, name=name, spec=spec)
class YamlItem(pytest.Item):
def __init__(self, name, parent, spec):
super().__init__(name, parent)
def __init__(self, *, spec, **kwargs):
super().__init__(**kwargs)
self.spec = spec
def runtest(self):
@@ -40,7 +40,7 @@ class YamlItem(pytest.Item):
)
def reportinfo(self):
return self.fspath, 0, f"usecase: {self.name}"
return self.path, 0, f"usecase: {self.name}"
class YamlException(Exception):

View File

@@ -97,10 +97,10 @@ the argument name:
# content of test_time.py
import pytest
from datetime import datetime, timedelta
import pytest
testdata = [
(datetime(2001, 12, 12), datetime(2001, 12, 11), timedelta(1)),
(datetime(2001, 12, 11), datetime(2001, 12, 12), timedelta(-1)),
@@ -160,9 +160,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 8 items
<Module test_time.py>
@@ -183,9 +182,7 @@ together with the actual data, instead of listing them separately.
A quick port of "testscenarios"
------------------------------------
.. _`test scenarios`: https://pypi.org/project/testscenarios/
Here is a quick port to run tests configured with `test scenarios`_,
Here is a quick port to run tests configured with :pypi:`testscenarios`,
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`:
@@ -225,9 +222,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items
test_scenarios.py .... [100%]
@@ -240,17 +236,16 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items
<Module test_scenarios.py>
<Class TestSampleWithScenarios>
<Function test_demo1[basic]>
<Function test_demo2[basic]>
<Function test_demo1[advanced]>
<Function test_demo2[advanced]>
<Function test_demo1[basic]>
<Function test_demo2[basic]>
<Function test_demo1[advanced]>
<Function test_demo2[advanced]>
======================== 4 tests collected in 0.12s ========================
@@ -319,9 +314,8 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
<Module test_backends.py>
@@ -339,7 +333,7 @@ And then when we run the test:
================================= FAILURES =================================
_________________________ test_db_initialized[d2] __________________________
db = <conftest.DB2 object at 0xdeadbeef>
db = <conftest.DB2 object at 0xdeadbeef0001>
def test_db_initialized(db):
# a dummy test
@@ -418,9 +412,9 @@ The result of this test will be successful:
$ pytest -v test_indirect_list.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 1 item
test_indirect_list.py::test_indirect[a-b] PASSED [100%]
@@ -478,7 +472,7 @@ argument sets to use for each test function. Let's run it:
================================= FAILURES =================================
________________________ TestClass.test_equals[1-2] ________________________
self = <test_parametrize.TestClass object at 0xdeadbeef>, a = 1, b = 2
self = <test_parametrize.TestClass object at 0xdeadbeef0002>, a = 1, b = 2
def test_equals(self, a, b):
> assert a == b
@@ -508,11 +502,12 @@ Running it results in some skips if we don't have all the python interpreters in
.. code-block:: pytest
. $ pytest -rs -q multipython.py
ssssssssssss...ssssssssssss [100%]
sssssssssssssssssssssssssss [100%]
========================= short test summary info ==========================
SKIPPED [12] multipython.py:29: 'python3.5' not found
SKIPPED [12] multipython.py:29: 'python3.7' not found
3 passed, 24 skipped in 0.12s
SKIPPED [9] multipython.py:29: 'python3.5' not found
SKIPPED [9] multipython.py:29: 'python3.6' not found
SKIPPED [9] multipython.py:29: 'python3.7' not found
27 skipped in 0.12s
Indirect parametrization of optional implementations/imports
--------------------------------------------------------------------
@@ -572,9 +567,8 @@ If you run this with reporting for skips enabled:
$ pytest -rs test_module.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
test_module.py .s [100%]
@@ -634,16 +628,16 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
collecting ... collected 14 items / 11 deselected / 3 selected
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
rootdir: /home/sweet/project
collecting ... collected 24 items / 21 deselected / 3 selected
test_pytest_param_example.py::test_eval[1+7-8] PASSED [ 33%]
test_pytest_param_example.py::test_eval[basic_2+4] PASSED [ 66%]
test_pytest_param_example.py::test_eval[basic_6*9] XFAIL [100%]
=============== 2 passed, 11 deselected, 1 xfailed in 0.12s ================
=============== 2 passed, 21 deselected, 1 xfailed in 0.12s ================
As the result:

View File

@@ -147,15 +147,14 @@ The test collection would look like this:
$ pytest --collect-only
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project, configfile: pytest.ini
collected 2 items
<Module check_myapp.py>
<Class CheckMyApp>
<Function simple_check>
<Function complex_check>
<Function simple_check>
<Function complex_check>
======================== 2 tests collected in 0.12s ========================
@@ -209,16 +208,15 @@ You can always peek at the collection tree without running tests like this:
. $ pytest --collect-only pythoncollection.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project, configfile: pytest.ini
collected 3 items
<Module CWD/pythoncollection.py>
<Function test_function>
<Class TestClass>
<Function test_method>
<Function test_anothermethod>
<Function test_method>
<Function test_anothermethod>
======================== 3 tests collected in 0.12s ========================
@@ -291,9 +289,8 @@ file will be left out:
$ pytest --collect-only
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR, configfile: pytest.ini
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project, configfile: pytest.ini
collected 0 items
======================= no tests collected in 0.12s ========================

View File

@@ -9,9 +9,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
assertion $ pytest failure_demo.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR/assertion
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project/assertion
collected 44 items
failure_demo.py FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [100%]
@@ -29,7 +28,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:19: AssertionError
_________________________ TestFailing.test_simple __________________________
self = <failure_demo.TestFailing object at 0xdeadbeef>
self = <failure_demo.TestFailing object at 0xdeadbeef0001>
def test_simple(self):
def f():
@@ -40,13 +39,13 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert f() == g()
E assert 42 == 43
E + where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef>()
E + and 43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef>()
E + where 42 = <function TestFailing.test_simple.<locals>.f at 0xdeadbeef0002>()
E + and 43 = <function TestFailing.test_simple.<locals>.g at 0xdeadbeef0003>()
failure_demo.py:30: AssertionError
____________________ TestFailing.test_simple_multiline _____________________
self = <failure_demo.TestFailing object at 0xdeadbeef>
self = <failure_demo.TestFailing object at 0xdeadbeef0004>
def test_simple_multiline(self):
> otherfunc_multi(42, 6 * 9)
@@ -63,7 +62,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:14: AssertionError
___________________________ TestFailing.test_not ___________________________
self = <failure_demo.TestFailing object at 0xdeadbeef>
self = <failure_demo.TestFailing object at 0xdeadbeef0005>
def test_not(self):
def f():
@@ -71,12 +70,12 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert not f()
E assert not 42
E + where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef>()
E + where 42 = <function TestFailing.test_not.<locals>.f at 0xdeadbeef0006>()
failure_demo.py:39: AssertionError
_________________ TestSpecialisedExplanations.test_eq_text _________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0007>
def test_eq_text(self):
> assert "spam" == "eggs"
@@ -87,7 +86,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:44: AssertionError
_____________ TestSpecialisedExplanations.test_eq_similar_text _____________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0008>
def test_eq_similar_text(self):
> assert "foo 1 bar" == "foo 2 bar"
@@ -100,7 +99,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:47: AssertionError
____________ TestSpecialisedExplanations.test_eq_multiline_text ____________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0009>
def test_eq_multiline_text(self):
> assert "foo\nspam\nbar" == "foo\neggs\nbar"
@@ -113,7 +112,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:50: AssertionError
______________ TestSpecialisedExplanations.test_eq_long_text _______________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000a>
def test_eq_long_text(self):
a = "1" * 100 + "a" + "2" * 100
@@ -130,7 +129,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:55: AssertionError
_________ TestSpecialisedExplanations.test_eq_long_text_multiline __________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000b>
def test_eq_long_text_multiline(self):
a = "1\n" * 100 + "a" + "2\n" * 100
@@ -150,7 +149,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:60: AssertionError
_________________ TestSpecialisedExplanations.test_eq_list _________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000c>
def test_eq_list(self):
> assert [0, 1, 2] == [0, 1, 3]
@@ -161,7 +160,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:63: AssertionError
______________ TestSpecialisedExplanations.test_eq_list_long _______________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000d>
def test_eq_list_long(self):
a = [0] * 100 + [1] + [3] * 100
@@ -174,7 +173,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:68: AssertionError
_________________ TestSpecialisedExplanations.test_eq_dict _________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000e>
def test_eq_dict(self):
> assert {"a": 0, "b": 1, "c": 0} == {"a": 0, "b": 2, "d": 0}
@@ -192,7 +191,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:71: AssertionError
_________________ TestSpecialisedExplanations.test_eq_set __________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef000f>
def test_eq_set(self):
> assert {0, 10, 11, 12} == {0, 20, 21}
@@ -210,7 +209,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:74: AssertionError
_____________ TestSpecialisedExplanations.test_eq_longer_list ______________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0010>
def test_eq_longer_list(self):
> assert [1, 2] == [1, 2, 3]
@@ -221,7 +220,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:77: AssertionError
_________________ TestSpecialisedExplanations.test_in_list _________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0011>
def test_in_list(self):
> assert 1 in [0, 2, 3, 4, 5]
@@ -230,7 +229,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:80: AssertionError
__________ TestSpecialisedExplanations.test_not_in_text_multiline __________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0012>
def test_not_in_text_multiline(self):
text = "some multiline\ntext\nwhich\nincludes foo\nand a\ntail"
@@ -249,7 +248,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:84: AssertionError
___________ TestSpecialisedExplanations.test_not_in_text_single ____________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0013>
def test_not_in_text_single(self):
text = "single foo line"
@@ -262,7 +261,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:88: AssertionError
_________ TestSpecialisedExplanations.test_not_in_text_single_long _________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0014>
def test_not_in_text_single_long(self):
text = "head " * 50 + "foo " + "tail " * 20
@@ -275,7 +274,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:92: AssertionError
______ TestSpecialisedExplanations.test_not_in_text_single_long_term _______
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0015>
def test_not_in_text_single_long_term(self):
text = "head " * 50 + "f" * 70 + "tail " * 20
@@ -288,7 +287,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:96: AssertionError
______________ TestSpecialisedExplanations.test_eq_dataclass _______________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0016>
def test_eq_dataclass(self):
from dataclasses import dataclass
@@ -315,7 +314,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:108: AssertionError
________________ TestSpecialisedExplanations.test_eq_attrs _________________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef0017>
def test_eq_attrs(self):
import attr
@@ -349,7 +348,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
i = Foo()
> assert i.b == 2
E assert 1 == 2
E + where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef>.b
E + where 1 = <failure_demo.test_attribute.<locals>.Foo object at 0xdeadbeef0018>.b
failure_demo.py:128: AssertionError
_________________________ test_attribute_instance __________________________
@@ -360,8 +359,8 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert Foo().b == 2
E AssertionError: assert 1 == 2
E + where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef>.b
E + where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
E + where 1 = <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019>.b
E + where <failure_demo.test_attribute_instance.<locals>.Foo object at 0xdeadbeef0019> = <class 'failure_demo.test_attribute_instance.<locals>.Foo'>()
failure_demo.py:135: AssertionError
__________________________ test_attribute_failure __________________________
@@ -379,7 +378,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:146:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef>
self = <failure_demo.test_attribute_failure.<locals>.Foo object at 0xdeadbeef001a>
def _get_b(self):
> raise Exception("Failed to get attrib")
@@ -397,15 +396,15 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert Foo().b == Bar().b
E AssertionError: assert 1 == 2
E + where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef>.b
E + where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
E + and 2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef>.b
E + where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
E + where 1 = <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b>.b
E + where <failure_demo.test_attribute_multiple.<locals>.Foo object at 0xdeadbeef001b> = <class 'failure_demo.test_attribute_multiple.<locals>.Foo'>()
E + and 2 = <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c>.b
E + where <failure_demo.test_attribute_multiple.<locals>.Bar object at 0xdeadbeef001c> = <class 'failure_demo.test_attribute_multiple.<locals>.Bar'>()
failure_demo.py:156: AssertionError
__________________________ TestRaises.test_raises __________________________
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef001d>
def test_raises(self):
s = "qwe"
@@ -415,7 +414,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:166: ValueError
______________________ TestRaises.test_raises_doesnt _______________________
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef001e>
def test_raises_doesnt(self):
> raises(OSError, int, "3")
@@ -424,7 +423,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:169: Failed
__________________________ TestRaises.test_raise ___________________________
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef001f>
def test_raise(self):
> raise ValueError("demo error")
@@ -433,7 +432,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:172: ValueError
________________________ TestRaises.test_tupleerror ________________________
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef0020>
def test_tupleerror(self):
> a, b = [1] # NOQA
@@ -442,7 +441,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:175: ValueError
______ TestRaises.test_reinterpret_fails_with_print_for_the_fun_of_it ______
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef0021>
def test_reinterpret_fails_with_print_for_the_fun_of_it(self):
items = [1, 2, 3]
@@ -455,7 +454,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
items is [1, 2, 3]
________________________ TestRaises.test_some_error ________________________
self = <failure_demo.TestRaises object at 0xdeadbeef>
self = <failure_demo.TestRaises object at 0xdeadbeef0022>
def test_some_error(self):
> if namenotexi: # NOQA
@@ -486,7 +485,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
abc-123:2: AssertionError
____________________ TestMoreErrors.test_complex_error _____________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0023>
def test_complex_error(self):
def f():
@@ -512,7 +511,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:6: AssertionError
___________________ TestMoreErrors.test_z1_unpack_error ____________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0024>
def test_z1_unpack_error(self):
items = []
@@ -522,7 +521,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:217: ValueError
____________________ TestMoreErrors.test_z2_type_error _____________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0025>
def test_z2_type_error(self):
items = 3
@@ -532,20 +531,20 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:221: TypeError
______________________ TestMoreErrors.test_startswith ______________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0026>
def test_startswith(self):
s = "123"
g = "456"
> assert s.startswith(g)
E AssertionError: assert False
E + where False = <built-in method startswith of str object at 0xdeadbeef>('456')
E + where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
E + where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
E + where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
failure_demo.py:226: AssertionError
__________________ TestMoreErrors.test_startswith_nested ___________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef0028>
def test_startswith_nested(self):
def f():
@@ -556,15 +555,15 @@ Here is a nice run of several failures and how ``pytest`` presents things:
> assert f().startswith(g())
E AssertionError: assert False
E + where False = <built-in method startswith of str object at 0xdeadbeef>('456')
E + where <built-in method startswith of str object at 0xdeadbeef> = '123'.startswith
E + where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef>()
E + and '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef>()
E + where False = <built-in method startswith of str object at 0xdeadbeef0027>('456')
E + where <built-in method startswith of str object at 0xdeadbeef0027> = '123'.startswith
E + where '123' = <function TestMoreErrors.test_startswith_nested.<locals>.f at 0xdeadbeef0029>()
E + and '456' = <function TestMoreErrors.test_startswith_nested.<locals>.g at 0xdeadbeef002a>()
failure_demo.py:235: AssertionError
_____________________ TestMoreErrors.test_global_func ______________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002b>
def test_global_func(self):
> assert isinstance(globf(42), float)
@@ -575,18 +574,18 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:238: AssertionError
_______________________ TestMoreErrors.test_instance _______________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>
def test_instance(self):
self.x = 6 * 7
> assert self.x != 42
E assert 42 != 42
E + where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef>.x
E + where 42 = <failure_demo.TestMoreErrors object at 0xdeadbeef002c>.x
failure_demo.py:242: AssertionError
_______________________ TestMoreErrors.test_compare ________________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002d>
def test_compare(self):
> assert globf(10) < 5
@@ -596,7 +595,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:245: AssertionError
_____________________ TestMoreErrors.test_try_finally ______________________
self = <failure_demo.TestMoreErrors object at 0xdeadbeef>
self = <failure_demo.TestMoreErrors object at 0xdeadbeef002e>
def test_try_finally(self):
x = 1
@@ -607,7 +606,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:250: AssertionError
___________________ TestCustomAssertMsg.test_single_line ___________________
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef002f>
def test_single_line(self):
class A:
@@ -622,7 +621,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:261: AssertionError
____________________ TestCustomAssertMsg.test_multiline ____________________
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0030>
def test_multiline(self):
class A:
@@ -641,7 +640,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
failure_demo.py:268: AssertionError
___________________ TestCustomAssertMsg.test_custom_repr ___________________
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef>
self = <failure_demo.TestCustomAssertMsg object at 0xdeadbeef0031>
def test_custom_repr(self):
class JSON:

View File

@@ -69,7 +69,7 @@ Here is a basic pattern to achieve this:
For this to work we need to add a command line option and
provide the ``cmdopt`` through a :ref:`fixture function <fixture function>`:
provide the ``cmdopt`` through a :ref:`fixture function <fixture>`:
.. code-block:: python
@@ -139,10 +139,67 @@ And now with supplying a command line option:
FAILED test_sample.py::test_answer - assert 0
1 failed in 0.12s
You can see that the command line option arrived in our test. This
completes the basic pattern. However, one often rather wants to process
command line options outside of the test and rather pass in different or
more complex objects.
You can see that the command line option arrived in our test.
We could add simple validation for the input by listing the choices:
.. code-block:: python
# content of conftest.py
import pytest
def pytest_addoption(parser):
parser.addoption(
"--cmdopt",
action="store",
default="type1",
help="my option: type1 or type2",
choices=("type1", "type2"),
)
Now we'll get feedback on a bad argument:
.. code-block:: pytest
$ pytest -q --cmdopt=type3
ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: argument --cmdopt: invalid choice: 'type3' (choose from 'type1', 'type2')
If you need to provide more detailed error messages, you can use the
``type`` parameter and raise ``pytest.UsageError``:
.. code-block:: python
# content of conftest.py
import pytest
def type_checker(value):
msg = "cmdopt must specify a numeric type as typeNNN"
if not value.startswith("type"):
raise pytest.UsageError(msg)
try:
int(value[4:])
except ValueError:
raise pytest.UsageError(msg)
return value
def pytest_addoption(parser):
parser.addoption(
"--cmdopt",
action="store",
default="type1",
help="my option: type1 or type2",
type=type_checker,
)
This completes the basic pattern. However, one often rather wants to
process command line options outside of the test and rather pass in
different or more complex objects.
Dynamically adding command line options
--------------------------------------------------------------
@@ -166,7 +223,7 @@ the command line arguments before they get processed:
num = max(multiprocessing.cpu_count() / 2, 1)
args[:] = ["-n", str(num)] + args
If you have the `xdist plugin <https://pypi.org/project/pytest-xdist/>`_ installed
If you have the :pypi:`xdist plugin <pytest-xdist>` installed
you will now always perform test runs using a number
of subprocesses close to your CPU. Running in an empty
directory with the above conftest.py:
@@ -175,9 +232,8 @@ directory with the above conftest.py:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 0 items
========================== no tests ran in 0.12s ===========================
@@ -240,9 +296,8 @@ and when running it will see a skipped "slow" test:
$ pytest -rs # "-rs" means report details on the little 's'
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
test_module.py .s [100%]
@@ -257,9 +312,8 @@ Or run it including the ``slow`` marked test:
$ pytest --runslow
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
test_module.py .. [100%]
@@ -401,10 +455,9 @@ which will add the string to the test header accordingly:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
project deps: mylib-1.1
rootdir: $REGENDOC_TMPDIR
rootdir: /home/sweet/project
collected 0 items
========================== no tests ran in 0.12s ===========================
@@ -430,11 +483,11 @@ which will add info only when run with "--v":
$ pytest -v
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y -- $PYTHON_PREFIX/bin/python
cachedir: $PYTHON_PREFIX/.pytest_cache
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y -- $PYTHON_PREFIX/bin/python
cachedir: .pytest_cache
info1: did you know that ...
did you?
rootdir: $REGENDOC_TMPDIR
rootdir: /home/sweet/project
collecting ... collected 0 items
========================== no tests ran in 0.12s ===========================
@@ -445,9 +498,8 @@ and nothing when run plainly:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 0 items
========================== no tests ran in 0.12s ===========================
@@ -485,9 +537,8 @@ Now we can profile which test functions execute the slowest:
$ pytest --durations=3
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 3 items
test_some_are_slow.py ... [100%]
@@ -591,9 +642,8 @@ If we run this:
$ pytest -rx
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 4 items
test_step.py .Fx. [100%]
@@ -601,7 +651,7 @@ If we run this:
================================= FAILURES =================================
____________________ TestUserHandling.test_modification ____________________
self = <test_step.TestUserHandling object at 0xdeadbeef>
self = <test_step.TestUserHandling object at 0xdeadbeef0001>
def test_modification(self):
> assert 0
@@ -621,7 +671,7 @@ Package/Directory-level fixtures (setups)
-------------------------------------------------------
If you have nested test directories, you can have per-directory fixture scopes
by placing fixture functions in a ``conftest.py`` file in that directory
by placing fixture functions in a ``conftest.py`` file in that directory.
You can use all types of fixtures including :ref:`autouse fixtures
<autouse fixtures>` which are the equivalent of xUnit's setup/teardown
concept. It's however recommended to have explicit fixture references in your
@@ -675,9 +725,8 @@ We can run this:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 7 items
test_step.py .Fx. [ 57%]
@@ -687,17 +736,17 @@ We can run this:
================================== ERRORS ==================================
_______________________ ERROR at setup of test_root ________________________
file $REGENDOC_TMPDIR/b/test_error.py, line 1
file /home/sweet/project/b/test_error.py, line 1
def test_root(db): # no db here, will error out
E fixture 'db' not found
> available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
$REGENDOC_TMPDIR/b/test_error.py:1
/home/sweet/project/b/test_error.py:1
================================= FAILURES =================================
____________________ TestUserHandling.test_modification ____________________
self = <test_step.TestUserHandling object at 0xdeadbeef>
self = <test_step.TestUserHandling object at 0xdeadbeef0002>
def test_modification(self):
> assert 0
@@ -706,21 +755,21 @@ We can run this:
test_step.py:11: AssertionError
_________________________________ test_a1 __________________________________
db = <conftest.DB object at 0xdeadbeef>
db = <conftest.DB object at 0xdeadbeef0003>
def test_a1(db):
> assert 0, db # to show value
E AssertionError: <conftest.DB object at 0xdeadbeef>
E AssertionError: <conftest.DB object at 0xdeadbeef0003>
E assert 0
a/test_db.py:2: AssertionError
_________________________________ test_a2 __________________________________
db = <conftest.DB object at 0xdeadbeef>
db = <conftest.DB object at 0xdeadbeef0003>
def test_a2(db):
> assert 0, db # to show value
E AssertionError: <conftest.DB object at 0xdeadbeef>
E AssertionError: <conftest.DB object at 0xdeadbeef0003>
E assert 0
a/test_db2.py:2: AssertionError
@@ -768,8 +817,8 @@ case we just write some information out to a ``failures`` file:
mode = "a" if os.path.exists("failures") else "w"
with open("failures", mode) as f:
# let's also access a fixture for the fun of it
if "tmpdir" in item.fixturenames:
extra = " ({})".format(item.funcargs["tmpdir"])
if "tmp_path" in item.fixturenames:
extra = " ({})".format(item.funcargs["tmp_path"])
else:
extra = ""
@@ -781,7 +830,7 @@ if you then have failing tests:
.. code-block:: python
# content of test_module.py
def test_fail1(tmpdir):
def test_fail1(tmp_path):
assert 0
@@ -794,9 +843,8 @@ and run them:
$ pytest test_module.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
test_module.py FF [100%]
@@ -804,9 +852,9 @@ and run them:
================================= FAILURES =================================
________________________________ test_fail1 ________________________________
tmpdir = local('PYTEST_TMPDIR/test_fail10')
tmp_path = PosixPath('PYTEST_TMPDIR/test_fail10')
def test_fail1(tmpdir):
def test_fail1(tmp_path):
> assert 0
E assert 0
@@ -901,9 +949,8 @@ and run it:
$ pytest -s test_module.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 3 items
test_module.py Esetting up a test failed! test_module.py::test_setup_fails
@@ -957,8 +1004,7 @@ which test got stuck, for example if pytest was run in quiet mode (``-q``) or yo
output. This is particularly a problem if the problem happens only sporadically, the famous "flaky" kind of tests.
``pytest`` sets the :envvar:`PYTEST_CURRENT_TEST` environment variable when running tests, which can be inspected
by process monitoring utilities or libraries like `psutil <https://pypi.org/project/psutil/>`_ to discover which
test got stuck if necessary:
by process monitoring utilities or libraries like :pypi:`psutil` to discover which test got stuck if necessary:
.. code-block:: python
@@ -1012,7 +1058,7 @@ your frozen program work as the pytest runner by some clever
argument handling during program startup. This allows you to
have a single executable, which is usually more convenient.
Please note that the mechanism for plugin discovery used by pytest
(setupttools entry points) doesn't work with frozen executables so pytest
(setuptools entry points) doesn't work with frozen executables so pytest
can't find any third party plugins automatically. To include third party plugins
like ``pytest-timeout`` they must be imported explicitly and passed on to pytest.main.

View File

@@ -43,7 +43,7 @@ will be called ahead of running any tests:
print("test_method1 called")
def test_method2(self):
print("test_method1 called")
print("test_method2 called")
class TestOther:
@@ -77,7 +77,7 @@ If you run this without output capturing:
callme other called
SomeTest callme called
test_method1 called
.test_method1 called
.test_method2 called
.test other
.test_unit1 method called
.

View File

@@ -0,0 +1,46 @@
.. _test-anatomy:
Anatomy of a test
=================
In the simplest terms, a test is meant to look at the result of a particular
behavior, and make sure that result aligns with what you would expect.
Behavior is not something that can be empirically measured, which is why writing
tests can be challenging.
"Behavior" is the way in which some system **acts in response** to a particular
situation and/or stimuli. But exactly *how* or *why* something is done is not
quite as important as *what* was done.
You can think of a test as being broken down into four steps:
1. **Arrange**
2. **Act**
3. **Assert**
4. **Cleanup**
**Arrange** is where we prepare everything for our test. This means pretty
much everything except for the "**act**". It's lining up the dominoes so that
the **act** can do its thing in one, state-changing step. This can mean
preparing objects, starting/killing services, entering records into a database,
or even things like defining a URL to query, generating some credentials for a
user that doesn't exist yet, or just waiting for some process to finish.
**Act** is the singular, state-changing action that kicks off the **behavior**
we want to test. This behavior is what carries out the changing of the state of
the system under test (SUT), and it's the resulting changed state that we can
look at to make a judgement about the behavior. This typically takes the form of
a function/method call.
**Assert** is where we look at that resulting state and check if it looks how
we'd expect after the dust has settled. It's where we gather evidence to say the
behavior does or does not aligns with what we expect. The ``assert`` in our test
is where we take that measurement/observation and apply our judgement to it. If
something should be green, we'd say ``assert thing == "green"``.
**Cleanup** is where the test picks up after itself, so other tests aren't being
accidentally influenced by it.
At its core, the test is ultimately the **act** and **assert** steps, with the
**arrange** step only providing the context. **Behavior** exists between **act**
and **assert**.

View File

@@ -0,0 +1,174 @@
.. _about-fixtures:
About fixtures
===============
.. seealso:: :ref:`how-to-fixtures`
.. seealso:: :ref:`Fixtures reference <reference-fixtures>`
pytest fixtures are designed to be explicit, modular and scalable.
What fixtures are
-----------------
In testing, a `fixture <https://en.wikipedia.org/wiki/Test_fixture#Software>`_
provides a defined, reliable and consistent context for the tests. This could
include environment (for example a database configured with known parameters)
or content (such as a dataset).
Fixtures define the steps and data that constitute the *arrange* phase of a
test (see :ref:`test-anatomy`). In pytest, they are functions you define that
serve this purpose. They can also be used to define a test's *act* phase; this
is a powerful technique for designing more complex tests.
The services, state, or other operating environments set up by fixtures are
accessed by test functions through arguments. For each fixture used by a test
function there is typically a parameter (named after the fixture) in the test
function's definition.
We can tell pytest that a particular function is a fixture by decorating it with
:py:func:`@pytest.fixture <pytest.fixture>`. Here's a simple example of
what a fixture in pytest might look like:
.. code-block:: python
import pytest
class Fruit:
def __init__(self, name):
self.name = name
def __eq__(self, other):
return self.name == other.name
@pytest.fixture
def my_fruit():
return Fruit("apple")
@pytest.fixture
def fruit_basket(my_fruit):
return [Fruit("banana"), my_fruit]
def test_my_fruit_in_basket(my_fruit, fruit_basket):
assert my_fruit in fruit_basket
Tests don't have to be limited to a single fixture, either. They can depend on
as many fixtures as you want, and fixtures can use other fixtures, as well. This
is where pytest's fixture system really shines.
Improvements over xUnit-style setup/teardown functions
-----------------------------------------------------------
pytest fixtures offer dramatic improvements over the classic xUnit
style of setup/teardown functions:
* fixtures have explicit names and are activated by declaring their use
from test functions, modules, classes or whole projects.
* fixtures are implemented in a modular manner, as each fixture name
triggers a *fixture function* which can itself use other fixtures.
* fixture management scales from simple unit to complex
functional testing, allowing to parametrize fixtures and tests according
to configuration and component options, or to re-use fixtures
across function, class, module or whole test session scopes.
* teardown logic can be easily, and safely managed, no matter how many fixtures
are used, without the need to carefully handle errors by hand or micromanage
the order that cleanup steps are added.
In addition, pytest continues to support :ref:`xunitsetup`. You can mix
both styles, moving incrementally from classic to new style, as you
prefer. You can also start out from existing :ref:`unittest.TestCase
style <unittest.TestCase>` or :ref:`nose based <nosestyle>` projects.
Fixture errors
--------------
pytest does its best to put all the fixtures for a given test in a linear order
so that it can see which fixture happens first, second, third, and so on. If an
earlier fixture has a problem, though, and raises an exception, pytest will stop
executing fixtures for that test and mark the test as having an error.
When a test is marked as having an error, it doesn't mean the test failed,
though. It just means the test couldn't even be attempted because one of the
things it depends on had a problem.
This is one reason why it's a good idea to cut out as many unnecessary
dependencies as possible for a given test. That way a problem in something
unrelated isn't causing us to have an incomplete picture of what may or may not
have issues.
Here's a quick example to help explain:
.. code-block:: python
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def append_first(order):
order.append(1)
@pytest.fixture
def append_second(order, append_first):
order.extend([2])
@pytest.fixture(autouse=True)
def append_third(order, append_second):
order += [3]
def test_order(order):
assert order == [1, 2, 3]
If, for whatever reason, ``order.append(1)`` had a bug and it raises an exception,
we wouldn't be able to know if ``order.extend([2])`` or ``order += [3]`` would
also have problems. After ``append_first`` throws an exception, pytest won't run
any more fixtures for ``test_order``, and it won't even try to run
``test_order`` itself. The only things that would've run would be ``order`` and
``append_first``.
Sharing test data
-----------------
If you want to make test data from files available to your tests, a good way
to do this is by loading these data in a fixture for use by your tests.
This makes use of the automatic caching mechanisms of pytest.
Another good approach is by adding the data files in the ``tests`` folder.
There are also community plugins available to help to manage this aspect of
testing, e.g. :pypi:`pytest-datadir` and :pypi:`pytest-datafiles`.
.. _fixtures-signal-cleanup:
A note about fixture cleanup
----------------------------
pytest does not do any special processing for :data:`SIGTERM <signal.SIGTERM>` and
:data:`SIGQUIT <signal.SIGQUIT>` signals (:data:`SIGINT <signal.SIGINT>` is handled naturally
by the Python runtime via :class:`KeyboardInterrupt`), so fixtures that manage external resources which are important
to be cleared when the Python process is terminated (by those signals) might leak resources.
The reason pytest does not handle those signals to perform fixture cleanup is that signal handlers are global,
and changing them might interfere with the code under execution.
If fixtures in your suite need special care regarding termination in those scenarios,
see :issue:`this comment <5243#issuecomment-491522595>` in the issue
tracker for a possible workaround.

View File

@@ -28,7 +28,7 @@ Flaky tests sometimes appear when a test suite is run in parallel (such as use o
Overly strict assertion
~~~~~~~~~~~~~~~~~~~~~~~
Overly strict assertions can cause problems with floating point comparison as well as timing issues. `pytest.approx <https://docs.pytest.org/en/stable/reference.html#pytest-approx>`_ is useful here.
Overly strict assertions can cause problems with floating point comparison as well as timing issues. :func:`pytest.approx` is useful here.
Pytest features
@@ -113,7 +113,7 @@ Resources
* `Eradicating Non-Determinism in Tests <https://martinfowler.com/articles/nonDeterminism.html>`_ by Martin Fowler, 2011
* `No more flaky tests on the Go team <https://www.thoughtworks.com/insights/blog/no-more-flaky-tests-go-team>`_ by Pavan Sudarshan, 2012
* `The Build That Cried Broken: Building Trust in your Continuous Integration Tests <https://www.youtube.com/embed/VotJqV4n8ig>`_ talk (video) by `Angie Jones <http://angiejones.tech/>`_ at SeleniumConf Austin 2017
* `The Build That Cried Broken: Building Trust in your Continuous Integration Tests <https://www.youtube.com/embed/VotJqV4n8ig>`_ talk (video) by `Angie Jones <https://angiejones.tech/>`_ at SeleniumConf Austin 2017
* `Test and Code Podcast: Flaky Tests and How to Deal with Them <https://testandcode.com/50>`_ by Brian Okken and Anthony Shaw, 2018
* Microsoft:

View File

@@ -7,28 +7,48 @@ Good Integration Practices
Install package with pip
-------------------------------------------------
For development, we recommend you use venv_ for virtual environments and
pip_ for installing your application and any dependencies,
For development, we recommend you use :mod:`venv` for virtual environments and
:doc:`pip:index` for installing your application and any dependencies,
as well as the ``pytest`` package itself.
This ensures your code and dependencies are isolated from your system Python installation.
Next, place a ``setup.py`` file in the root of your package with the following minimum content:
Next, place a ``pyproject.toml`` file in the root of your package:
.. code-block:: python
.. code-block:: toml
from setuptools import setup, find_packages
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"
setup(name="PACKAGENAME", packages=find_packages())
and a ``setup.cfg`` file containing your package's metadata with the following minimum content:
Where ``PACKAGENAME`` is the name of your package. You can then install your package in "editable" mode by running from the same directory:
.. code-block:: ini
[metadata]
name = PACKAGENAME
[options]
packages = find:
where ``PACKAGENAME`` is the name of your package.
.. note::
If your pip version is older than ``21.3``, you'll also need a ``setup.py`` file:
.. code-block:: python
from setuptools import setup
setup()
You can then install your package in "editable" mode by running from the same directory:
.. code-block:: bash
pip install -e .
which lets you change your source code (both tests and application) and rerun tests at will.
This is similar to running ``python setup.py develop`` or ``conda develop`` in that it installs
your package using a symlink to your development code.
.. _`test discovery`:
.. _`Python test discovery`:
@@ -48,7 +68,7 @@ Conventions for Python test discovery
* ``test`` prefixed test functions or methods outside of class
* ``test`` prefixed test functions or methods inside ``Test`` prefixed test classes (without an ``__init__`` method)
For examples of how to customize your test discovery :doc:`example/pythoncollection`.
For examples of how to customize your test discovery :doc:`/example/pythoncollection`.
Within Python modules, ``pytest`` also discovers tests using the standard
:ref:`unittest.TestCase <unittest.TestCase>` subclassing technique.
@@ -68,7 +88,8 @@ to keep tests separate from actual application code (often a good idea):
.. code-block:: text
setup.py
pyproject.toml
setup.cfg
mypkg/
__init__.py
app.py
@@ -82,7 +103,7 @@ This has the following benefits:
* Your tests can run against an installed version after executing ``pip install .``.
* Your tests can run against the local copy with an editable install after executing ``pip install --editable .``.
* If you don't have a ``setup.py`` file and are relying on the fact that Python by default puts the current
* If you don't use an editable install and are relying on the fact that Python by default puts the current
directory in ``sys.path`` to import your package, you can execute ``python -m pytest`` to execute the tests against the
local copy directly, without using ``pip``.
@@ -103,7 +124,8 @@ If you need to have test modules with the same name, you might add ``__init__.py
.. code-block:: text
setup.py
pyproject.toml
setup.cfg
mypkg/
...
tests/
@@ -130,7 +152,8 @@ sub-directory of your root:
.. code-block:: text
setup.py
pyproject.toml
setup.cfg
src/
mypkg/
__init__.py
@@ -151,7 +174,7 @@ This layout prevents a lot of common pitfalls and has many benefits, which are b
.. note::
The new ``--import-mode=importlib`` (see :ref:`import-modes`) doesn't have
any of the drawbacks above because ``sys.path`` and ``sys.modules`` are not changed when importing
any of the drawbacks above because ``sys.path`` is not changed when importing
test modules, so users that run
into this issue are strongly encouraged to try it and report if the new option works well for them.
@@ -167,7 +190,8 @@ want to distribute them along with your application:
.. code-block:: text
setup.py
pyproject.toml
setup.cfg
mypkg/
__init__.py
app.py
@@ -191,11 +215,11 @@ Note that this layout also works in conjunction with the ``src`` layout mentione
.. note::
You can use Python3 namespace packages (PEP420) for your application
You can use namespace packages (PEP420) for your application
but pytest will still perform `test package name`_ discovery based on the
presence of ``__init__.py`` files. If you use one of the
two recommended file system layouts above but leave away the ``__init__.py``
files from your directories it should just work on Python3.3 and above. From
files from your directories, it should just work. From
"inlined tests", however, you will need to use absolute imports for
getting at your application code.
@@ -230,23 +254,35 @@ Note that this layout also works in conjunction with the ``src`` layout mentione
much less surprising.
.. _`virtualenv`: https://pypi.org/project/virtualenv/
.. _`buildout`: http://www.buildout.org/
.. _pip: https://pypi.org/project/pip/
.. _`buildout`: http://www.buildout.org/en/latest/
.. _`use tox`:
tox
------
---
Once you are done with your work and want to make sure that your actual
package passes all tests you may want to look into `tox`_, the
virtualenv test automation tool and its `pytest support
<https://tox.readthedocs.io/en/latest/example/pytest.html>`_.
package passes all tests you may want to look into :doc:`tox <tox:index>`, the
virtualenv test automation tool and its :doc:`pytest support <tox:example/pytest>`.
tox helps you to setup virtualenv environments with pre-defined
dependencies and then executing a pre-configured test command with
options. It will run tests against the installed package and not
against your source code checkout, helping to detect packaging
glitches.
.. _`venv`: https://docs.python.org/3/library/venv.html
Do not run via setuptools
-------------------------
Integration with setuptools is **not recommended**,
i.e. you should not be using ``python setup.py test`` or ``pytest-runner``,
and may stop working in the future.
This is deprecated since it depends on deprecated features of setuptools
and relies on features that break security mechanisms in pip.
For example 'setup_requires' and 'tests_require' bypass ``pip --require-hashes``.
For more information and migration instructions,
see the `pytest-runner notice <https://github.com/pytest-dev/pytest-runner#deprecation-notice>`_.
See also `pypa/setuptools#1684 <https://github.com/pypa/setuptools/issues/1684>`_.
setuptools intends to
`remove the test command <https://github.com/pypa/setuptools/issues/931>`_.

View File

@@ -0,0 +1,15 @@
:orphan:
.. _explanation:
Explanation
================
.. toctree::
:maxdepth: 1
anatomy
fixtures
goodpractices
flaky
pythonpath

View File

@@ -11,19 +11,19 @@ Import modes
pytest as a testing framework needs to import test modules and ``conftest.py`` files for execution.
Importing files in Python (at least until recently) is a non-trivial processes, often requiring
changing `sys.path <https://docs.python.org/3/library/sys.html#sys.path>`__. Some aspects of the
changing :data:`sys.path`. Some aspects of the
import process can be controlled through the ``--import-mode`` command-line flag, which can assume
these values:
* ``prepend`` (default): the directory path containing each module will be inserted into the *beginning*
of ``sys.path`` if not already there, and then imported with the `__import__ <https://docs.python.org/3/library/functions.html#__import__>`__ builtin.
of :py:data:`sys.path` if not already there, and then imported with the :func:`__import__ <__import__>` builtin.
This requires test module names to be unique when the test directory tree is not arranged in
packages, because the modules will put in ``sys.modules`` after importing.
packages, because the modules will put in :py:data:`sys.modules` after importing.
This is the classic mechanism, dating back from the time Python 2 was still supported.
* ``append``: the directory containing each module is appended to the end of ``sys.path`` if not already
* ``append``: the directory containing each module is appended to the end of :py:data:`sys.path` if not already
there, and imported with ``__import__``.
This better allows to run test modules against installed versions of a package even if the
@@ -41,17 +41,14 @@ these values:
we advocate for using :ref:`src <src-layout>` layouts.
Same as ``prepend``, requires test module names to be unique when the test directory tree is
not arranged in packages, because the modules will put in ``sys.modules`` after importing.
not arranged in packages, because the modules will put in :py:data:`sys.modules` after importing.
* ``importlib``: new in pytest-6.0, this mode uses `importlib <https://docs.python.org/3/library/importlib.html>`__ to import test modules. This gives full control over the import process, and doesn't require
changing ``sys.path`` or ``sys.modules`` at all.
* ``importlib``: new in pytest-6.0, this mode uses :mod:`importlib` to import test modules. This gives full control over the import process, and doesn't require changing :py:data:`sys.path`.
For this reason this doesn't require test module names to be unique at all, but also makes test
modules non-importable by each other. This was made possible in previous modes, for tests not residing
in Python packages, because of the side-effects of changing ``sys.path`` and ``sys.modules``
mentioned above. Users which require this should turn their tests into proper packages instead.
For this reason this doesn't require test module names to be unique, but also makes test
modules non-importable by each other.
We intend to make ``importlib`` the default in future releases.
We intend to make ``importlib`` the default in future releases, depending on feedback.
``prepend`` and ``append`` import modes scenarios
-------------------------------------------------
@@ -133,4 +130,4 @@ Running pytest with ``pytest [...]`` instead of ``python -m pytest [...]`` yield
equivalent behaviour, except that the latter will add the current directory to ``sys.path``, which
is standard ``python`` behavior.
See also :ref:`cmdline`.
See also :ref:`invoke-python`.

View File

@@ -7,7 +7,7 @@ pytest-2.3: reasoning for fixture/funcarg evolution
**Target audience**: Reading this document requires basic knowledge of
python testing, xUnit setup methods and the (previous) basic pytest
funcarg mechanism, see https://docs.pytest.org/en/stable/historical-notes.html#funcargs-and-pytest-funcarg.
funcarg mechanism, see :ref:`historical funcargs and pytest.funcargs`.
If you are new to pytest, then you can simply ignore this
section and read the other sections.
@@ -47,7 +47,7 @@ There are several limitations and difficulties with this approach:
2. parametrizing the "db" resource is not straight forward:
you need to apply a "parametrize" decorator or implement a
:py:func:`~hookspec.pytest_generate_tests` hook
calling :py:func:`~python.Metafunc.parametrize` which
calling :py:func:`~pytest.Metafunc.parametrize` which
performs parametrization at the places where the resource
is used. Moreover, you need to modify the factory to use an
``extrakey`` parameter containing ``request.param`` to the
@@ -113,7 +113,7 @@ This new way of parametrizing funcarg factories should in many cases
allow to re-use already written factories because effectively
``request.param`` was already used when test functions/classes were
parametrized via
:py:func:`metafunc.parametrize(indirect=True) <_pytest.python.Metafunc.parametrize>` calls.
:py:func:`metafunc.parametrize(indirect=True) <pytest.Metafunc.parametrize>` calls.
Of course it's perfectly fine to combine parametrization and scoping:
@@ -168,7 +168,7 @@ pytest for a long time offered a pytest_configure and a pytest_sessionstart
hook which are often used to setup global resources. This suffers from
several problems:
1. in distributed testing the master process would setup test resources
1. in distributed testing the managing process would setup test resources
that are never needed because it only co-ordinates the test run
activities of the worker processes.

View File

@@ -1,22 +1,16 @@
Installation and Getting Started
.. _get-started:
Get Started
===================================
**Pythons**: Python 3.6, 3.7, 3.8, 3.9, PyPy3
**Platforms**: Linux and Windows
**PyPI package name**: `pytest <https://pypi.org/project/pytest/>`_
**Documentation as PDF**: `download latest <https://media.readthedocs.org/pdf/pytest/latest/pytest.pdf>`_
``pytest`` is a framework that makes building simple and scalable tests easy. Tests are expressive and readable—no boilerplate code required. Get started in minutes with a small unit test or complex functional test for your application or library.
.. _`getstarted`:
.. _`installation`:
Install ``pytest``
----------------------------------------
``pytest`` requires: Python 3.6, 3.7, 3.8, 3.9, or PyPy3.
1. Run the following command in your command line:
.. code-block:: bash
@@ -28,14 +22,14 @@ Install ``pytest``
.. code-block:: bash
$ pytest --version
pytest 6.2.0
pytest 7.0.1
.. _`simpletest`:
Create your first test
----------------------------------------------------------
Create a simple test function with just four lines of code:
Create a new file called ``test_sample.py``, containing a function, and a test:
.. code-block:: python
@@ -47,15 +41,14 @@ Create a simple test function with just four lines of code:
def test_answer():
assert func(3) == 5
Thats it. You can now execute the test function:
The test
.. code-block:: pytest
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_sample.py F [100%]
@@ -77,7 +70,7 @@ The ``[100%]`` refers to the overall progress of running all test cases. After i
.. note::
You can use the ``assert`` statement to verify test expectations. pytests `Advanced assertion introspection <http://docs.python.org/reference/simple_stmts.html#the-assert-statement>`_ will intelligently report intermediate values of the assert expression so you can avoid the many names `of JUnit legacy methods <http://docs.python.org/library/unittest.html#test-cases>`_.
You can use the ``assert`` statement to verify test expectations. pytests :ref:`Advanced assertion introspection <python:assert>` will intelligently report intermediate values of the assert expression so you can avoid the many names :ref:`of JUnit legacy methods <testcase-objects>`.
Run multiple tests
----------------------------------------------------------
@@ -144,7 +137,7 @@ Once you develop multiple tests, you may want to group them into a class. pytest
================================= FAILURES =================================
____________________________ TestClass.test_two ____________________________
self = <test_class.TestClass object at 0xdeadbeef>
self = <test_class.TestClass object at 0xdeadbeef0001>
def test_two(self):
x = "hello"
@@ -175,77 +168,73 @@ This is outlined below:
# content of test_class_demo.py
class TestClassDemoInstance:
value = 0
def test_one(self):
assert 0
self.value = 1
assert self.value == 1
def test_two(self):
assert 0
assert self.value == 1
.. code-block:: pytest
$ pytest -k TestClassDemoInstance -q
FF [100%]
.F [100%]
================================= FAILURES =================================
______________________ TestClassDemoInstance.test_one ______________________
self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef>
def test_one(self):
> assert 0
E assert 0
test_class_demo.py:3: AssertionError
______________________ TestClassDemoInstance.test_two ______________________
self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef>
self = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef0002>
def test_two(self):
> assert 0
E assert 0
> assert self.value == 1
E assert 0 == 1
E + where 0 = <test_class_demo.TestClassDemoInstance object at 0xdeadbeef0002>.value
test_class_demo.py:6: AssertionError
test_class_demo.py:9: AssertionError
========================= short test summary info ==========================
FAILED test_class_demo.py::TestClassDemoInstance::test_one - assert 0
FAILED test_class_demo.py::TestClassDemoInstance::test_two - assert 0
2 failed in 0.12s
FAILED test_class_demo.py::TestClassDemoInstance::test_two - assert 0 == 1
1 failed, 1 passed in 0.12s
Note that attributes added at class level are *class attributes*, so they will be shared between tests.
Request a unique temporary directory for functional tests
--------------------------------------------------------------
``pytest`` provides `Builtin fixtures/function arguments <https://docs.pytest.org/en/stable/builtin.html>`_ to request arbitrary resources, like a unique temporary directory:
``pytest`` provides :std:doc:`Builtin fixtures/function arguments <builtin>` to request arbitrary resources, like a unique temporary directory:
.. code-block:: python
# content of test_tmpdir.py
def test_needsfiles(tmpdir):
print(tmpdir)
# content of test_tmp_path.py
def test_needsfiles(tmp_path):
print(tmp_path)
assert 0
List the name ``tmpdir`` in the test function signature and ``pytest`` will lookup and call a fixture factory to create the resource before performing the test function call. Before the test runs, ``pytest`` creates a unique-per-test-invocation temporary directory:
List the name ``tmp_path`` in the test function signature and ``pytest`` will lookup and call a fixture factory to create the resource before performing the test function call. Before the test runs, ``pytest`` creates a unique-per-test-invocation temporary directory:
.. code-block:: pytest
$ pytest -q test_tmpdir.py
$ pytest -q test_tmp_path.py
F [100%]
================================= FAILURES =================================
_____________________________ test_needsfiles ______________________________
tmpdir = local('PYTEST_TMPDIR/test_needsfiles0')
tmp_path = PosixPath('PYTEST_TMPDIR/test_needsfiles0')
def test_needsfiles(tmpdir):
print(tmpdir)
def test_needsfiles(tmp_path):
print(tmp_path)
> assert 0
E assert 0
test_tmpdir.py:3: AssertionError
test_tmp_path.py:3: AssertionError
--------------------------- Captured stdout call ---------------------------
PYTEST_TMPDIR/test_needsfiles0
========================= short test summary info ==========================
FAILED test_tmpdir.py::test_needsfiles - assert 0
FAILED test_tmp_path.py::test_needsfiles - assert 0
1 failed in 0.12s
More info on tmpdir handling is available at :ref:`Temporary directories and files <tmpdir handling>`.
More info on temporary directory handling is available at :ref:`Temporary directories and files <tmp_path handling>`.
Find out what kind of builtin :ref:`pytest fixtures <fixtures>` exist with the command:
@@ -260,7 +249,7 @@ Continue reading
Check out additional pytest resources to help you customize tests for your unique workflow:
* ":ref:`cmdline`" for command line invocation examples
* ":ref:`usage`" for command line invocation examples
* ":ref:`existingtestsuite`" for working with pre-existing tests
* ":ref:`mark`" for information on the ``pytest.mark`` mechanism
* ":ref:`fixtures`" for providing a functional baseline to your tests

View File

@@ -76,38 +76,38 @@ order doesn't even matter. You probably want to think of your marks as a set her
If you are unsure or have any questions, please consider opening
`an issue <https://github.com/pytest-dev/pytest/issues>`_.
:issue:`an issue <new>`.
Related issues
~~~~~~~~~~~~~~
Here is a non-exhaustive list of issues fixed by the new implementation:
* Marks don't pick up nested classes (`#199 <https://github.com/pytest-dev/pytest/issues/199>`_).
* Marks don't pick up nested classes (:issue:`199`).
* Markers stain on all related classes (`#568 <https://github.com/pytest-dev/pytest/issues/568>`_).
* Markers stain on all related classes (:issue:`568`).
* Combining marks - args and kwargs calculation (`#2897 <https://github.com/pytest-dev/pytest/issues/2897>`_).
* Combining marks - args and kwargs calculation (:issue:`2897`).
* ``request.node.get_marker('name')`` returns ``None`` for markers applied in classes (`#902 <https://github.com/pytest-dev/pytest/issues/902>`_).
* ``request.node.get_marker('name')`` returns ``None`` for markers applied in classes (:issue:`902`).
* Marks applied in parametrize are stored as markdecorator (`#2400 <https://github.com/pytest-dev/pytest/issues/2400>`_).
* Marks applied in parametrize are stored as markdecorator (:issue:`2400`).
* Fix marker interaction in a backward incompatible way (`#1670 <https://github.com/pytest-dev/pytest/issues/1670>`_).
* Fix marker interaction in a backward incompatible way (:issue:`1670`).
* Refactor marks to get rid of the current "marks transfer" mechanism (`#2363 <https://github.com/pytest-dev/pytest/issues/2363>`_).
* Refactor marks to get rid of the current "marks transfer" mechanism (:issue:`2363`).
* Introduce FunctionDefinition node, use it in generate_tests (`#2522 <https://github.com/pytest-dev/pytest/issues/2522>`_).
* Introduce FunctionDefinition node, use it in generate_tests (:issue:`2522`).
* Remove named marker attributes and collect markers in items (`#891 <https://github.com/pytest-dev/pytest/issues/891>`_).
* Remove named marker attributes and collect markers in items (:issue:`891`).
* skipif mark from parametrize hides module level skipif mark (`#1540 <https://github.com/pytest-dev/pytest/issues/1540>`_).
* skipif mark from parametrize hides module level skipif mark (:issue:`1540`).
* skipif + parametrize not skipping tests (`#1296 <https://github.com/pytest-dev/pytest/issues/1296>`_).
* skipif + parametrize not skipping tests (:issue:`1296`).
* Marker transfer incompatible with inheritance (`#535 <https://github.com/pytest-dev/pytest/issues/535>`_).
* Marker transfer incompatible with inheritance (:issue:`535`).
More details can be found in the `original PR <https://github.com/pytest-dev/pytest/pull/3317>`_.
More details can be found in the :pull:`original PR <3317>`.
.. note::
@@ -125,6 +125,7 @@ as a third party plugin named ``pytest-cache``. The core plugin
is compatible regarding command line options and API usage except that you
can only store/receive data between test runs that is json-serializable.
.. _historical funcargs and pytest.funcargs:
funcargs and ``pytest_funcarg__``
---------------------------------

145
doc/en/history.rst Normal file
View File

@@ -0,0 +1,145 @@
History
=======
pytest has a long and interesting history. The `first commit
<https://github.com/pytest-dev/pytest/commit/5992a8ef21424d7571305a8d7e2a3431ee7e1e23>`__
in this repository is from January 2007, and even that commit alone already
tells a lot: The repository originally was from the :pypi:`py`
library (later split off to pytest), and it
originally was a SVN revision, migrated to Mercurial, and finally migrated to
git.
However, the commit says “create the new development trunk” and is
already quite big: *435 files changed, 58640 insertions(+)*. This is because
pytest originally was born as part of `PyPy <https://www.pypy.org/>`__, to make
it easier to write tests for it. Here's how it evolved from there to its own
project:
- Late 2002 / early 2003, `PyPy was
born <https://morepypy.blogspot.com/2018/09/the-first-15-years-of-pypy.html>`__.
- Like that blog post mentioned, from very early on, there was a big
focus on testing. There were various ``testsupport`` files on top of
unittest.py, and as early as June 2003, Holger Krekel (:user:`hpk42`)
`refactored <https://mail.python.org/pipermail/pypy-dev/2003-June/000787.html>`__
its test framework to clean things up (``pypy.tool.test``, but still
on top of ``unittest.py``, with nothing pytest-like yet).
- In December 2003, there was `another
iteration <https://foss.heptapod.net/pypy/pypy/-/commit/02752373e1b29d89c6bb0a97e5f940caa22bdd63>`__
at improving their testing situation, by Stefan Schwarzer, called
``pypy.tool.newtest``.
- However, it didnt seem to be around for long, as around June/July
2004, efforts started on a thing called ``utest``, offering plain
assertions. This seems like the start of something pytest-like, but
unfortunately, it's unclear where the test runner's code was at the time.
The closest thing still around is `this
file <https://foss.heptapod.net/pypy/pypy/-/commit/0735f9ed287ec20950a7dd0a16fc10810d4f6847>`__,
but that doesnt seem like a complete test runner at all. What can be seen
is that there were `various
efforts <https://foss.heptapod.net/pypy/pypy/-/commits/branch/default?utf8=%E2%9C%93&search=utest>`__
by Laura Creighton and Samuele Pedroni (:user:`pedronis`) at automatically
converting existing tests to the new ``utest`` framework.
- Around the same time, for Europython 2004, @hpk42 `started a
project <http://web.archive.org/web/20041020215353/http://codespeak.net/svn/user/hpk/talks/std-talk.txt>`__
originally called “std”, intended to be a “complementary standard
library” - already laying out the principles behind what later became
pytest:
- current “batteries included” are very useful, but
- some of them are written in a pretty much java-like style,
especially the unittest-framework
- […]
- the best API is one that doesnt exist
[…]
- a testing package should require as few boilerplate code as
possible and offer much flexibility
- it should provide premium quality tracebacks and debugging aid
[…]
- first of all … forget about limited “assertXYZ APIs” and use the
real thing, e.g.::
assert x == y
- this works with plain python but you get unhelpful “assertion
failed” errors with no information
- std.utest (magic!) actually reinterprets the assertion expression
and offers detailed information about underlying values
- In September 2004, the ``py-dev`` mailinglist gets born, which `is
now <https://mail.python.org/pipermail/pytest-dev/>`__ ``pytest-dev``,
but thankfully with all the original archives still intact.
- Around September/October 2004, the ``std`` project `was renamed
<https://mail.python.org/pipermail/pypy-dev/2004-September/001565.html>`__ to
``py`` and ``std.utest`` became ``py.test``. This is also the first time the
`entire source
code <https://foss.heptapod.net/pypy/pypy/-/commit/42cf50c412026028e20acd23d518bd92e623ac11>`__,
seems to be available, with much of the API still being around today:
- ``py.path.local``, which is being phased out of pytest (in favour of
pathlib) some 16-17 years later
- The idea of the collection tree, including ``Collector``,
``FSCollector``, ``Directory``, ``PyCollector``, ``Module``,
``Class``
- Arguments like ``-x`` / ``--exitfirst``, ``-l`` /
``--showlocals``, ``--fulltrace``, ``--pdb``, ``-S`` /
``--nocapture`` (``-s`` / ``--capture=off`` today),
``--collectonly`` (``--collect-only`` today)
- In the same month, the ``py`` library `gets split off
<https://foss.heptapod.net/pypy/pypy/-/commit/6bdafe9203ad92eb259270b267189141c53bce33>`__
from ``PyPy``
- It seemed to get rather quiet for a while, and little seemed to happen
between October 2004 (removing ``py`` from PyPy) and January
2007 (first commit in the now-pytest repository). However, there were
various discussions about features/ideas on the mailinglist, and
:pypi:`a couple of releases <py/0.8.0-alpha2/#history>` every
couple of months:
- March 2006: py 0.8.0-alpha2
- May 2007: py 0.9.0
- March 2008: py 0.9.1 (first release to be found `in the pytest
changelog <https://github.com/pytest-dev/pytest/blob/main/doc/en/changelog.rst#091>`__!)
- August 2008: py 0.9.2
- In August 2009, py 1.0.0 was released, `introducing a lot of
fundamental
features <https://holgerkrekel.net/2009/08/04/pylib-1-0-0-released-the-testing-with-python-innovations-continue/>`__:
- funcargs/fixtures
- A `plugin
architecture <http://web.archive.org/web/20090629032718/https://codespeak.net/py/dist/test/extend.html>`__
which still looks very much the same today!
- Various `default
plugins <http://web.archive.org/web/20091005181132/https://codespeak.net/py/dist/test/plugin/index.html>`__,
including
`monkeypatch <http://web.archive.org/web/20091012022829/http://codespeak.net/py/dist/test/plugin/how-to/monkeypatch.html>`__
- Even back there, the
`FAQ <http://web.archive.org/web/20091005222413/http://codespeak.net/py/dist/faq.html>`__
said:
Clearly, [a second standard library] was ambitious and the naming has
maybe haunted the project rather than helping it. There may be a
project name change and possibly a split up into different projects
sometime.
and that finally happened in November 2010, when pytest 2.0.0 `was
released <https://mail.python.org/pipermail/pytest-dev/2010-November/001687.html>`__
as a package separate from ``py`` (but still called ``py.test``).
- In August 2016, pytest 3.0.0 :std:ref:`was released <release-3.0.0>`,
which adds ``pytest`` (rather than ``py.test``) as the recommended
command-line entry point
Due to this history, it's difficult to answer the question when pytest was started.
It depends what point should really be seen as the start of it all. One
possible interpretation is to pick Europython 2004, i.e. around June/July
2004.

View File

@@ -1,16 +1,14 @@
The writing and reporting of assertions in tests
==================================================
.. _`assertfeedback`:
.. _`assert with the assert statement`:
.. _`assert`:
How to write and report assertions in tests
==================================================
.. _`assert with the assert statement`:
Asserting with the ``assert`` statement
---------------------------------------------------------
``pytest`` allows you to use the standard python ``assert`` for verifying
``pytest`` allows you to use the standard Python ``assert`` for verifying
expectations and values in Python tests. For example, you can write the
following:
@@ -31,9 +29,8 @@ you will see the return value of the function call:
$ pytest test_assert1.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_assert1.py F [100%]
@@ -98,13 +95,13 @@ and if you need to have access to the actual exception info you may use:
f()
assert "maximum recursion" in str(excinfo.value)
``excinfo`` is an ``ExceptionInfo`` instance, which is a wrapper around
``excinfo`` is an :class:`~pytest.ExceptionInfo` instance, which is a wrapper around
the actual exception raised. The main attributes of interest are
``.type``, ``.value`` and ``.traceback``.
You can pass a ``match`` keyword parameter to the context-manager to test
that a regular expression matches on the string representation of an exception
(similar to the ``TestCase.assertRaisesRegexp`` method from ``unittest``):
(similar to the ``TestCase.assertRaisesRegex`` method from ``unittest``):
.. code-block:: python
@@ -175,8 +172,6 @@ when it encounters comparisons. For example:
.. code-block:: python
# content of test_assert2.py
def test_set_comparison():
set1 = set("1308")
set2 = set("8035")
@@ -188,9 +183,8 @@ if you run this module:
$ pytest test_assert2.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_assert2.py F [100%]
@@ -209,7 +203,7 @@ if you run this module:
E '5'
E Use -v to get the full diff
test_assert2.py:6: AssertionError
test_assert2.py:4: AssertionError
========================= short test summary info ==========================
FAILED test_assert2.py::test_set_comparison - AssertionError: assert {'0'...
============================ 1 failed in 0.12s =============================
@@ -301,7 +295,7 @@ modules directly discovered by its test collection process, so **asserts in
supporting modules which are not themselves test modules will not be rewritten**.
You can manually enable assertion rewriting for an imported module by calling
`register_assert_rewrite <https://docs.pytest.org/en/stable/writing_plugins.html#assertion-rewriting>`_
:ref:`register_assert_rewrite <assertion-rewriting>`
before you import it (a good place to do that is in your root ``conftest.py``).
For further information, Benjamin Peterson wrote up `Behind the scenes of pytest's new assertion rewriting <http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-assertion.html>`_.

View File

@@ -1,8 +1,8 @@
.. _bash_completion:
Setting up bash completion
==========================
How to set up bash completion
=============================
When using bash as your shell, ``pytest`` can use argcomplete
(https://argcomplete.readthedocs.io/) for auto-completion.

View File

@@ -2,8 +2,8 @@
.. _cache:
Cache: working with cross-testrun state
=======================================
How to re-run failed tests and maintain state between test runs
===============================================================
@@ -86,9 +86,8 @@ If you then run it with ``--lf``:
$ pytest --lf
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
run-last-failure: rerun previous 2 failures
@@ -133,9 +132,8 @@ of ``FF`` and dots):
$ pytest --ff
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 50 items
run-last-failure: rerun previous 2 failures first
@@ -277,73 +275,14 @@ 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-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
cachedir: $PYTHON_PREFIX/.pytest_cache
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
cachedir: /home/sweet/project/.pytest_cache
--------------------------- cache values for '*' ---------------------------
cache/lastfailed contains:
{'test_50.py::test_num[17]': True,
'test_50.py::test_num[25]': True,
'test_assert1.py::test_function': True,
'test_assert2.py::test_set_comparison': True,
'test_caching.py::test_function': True,
'test_foocompare.py::test_compare': True}
{'test_caching.py::test_function': True}
cache/nodeids contains:
['test_50.py::test_num[0]',
'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[1]',
'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[2]',
'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[3]',
'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_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_assert1.py::test_function',
'test_assert2.py::test_set_comparison',
'test_caching.py::test_function',
'test_foocompare.py::test_compare']
['test_caching.py::test_function']
cache/stepwise contains:
[]
example/value contains:
@@ -358,10 +297,9 @@ filtering:
$ pytest --cache-show example/*
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
cachedir: $PYTHON_PREFIX/.pytest_cache
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
cachedir: /home/sweet/project/.pytest_cache
----------------------- cache values for 'example/*' -----------------------
example/value contains:
42
@@ -383,7 +321,9 @@ servers where isolation and correctness is more important
than speed.
.. _cache stepwise:
Stepwise
--------
As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later.
As an alternative to ``--lf -x``, especially for cases where you expect a large part of the test suite will fail, ``--sw``, ``--stepwise`` allows you to fix them one at a time. The test suite will run until the first failure and then stop. At the next invocation, tests will continue from the last failing test and then run until the next failing test. You may use the ``--stepwise-skip`` option to ignore one failing test and stop the test execution on the second failing test instead. This is useful if you get stuck on a failing test and just want to ignore it until later. Providing ``--stepwise-skip`` will also enable ``--stepwise`` implicitly.

View File

@@ -1,7 +1,7 @@
.. _`captures`:
Capturing of the stdout/stderr output
How to capture stdout/stderr output
=========================================================
Default stdout/stderr/stdin capturing behaviour
@@ -83,9 +83,8 @@ of the failing function and hide the other one:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
test_module.py .F [100%]
@@ -99,7 +98,7 @@ of the failing function and hide the other one:
test_module.py:12: AssertionError
-------------------------- Captured stdout setup ---------------------------
setting up <function test_func2 at 0xdeadbeef>
setting up <function test_func2 at 0xdeadbeef0001>
========================= short test summary info ==========================
FAILED test_module.py::test_func2 - assert False
======================= 1 failed, 1 passed in 0.12s ========================

View File

@@ -1,7 +1,7 @@
.. _`warnings`:
Warnings Capture
================
How to capture warnings
=======================
@@ -28,23 +28,32 @@ Running pytest now produces this output:
$ pytest test_show_warnings.py
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_show_warnings.py . [100%]
============================= warnings summary =============================
test_show_warnings.py::test_one
$REGENDOC_TMPDIR/test_show_warnings.py:5: UserWarning: api v1, should use functions from v2
/home/sweet/project/test_show_warnings.py:5: UserWarning: api v1, should use functions from v2
warnings.warn(UserWarning("api v1, should use functions from v2"))
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================= 1 passed, 1 warning in 0.12s =======================
The ``-W`` flag can be passed to control which warnings will be displayed or even turn
them into errors:
Controlling warnings
--------------------
Similar to Python's `warning filter`_ and :option:`-W option <python:-W>` flag, pytest provides
its own ``-W`` flag to control which warnings are ignored, displayed, or turned into
errors. See the `warning filter`_ documentation for more
advanced use-cases.
.. _`warning filter`: https://docs.python.org/3/library/warnings.html#warning-filter
This code sample shows how to treat any ``UserWarning`` category class of warning
as an error:
.. code-block:: pytest
@@ -97,9 +106,6 @@ all other warnings into errors.
When a warning matches more than one option in the list, the action for the last matching option
is performed.
Both ``-W`` command-line option and ``filterwarnings`` ini option are based on Python's own
`-W option`_ and `warnings.simplefilter`_, so please refer to those sections in the Python
documentation for other examples and advanced usage.
.. _`filterwarnings`:
@@ -143,8 +149,6 @@ decorator or to all tests in a module by setting the :globalvar:`pytestmark` var
*Credits go to Florian Schulze for the reference implementation in the* `pytest-warnings`_
*plugin.*
.. _`-W option`: https://docs.python.org/3/using/cmdline.html#cmdoption-w
.. _warnings.simplefilter: https://docs.python.org/3/library/warnings.html#warnings.simplefilter
.. _`pytest-warnings`: https://github.com/fschulze/pytest-warnings
Disabling warnings summary
@@ -173,10 +177,8 @@ DeprecationWarning and PendingDeprecationWarning
------------------------------------------------
By default pytest will display ``DeprecationWarning`` and ``PendingDeprecationWarning`` warnings from
user code and third-party libraries, as recommended by `PEP-0565 <https://www.python.org/dev/peps/pep-0565>`_.
user code and third-party libraries, as recommended by :pep:`565`.
This helps users keep their code modern and avoid breakages when deprecated warnings are effectively removed.
Sometimes it is useful to hide some specific deprecation warnings that happen in code that you have no control over
@@ -198,13 +200,12 @@ the regular expression ``".*U.*mode is deprecated"``.
.. note::
If warnings are configured at the interpreter level, using
the `PYTHONWARNINGS <https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS>`_ environment variable or the
the :envvar:`python:PYTHONWARNINGS` environment variable or the
``-W`` command-line option, pytest will not configure any filters by default.
Also pytest doesn't follow ``PEP-0506`` suggestion of resetting all warning filters because
Also pytest doesn't follow :pep:`506` suggestion of resetting all warning filters because
it might break test suites that configure warning filters themselves
by calling ``warnings.simplefilter`` (see issue `#2430 <https://github.com/pytest-dev/pytest/issues/2430>`_
for an example of that).
by calling :func:`warnings.simplefilter` (see :issue:`2430` for an example of that).
.. _`ensuring a function triggers a deprecation warning`:
@@ -230,27 +231,8 @@ that a certain function call triggers a ``DeprecationWarning`` or
This test will fail if ``myfunction`` does not issue a deprecation warning
when called with a ``17`` argument.
By default, ``DeprecationWarning`` and ``PendingDeprecationWarning`` will not be
caught when using :func:`pytest.warns` or :ref:`recwarn <recwarn>` because
the default Python warnings filters hide
them. If you wish to record them in your own code, use
``warnings.simplefilter('always')``:
.. code-block:: python
import warnings
import pytest
def test_deprecation(recwarn):
warnings.simplefilter("always")
myfunction(17)
assert len(recwarn) == 1
assert recwarn.pop(DeprecationWarning)
The :ref:`recwarn <recwarn>` fixture automatically ensures to reset the warnings
filter at the end of the test, so no global state is leaked.
.. _`asserting warnings`:
@@ -265,7 +247,7 @@ Asserting warnings with the warns function
You can check that code raises a particular warning using func:`pytest.warns`,
You can check that code raises a particular warning using :func:`pytest.warns`,
which works in a similar manner to :ref:`raises <assertraises>`:
.. code-block:: python
@@ -291,9 +273,9 @@ argument ``match`` to assert that the exception matches a text or regex::
... warnings.warn("this is not here", UserWarning)
Traceback (most recent call last):
...
Failed: DID NOT WARN. No warnings of type ...UserWarning... was emitted...
Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted...
You can also call func:`pytest.warns` on a function or code string:
You can also call :func:`pytest.warns` on a function or code string:
.. code-block:: python
@@ -317,9 +299,9 @@ additional information:
Alternatively, you can examine raised warnings in detail using the
:ref:`recwarn <recwarn>` fixture (see below).
.. note::
``DeprecationWarning`` and ``PendingDeprecationWarning`` are treated
differently; see :ref:`ensuring_function_triggers`.
The :ref:`recwarn <recwarn>` fixture automatically ensures to reset the warnings
filter at the end of the test, so no global state is leaked.
.. _`recording warnings`:
@@ -328,15 +310,15 @@ Alternatively, you can examine raised warnings in detail using the
Recording warnings
------------------
You can record raised warnings either using func:`pytest.warns` or with
You can record raised warnings either using :func:`pytest.warns` or with
the ``recwarn`` fixture.
To record with func:`pytest.warns` without asserting anything about the warnings,
pass ``None`` as the expected warning type:
To record with :func:`pytest.warns` without asserting anything about the warnings,
pass no arguments as the expected warning type and it will default to a generic Warning:
.. code-block:: python
with pytest.warns(None) as record:
with pytest.warns() as record:
warnings.warn("user", UserWarning)
warnings.warn("runtime", RuntimeWarning)
@@ -360,7 +342,7 @@ The ``recwarn`` fixture will record warnings for the whole function:
assert w.filename
assert w.lineno
Both ``recwarn`` and func:`pytest.warns` return the same interface for recorded
Both ``recwarn`` and :func:`pytest.warns` return the same interface for recorded
warnings: a WarningsRecorder instance. To view the recorded warnings, you can
iterate over this instance, call ``len`` on it to get the number of recorded
warnings, or index into it to get a particular recorded warning.
@@ -369,6 +351,37 @@ warnings, or index into it to get a particular recorded warning.
Full API: :class:`~_pytest.recwarn.WarningsRecorder`.
.. _`warns use cases`:
Additional use cases of warnings in tests
-----------------------------------------
Here are some use cases involving warnings that often come up in tests, and suggestions on how to deal with them:
- To ensure that **any** warning is emitted, use:
.. code-block:: python
with pytest.warns():
...
- To ensure that **no** warnings are emitted, use:
.. code-block:: python
with warnings.catch_warnings():
warnings.simplefilter("error")
...
- To suppress warnings, use:
.. code-block:: python
with warnings.catch_warnings():
warnings.simplefilter("ignore")
...
.. _custom_failure_messages:
Custom failure messages
@@ -416,10 +429,10 @@ defines an ``__init__`` constructor, as this prevents the class from being insta
============================= warnings summary =============================
test_pytest_warnings.py:1
$REGENDOC_TMPDIR/test_pytest_warnings.py:1: PytestCollectionWarning: cannot collect test class 'Test' because it has a __init__ constructor (from: test_pytest_warnings.py)
/home/sweet/project/test_pytest_warnings.py:1: PytestCollectionWarning: cannot collect test class 'Test' because it has a __init__ constructor (from: test_pytest_warnings.py)
class Test:
-- Docs: https://docs.pytest.org/en/stable/warnings.html
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
1 warning in 0.12s
These warnings might be filtered using the same builtin mechanisms used to filter other types of warnings.

View File

@@ -1,9 +1,10 @@
.. _doctest:
Doctest integration for modules and test files
How to run doctests
=========================================================
By default, all files matching the ``test*.txt`` pattern will
be run through the python standard ``doctest`` module. You
be run through the python standard :mod:`doctest` module. You
can change the pattern by issuing:
.. code-block:: bash
@@ -29,9 +30,8 @@ then you can just invoke ``pytest`` directly:
$ pytest
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 1 item
test_example.txt . [100%]
@@ -48,7 +48,7 @@ and functions, including from test modules:
# content of mymodule.py
def something():
""" a doctest in a docstring
"""a doctest in a docstring
>>> something()
42
"""
@@ -58,9 +58,8 @@ and functions, including from test modules:
$ pytest --doctest-modules
=========================== test session starts ============================
platform linux -- Python 3.x.y, pytest-6.x.y, py-1.x.y, pluggy-0.x.y
cachedir: $PYTHON_PREFIX/.pytest_cache
rootdir: $REGENDOC_TMPDIR
platform linux -- Python 3.x.y, pytest-7.x.y, pluggy-1.x.y
rootdir: /home/sweet/project
collected 2 items
mymodule.py . [ 50%]
@@ -91,10 +90,12 @@ that will be used for those doctest files using the
[pytest]
doctest_encoding = latin1
.. _using doctest options:
Using 'doctest' options
-----------------------
Python's standard ``doctest`` module provides some `options <https://docs.python.org/3/library/doctest.html#option-flags>`__
Python's standard :mod:`doctest` module provides some :ref:`options <python:option-flags-and-directives>`
to configure the strictness of doctest tests. In pytest, you can enable those flags using the
configuration file.
@@ -193,7 +194,7 @@ It is possible to use fixtures using the ``getfixture`` helper:
.. code-block:: text
# content of example.rst
>>> tmp = getfixture('tmpdir')
>>> tmp = getfixture('tmp_path')
>>> ...
>>>
@@ -251,7 +252,7 @@ For the same reasons one might want to skip normal tests, it is also possible to
tests inside doctests.
To skip a single check inside a doctest you can use the standard
`doctest.SKIP <https://docs.python.org/3/library/doctest.html#doctest.SKIP>`__ directive:
:data:`doctest.SKIP` directive:
.. code-block:: python

View File

@@ -1,7 +1,7 @@
.. _existingtestsuite:
Using pytest with an existing test suite
===========================================
How to use pytest with an existing test suite
==============================================
Pytest can be used with most existing test suites, but its
behavior differs from other test runners such as :ref:`nose <noseintegration>` or

160
doc/en/how-to/failures.rst Normal file
View File

@@ -0,0 +1,160 @@
.. _how-to-handle-failures:
How to handle test failures
=============================
.. _maxfail:
Stopping after the first (or N) failures
---------------------------------------------------
To stop the testing process after the first (N) failures:
.. code-block:: bash
pytest -x # stop after first failure
pytest --maxfail=2 # stop after two failures
.. _pdb-option:
Using :doc:`python:library/pdb` with pytest
-------------------------------------------
Dropping to :doc:`pdb <python:library/pdb>` on failures
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python comes with a builtin Python debugger called :doc:`pdb <python:library/pdb>`. ``pytest``
allows one to drop into the :doc:`pdb <python:library/pdb>` prompt via a command line option:
.. code-block:: bash
pytest --pdb
This will invoke the Python debugger on every failure (or KeyboardInterrupt).
Often you might only want to do this for the first failing test to understand
a certain failure situation:
.. code-block:: bash
pytest -x --pdb # drop to PDB on first failure, then end test session
pytest --pdb --maxfail=3 # drop to PDB for first three failures
Note that on any failure the exception information is stored on
``sys.last_value``, ``sys.last_type`` and ``sys.last_traceback``. In
interactive use, this allows one to drop into postmortem debugging with
any debug tool. One can also manually access the exception information,
for example::
>>> import sys
>>> sys.last_traceback.tb_lineno
42
>>> sys.last_value
AssertionError('assert result == "ok"',)
.. _trace-option:
Dropping to :doc:`pdb <python:library/pdb>` at the start of a test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``pytest`` allows one to drop into the :doc:`pdb <python:library/pdb>` prompt immediately at the start of each test via a command line option:
.. code-block:: bash
pytest --trace
This will invoke the Python debugger at the start of every test.
.. _breakpoints:
Setting breakpoints
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded: 2.4.0
To set a breakpoint in your code use the native Python ``import pdb;pdb.set_trace()`` call
in your code and pytest automatically disables its output capture for that test:
* Output capture in other tests is not affected.
* Any prior test output that has already been captured and will be processed as
such.
* Output capture gets resumed when ending the debugger session (via the
``continue`` command).
.. _`breakpoint-builtin`:
Using the builtin breakpoint function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python 3.7 introduces a builtin ``breakpoint()`` function.
Pytest supports the use of ``breakpoint()`` with the following behaviours:
- When ``breakpoint()`` is called and ``PYTHONBREAKPOINT`` is set to the default value, pytest will use the custom internal PDB trace UI instead of the system default ``Pdb``.
- When tests are complete, the system will default back to the system ``Pdb`` trace UI.
- With ``--pdb`` passed to pytest, the custom internal Pdb trace UI is used with both ``breakpoint()`` and failed tests/unhandled exceptions.
- ``--pdbcls`` can be used to specify a custom debugger class.
.. _faulthandler:
Fault Handler
-------------
.. versionadded:: 5.0
The :mod:`faulthandler` standard module
can be used to dump Python tracebacks on a segfault or after a timeout.
The module is automatically enabled for pytest runs, unless the ``-p no:faulthandler`` is given
on the command-line.
Also the :confval:`faulthandler_timeout=X<faulthandler_timeout>` configuration option can be used
to dump the traceback of all threads if a test takes longer than ``X``
seconds to finish (not available on Windows).
.. note::
This functionality has been integrated from the external
`pytest-faulthandler <https://github.com/pytest-dev/pytest-faulthandler>`__ plugin, with two
small differences:
* To disable it, use ``-p no:faulthandler`` instead of ``--no-faulthandler``: the former
can be used with any plugin, so it saves one option.
* The ``--faulthandler-timeout`` command-line option has become the
:confval:`faulthandler_timeout` configuration option. It can still be configured from
the command-line using ``-o faulthandler_timeout=X``.
.. _unraisable:
Warning about unraisable exceptions and unhandled thread exceptions
-------------------------------------------------------------------
.. versionadded:: 6.2
.. note::
These features only work on Python>=3.8.
Unhandled exceptions are exceptions that are raised in a situation in which
they cannot propagate to a caller. The most common case is an exception raised
in a :meth:`__del__ <object.__del__>` implementation.
Unhandled thread exceptions are exceptions raised in a :class:`~threading.Thread`
but not handled, causing the thread to terminate uncleanly.
Both types of exceptions are normally considered bugs, but may go unnoticed
because they don't cause the program itself to crash. Pytest detects these
conditions and issues a warning that is visible in the test run summary.
The plugins are automatically enabled for pytest runs, unless the
``-p no:unraisableexception`` (for unraisable exceptions) and
``-p no:threadexception`` (for thread exceptions) options are given on the
command-line.
The warnings may be silenced selectively using the :ref:`pytest.mark.filterwarnings ref`
mark. The warning categories are :class:`pytest.PytestUnraisableExceptionWarning` and
:class:`pytest.PytestUnhandledThreadExceptionWarning`.

File diff suppressed because it is too large Load Diff

64
doc/en/how-to/index.rst Normal file
View File

@@ -0,0 +1,64 @@
:orphan:
.. _how-to:
How-to guides
================
Core pytest functionality
-------------------------
.. toctree::
:maxdepth: 1
usage
assert
fixtures
mark
parametrize
tmp_path
monkeypatch
doctest
cache
Test output and outcomes
----------------------------
.. toctree::
:maxdepth: 1
failures
output
logging
capture-stdout-stderr
capture-warnings
skipping
Plugins
----------------------------
.. toctree::
:maxdepth: 1
plugins
writing_plugins
writing_hook_functions
pytest and other test systems
-----------------------------
.. toctree::
:maxdepth: 1
existingtestsuite
unittest
nose
xunit_setup
pytest development environment
------------------------------
.. toctree::
:maxdepth: 1
bash-completion

View File

@@ -1,10 +1,7 @@
.. _logging:
Logging
-------
How to manage logging
---------------------
pytest captures log messages of level ``WARNING`` or above automatically and displays them in their own section
for each failed test in the same manner as captured stdout and stderr.
@@ -170,7 +167,7 @@ the records for the ``setup`` and ``call`` stages during teardown like so:
The full API is available at :class:`_pytest.logging.LogCaptureFixture`.
The full API is available at :class:`pytest.LogCaptureFixture`.
.. _live_logs:
@@ -222,13 +219,37 @@ option names are:
You can call ``set_log_path()`` to customize the log_file path dynamically. This functionality
is considered **experimental**.
.. _log_colors:
Customizing Colors
^^^^^^^^^^^^^^^^^^
Log levels are colored if colored terminal output is enabled. Changing
from default colors or putting color on custom log levels is supported
through ``add_color_level()``. Example:
.. code-block:: python
@pytest.hookimpl
def pytest_configure(config):
logging_plugin = config.pluginmanager.get_plugin("logging-plugin")
# Change color on existing log level
logging_plugin.log_cli_handler.formatter.add_color_level(logging.INFO, "cyan")
# Add color to a custom log level (a custom log level `SPAM` is already set up)
logging_plugin.log_cli_handler.formatter.add_color_level(logging.SPAM, "blue")
.. warning::
This feature and its API are considered **experimental** and might change
between releases without a deprecation notice.
.. _log_release_notes:
Release notes
^^^^^^^^^^^^^
This feature was introduced as a drop-in replacement for the `pytest-catchlog
<https://pypi.org/project/pytest-catchlog/>`_ plugin and they conflict
This feature was introduced as a drop-in replacement for the
:pypi:`pytest-catchlog` plugin and they conflict
with each other. The backward compatibility API with ``pytest-capturelog``
has been dropped when this feature was introduced, so if for that reason you
still need ``pytest-catchlog`` you can disable the internal feature by
@@ -268,5 +289,4 @@ file:
log_cli=true
log_level=NOTSET
More details about the discussion that lead to this changes can be read in
issue `#3013 <https://github.com/pytest-dev/pytest/issues/3013>`_.
More details about the discussion that lead to this changes can be read in :issue:`3013`.

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