Commit Graph

30 Commits

Author SHA1 Message Date
Ran Benita 6c89f9261c Remove deprecated py.path (`fspath`) node constructor arguments 2024-01-03 14:29:45 +02:00
Ran Benita 0ae02e2165 nodes,python: mark abstract node classes as ABCs
Fixes #11676
2023-12-07 16:41:07 +02:00
Bruno Oliveira 88c35123b8 Delay warning about collector/item diamond inheritance
This allows that warning to be filtered by `filterwarnings`.

Fix #9643
2022-02-10 13:50:25 -03: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
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
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
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
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
Ran Benita e515264eb1 Remove yet more unnecessary py.path uses 2021-03-18 10:23:48 +02: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
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 2cb34a99cb Some py.path.local -> pathlib.Path 2020-12-15 00:29:13 +02:00
Simon K 52fef811c2
permit node to warn with any warning type, not just PytestWarning (#8052)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-21 10:49:17 -03:00
crricks 3c7eb5a398
migrated test_nodes.py from testdir to pytester #7492. (#7969) 2020-10-30 22:34:05 +02:00
Ran Benita aa0e2d654f fixtures: use a faster replacement for ischildnode
ischildnode can be quite hot in some cases involving many fixtures.
However it is always used in a way that the nodeid is constant and the
baseid is iterated. So we can save work by pre-computing the parents of
the nodeid and use a simple containment test.

The `_getautousenames` function has the same stuff open-coded, so change
it to use the new function as well.
2020-10-25 00:48:35 +03:00
Ran Benita a2f021b6f3 Remove no longer needed `noqa: F821` uses
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
Ran Benita bcff02c4c6 pytester: some type annotations 2020-07-10 13:08:56 +03:00
Ran Benita 54ad048be7 Enable check_untyped_defs mypy option for testing/ too 2020-06-05 11:34:20 +03:00
Bruno Oliveira b98aa195e0 Add test and changelog for #6428 2020-05-30 20:02:47 -03:00
Ronny Pfannschmidt 8ba0b7bc2a fix #6341 - disallow session/config in Node.from_parent 2020-01-15 13:00:46 +01:00
Anthony Sottile 5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
Anthony Sottile dc75b6af47 Use fix-encoding-pragma pre-commit hook 2019-05-14 15:56:31 -07:00
Bruno Oliveira 557cb6cffe Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-11-13 09:01:37 -02:00
Daniel Hahler ac8b9c6e9d Node: do not add "::()" to nodeid
Fixes https://github.com/pytest-dev/pytest/issues/4127.
2018-11-10 23:46:41 +01:00
Daniel Hahler bee72a6622 Fix nodes._check_initialpaths_for_relpath for dirs
Ref: https://github.com/pytest-dev/pytest/issues/4321#issuecomment-436951894

Hardens some of the not many tests affected by this:

1. `testing/test_session.py::test_rootdir_option_arg` displayed:

> root/test_rootdir_option_arg2/test_rootdir_option_arg.py

2. `test_cmdline_python_namespace_package` displayed "hello/" prefix for:

> hello/test_hello.py::test_hello
> hello/test_hello.py::test_other
2018-11-09 13:16:59 +01:00
Anthony Sottile 2368fbb63c Apply reorder-python-imports to all files 2018-10-25 00:01:29 -07:00
Bruno Oliveira 47bf58d69e Make Node.warn support two forms, new and deprecated
As suggested during review, it now accepts two forms:

Node.warn(warning_instance)  (recommended)

Node.warn(code, message)  (deprecated)
2018-09-04 15:53:17 -03:00
Bruno Oliveira b42518acd5 Change std_warn to receive a single warning instance, addressed review suggestions 2018-09-04 14:20:42 -03:00
Ronny Pfannschmidt 703e4b11ba run black 2018-05-23 16:48:46 +02:00
Tom Dalton 655ab0bf8b Address more review comments, fix massive bug I reintroduced in the node-splitting code :-/ 2017-10-23 17:49:49 +01:00