Commit Graph

15563 Commits

Author SHA1 Message Date
woutdenolf 6e9f566d79 avoid using __file__ in pytest_plugin_registered as can be wrong on Windows 2024-01-17 15:01:04 +02:00
Ran Benita a6708b9254
Merge pull request #11822 from bluetech/doc-hookspec
hookspec: minor doc tweaks
2024-01-16 18:34:33 +02:00
Florian Bruhin e895c9d38c
doc: Remove sold out training (#11823) 2024-01-16 14:53:10 +01:00
Ran Benita c973ccb622 hookspec: modernize a reference 2024-01-15 23:47:19 +02:00
Ran Benita dd1447cfe5 hookspec: move pytest_load_initial_conftests up
Reflect the order in which the plugins are called.
2024-01-15 23:46:07 +02:00
Ran Benita 9ad8b9fc36 hookspec: remove explicit `:param` types
Duplicates info in the type annotations which sphinx understands.
2024-01-15 23:35:53 +02:00
Florian Bruhin 348e6de102
doc: Update training dates and add pytest sprint (#11819) 2024-01-15 21:04:08 +01:00
Ran Benita 9af6d46371
Merge pull request #11817 from bluetech/conftesterror-cleanup
config: stop using exception triplets in `ConftestImportError`
2024-01-15 13:26:46 +02:00
Ran Benita e1074f9c3d config: stop using exception triplets in `ConftestImportError`
In recent python versions all of the info is on the exception object
itself so no reason to deal with the annoying tuple.
2024-01-15 09:47:55 +02:00
Ran Benita 6e74601466
Merge pull request #11815 from bluetech/iter_parents-rename
nodes: rename `iterparents()` -> `iter_parents()`
2024-01-15 09:46:59 +02:00
Ronny Pfannschmidt 3acbdc2f79
Merge pull request #11814 from bluetech/pycache-ignore-collect
main,python: move `__pycache__` ignore to `pytest_ignore_collect`
2024-01-14 17:26:34 +01:00
Ran Benita 707642ad35 nodes: rename `iterparents()` -> `iter_parents()`
After the fact I remembered there is `node.iter_markers()` so let's be
consistent with that rather than with `listchain()`.
2024-01-14 15:17:41 +02:00
Ran Benita 2413d1b214 main,python: move `__pycache__` ignore to `pytest_ignore_collect`
This removes one thing that directory collectors need to worry about.

This adds one hook dispatch per `__pycache__` file, but I think it's
worth it for consistency.
2024-01-14 15:05:15 +02:00
Ran Benita 2bb0eca347
Merge pull request #11795 from lesteve/improve-assert-mod-not-in-mods-error-message
Improve assert mod not in mods error message
2024-01-14 13:39:14 +02:00
Loïc Estève 1c9d6834fd Improve assert mod not in mods error message
[ran: tweaked message, made the formatting lazy]
2024-01-14 13:21:54 +02:00
github-actions[bot] c6ed86453f
[automated] Update plugin list (#11811)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2024-01-14 01:04:53 -03:00
Ran Benita e403bbf1a9
Merge pull request #11708 from fcharras/FIX/crash_during_conftest_collection
FIX key formating divergence when inspecting plugin dictionary.
2024-01-13 21:45:36 +02:00
Franck Charras a7c2549321 Fix `assert mod not in mods` crash
Fix #27806.

Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2024-01-13 20:19:28 +02:00
Ran Benita d65bcd9a3b
Merge pull request #11808 from bluetech/doctest-conftest
doctest: remove special conftest handling
2024-01-13 19:50:20 +02:00
Ran Benita 06dbd3c21c doctest: remove special conftest handling
(Diff better viewed ignoring whitespace)

Since e1c66ab0ad, conftest loading is
handled at the directory level before sub-nodes are collected, so there
is no need for the doctest plugin to handle it specially.

This was probably the case even before
e1c66ab0ad, but I haven't verified this.
2024-01-13 11:18:41 +02:00
Ran Benita 1b78de4e21
Merge pull request #11803 from pytest-dev/package-scope-note
Add note about package scope
2024-01-12 22:15:33 +02:00
mrbean-bremen 82fda31e99
Clarify package scope
The behavior of package scope is surprising to some
(as seen by related questions on SO), this should clarify it a bit.
2024-01-12 20:03:30 +01:00
Ran Benita 5645fa45fb
Merge pull request #11801 from bluetech/node-iterchain
nodes: add `Node.iterchain()` function
2024-01-12 11:01:48 +02:00
Ran Benita 5bd5b80afd nodes: add `Node.iterparents()` function
This is a useful addition to the existing `listchain`. While `listchain`
returns top-to-bottom, `iterparents` is bottom-to-top and doesn't require
an internal full iteration + `reverse`.
2024-01-11 23:19:45 +02:00
Ran Benita bd58c09500
Merge pull request #11799 from bluetech/rm-nose-compat_co_firstlineno
python: remove support for nose's `compat_co_firstlineno`
2024-01-11 13:13:30 +02:00
Faisal Fawad 996e45d66a
Slight change to tmp_path documentation to more clearly illustrate its behavior (#11800) 2024-01-11 11:01:07 +00:00
Ran Benita c7d85c5dc6 python: remove support for nose's `compat_co_firstlineno`
Since we're removing nose support, let's also drop support for this
attribute.

From doing a code search on github, this seems completely unused outside
of nose, except for some projects which used to use it, but no longer
do.
2024-01-10 19:22:19 +02:00
Ronny Pfannschmidt b1c430820f
Merge pull request #11794 from bluetech/fixturedef-ref-cycle
A few cleanups
2024-01-10 06:44:14 +01:00
Ran Benita 35a3863b15 config: clarify a bit of code in `_importconftest` 2024-01-09 23:49:03 +02:00
Ran Benita 368fa2c03e fixtures: remove unhelpful FixtureManager.{FixtureLookupError,FixtureLookupErrorRepr}
Couldn't find any reason for this indirection, nor any plugins which
rely on it. Seems like historically it was done to avoid some imports...
2024-01-09 23:33:07 +02:00
Ran Benita 372c17e228 fixtures: avoid FixtureDef <-> FixtureManager reference cycle
There is no need to store the FixtureManager on each FixtureDef.
2024-01-09 23:29:58 +02:00
Ran Benita c4a356eaee
Merge pull request #11718 from pytest-dev/dependabot/github_actions/hynek/build-and-inspect-python-package-2.0.0
build(deps): Bump hynek/build-and-inspect-python-package from 1.5.4 to 2.0.0
2024-01-09 21:44:43 +02:00
dependabot[bot] 2270cab1c2 build(deps): Bump actions/download-artifact from 3 to 4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-09 21:12:42 +02:00
dependabot[bot] 956d0e5e9d build(deps): Bump hynek/build-and-inspect-python-package
Bumps [hynek/build-and-inspect-python-package](https://github.com/hynek/build-and-inspect-python-package) from 1.5.4 to 2.0.0.
- [Release notes](https://github.com/hynek/build-and-inspect-python-package/releases)
- [Changelog](https://github.com/hynek/build-and-inspect-python-package/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hynek/build-and-inspect-python-package/compare/v1.5.4...v2.0.0)

---
updated-dependencies:
- dependency-name: hynek/build-and-inspect-python-package
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-09 21:12:27 +02:00
pre-commit-ci[bot] 7bc8385924
[pre-commit.ci] pre-commit autoupdate (#11792)
updates:
- [github.com/PyCQA/flake8: 6.1.0 → 7.0.0](https://github.com/PyCQA/flake8/compare/6.1.0...7.0.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-08 21:19:35 +00:00
Ran Benita 9b7e10a3c0
Merge pull request #11788 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-asyncio-0.23.3
build(deps): Bump pytest-asyncio from 0.23.2 to 0.23.3 in /testing/plugins_integration
2024-01-08 22:40:47 +02:00
dependabot[bot] 913d93debb
build(deps): Bump pytest-asyncio in /testing/plugins_integration
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.23.2 to 0.23.3.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.2...v0.23.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-08 20:24:22 +00:00
Ran Benita 97dfc3429e
Merge pull request #11785 from bluetech/matchfactories-nodes
fixtures: match fixtures based on actual node hierarchy, not textual nodeids
2024-01-08 22:23:08 +02:00
Ran Benita 992d0f082f fixtures: match fixtures based on actual node hierarchy, not textual nodeids
Refs #11662.

--- Problem

Each fixture definition has a "visibility", the `FixtureDef.baseid`
attribute. This is nodeid-like string. When a certain `node` requests a
certain fixture name, we match node's nodeid against the fixture
definitions with this name.

The matching currently happens on the *textual* representation of the
nodeid - we split `node.nodeid` to its "parent nodeids" and then check
if the fixture's `baseid` is in there.

While this has worked so far, we really should try to avoid textual
manipulation of nodeids as much as possible. It has also caused problem
in an odd case of a `Package` in the root directory: the `Package` gets
nodeid `.`, while a `Module` in it gets nodeid `test_module.py`. And
textually, `.` is not a parent of `test_module.py`.

--- Solution

Avoid this entirely by just checking the node hierarchy itself. This is
made possible by the fact that we now have proper `Directory` nodes
(`Dir` or `Package`) for the entire hierarchy.

Also do the same for `_getautousenames` which is a similar deal.

The `iterparentnodeids` function is no longer used and is removed.
2024-01-08 21:36:51 +02:00
Ran Benita b968f63ca5
Merge pull request #11780 from bluetech/register-fixture
Add an internal "register fixture" API and use it replace object patching for fixture injection
2024-01-08 21:24:54 +02:00
Ran Benita c8792bd080 python,unittest: replace obj fixture patching with `FixtureManager._register_fixture`
Instead of modifying user objects like modules and classes that we
really shouldn't be touching, use the new `_register_fixture` internal
API to do it directly.
2024-01-08 21:02:59 +02:00
Ran Benita 3234c79ee5 fixtures: add an internal API for registering a fixture
Add a function on the `FixtureManager` to register a fixture with
pytest. Currently this can only be done through `parsefactories`.

My aim is to eventually make something like this available to plugins,
as it's a pretty common need.
2024-01-08 21:02:59 +02:00
Ran Benita 851b72f289
Merge pull request #11776 from bluetech/unittest-xunit-inline
unittest: inline `_make_xunit_fixture`
2024-01-08 21:02:24 +02:00
Ran Benita 1d7349d18c
Merge pull request #11774 from bluetech/fspath-cleanups
Small `fspath` cleanups
2024-01-08 21:01:56 +02:00
github-actions[bot] 5747a6c06e
[automated] Update plugin list (#11784)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2024-01-07 10:20:38 -03:00
Fabian Sturm 13eacdad8a
Add summary for xfails with -rxX option (#11574)
Co-authored-by: Brian Okken <1568356+okken@users.noreply.github.com>
2024-01-05 09:59:19 -03:00
Ran Benita a616adf3ae unittest: inline `_make_xunit_fixture`
The indirection makes things harder to follow in this case IMO.
2024-01-05 14:37:03 +02:00
Ran Benita 685e52ec30 nodes: fix attribute name `fspath` -> `path` in `get_fslocation_from_item` 2024-01-04 22:32:34 +02:00
Ran Benita 7b4ab8134e fixtures: remove unnecessary `fspath` workaround 2024-01-04 22:32:34 +02:00
Ran Benita c2a4a8d518
Merge pull request #11769 from neutrinoceros/fix_warns_docstring
Fix a mistake in pytest.warns' docstring (expect_warning accepts tuples, not any sequence)
2024-01-04 14:27:49 +02:00