test_ok2/testing/python
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
..
approx.py Separate the various parts of the error report with newlines (#11659) 2023-12-06 09:25:00 +00:00
collect.py Rework Session and Package collection 2023-12-10 17:01:39 +02:00
fixtures.py fixtures: match fixtures based on actual node hierarchy, not textual nodeids 2024-01-08 21:36:51 +02:00
integration.py Class methods can now be discovered as tests (#10552) 2022-12-02 15:53:04 +00:00
metafunc.py Rework Session and Package collection 2023-12-10 17:01:39 +02:00
raises.py update does_not_raise docs now that pytest is 3.7+ only 2022-06-29 13:13:15 -04:00
show_fixtures_per_test.py add feature to view fixture source location in invocations with --fixtures-per-test option (#8626) 2021-05-14 14:38:55 +02:00