Ran Benita
a267a622eb
python: fix empty parametrize() leading to "NotSetType.token" id
...
In ff8b7884e8 NOTSET was changed to a
singleton enum, which ended up unexpectedly triggering a code path in ID
generation which checks for `isinstance(Enum)`.
Add an explicit case for it, which is not too bad anyway.
2020-08-25 22:01:43 +03:00
Ran Benita
c1f975668e
main: couple of code simplifications
2020-08-24 18:15:11 +03:00
Ran Benita
023f0510af
main: move collection cache attributes to local variables in collect()
...
They are only used for the duration of this function.
2020-08-24 18:15:11 +03:00
Ran Benita
c867452488
main: inline matchnodes() into collect()
...
Now all of the logic is in one place and may be simplified and
refactored in more sensible way.
2020-08-24 18:15:11 +03:00
Ran Benita
d0e8b71404
main: inline _collect() into collect()
...
This removes an unhelpful level of indirection and enables some upcoming
upcoming simplifications.
2020-08-24 18:15:11 +03:00
Ran Benita
eec13ba57e
main: get rid of NoMatch
...
Things are easier to understand without the weird exception.
2020-08-24 18:15:11 +03:00
Ran Benita
c4fd461617
main: better name for _collection_node_cache3
...
The weird name was due to f3967333a1 , now
that I understand it a bit better can give it a more descriptive name.
2020-08-24 18:15:11 +03:00
Ran Benita
c2256189ae
main: make matchnodes non-recursive
...
It's a little more sane this way.
2020-08-24 18:15:11 +03:00
Ran Benita
841521fedb
main: only perform one recursive matchnodes call per node
2020-08-24 18:15:11 +03:00
Ran Benita
0c6b2f39b2
main: move NoMatch raising to _collect()
...
This is a more sensible interface for matchnodes.
This also fixes a sort-of bug where a recursive call to matchnodes
raises NoMatch which would terminate the entire tree, even if other
branches may find a match. Though I don't think it's actually possible.
2020-08-24 18:15:11 +03:00
Ran Benita
a2c919d350
main: refactor a bit to reduce indentation
2020-08-24 18:15:11 +03:00
Ran Benita
adaec2da90
main: remove impossible condition in matchnodes
...
Already covered in a condition above.
2020-08-24 18:15:11 +03:00
Ran Benita
1b2de81404
main: remove unneeded condition in matchnodes
...
The end result in the `else` branch is the same, but flows naturally.
2020-08-24 18:15:11 +03:00
Ran Benita
5356a0979a
main: small code simplification in matchnodes
2020-08-24 18:15:11 +03:00
Ran Benita
0b41b79dcb
main: better solution to a type ignore
2020-08-24 18:15:11 +03:00
Ran Benita
57aca11d4a
hookspec: type annotate parent argument to pytest_collect_file
2020-08-24 18:15:11 +03:00
Ran Benita
4b8e1a1771
Revert "Move common code between Session and Package to FSCollector"
...
This reverts commit f10ab021e2 .
The commit was good in that it removed a non-trivial amount of code
duplication. However it was done in the wrong layer (nodes.py) and split
up a major part of the collection (the filesystem traversal) to a
separate class making it harder to understand.
We should try to reduce the duplication, but in a more appropriate
manner.
2020-08-24 18:15:11 +03:00
Ran Benita
32edc4655c
main: inline Session._matchnodes() into Session.matchnodes()
...
Similar to the previous commit, this makes things more straightforward.
2020-08-24 18:15:11 +03:00
Ran Benita
d121d7c917
main: inline Session._perform_collect() into perform_collect()
...
It doesn't add much, mostly just an eye sore, particularly with the
overloads.
2020-08-24 18:15:10 +03:00
Ran Benita
1dad5c6433
Merge pull request #7669 from bluetech/collection-doc
...
hookspec: improve collection phase documentation a bit
2020-08-24 14:57:37 +03:00
Ran Benita
172b6e15c5
hookspec: improve collection phase documentation a bit
...
Make it a bit more accurate and use the same format that
pytest_runtest_protocol uses.
2020-08-24 13:00:09 +03:00
Ran Benita
bb38ae9c52
Merge pull request #7651 from bluetech/capture-safe-disable
...
capture: fix disabled()/global_and_fixture_disabled() enabling capturing when it was disabled
2020-08-24 12:11:09 +03:00
Ran Benita
143e3ab846
Merge pull request #7673 from bluetech/logging-fix-handler-restore
...
logging: fix handler level restored incorrectly if caplog.set_level is called more than once
2020-08-23 12:06:09 +03:00
Ran Benita
837687c21a
Merge pull request #7668 from bluetech/dir-match-msg
...
main: improve message on `pytest path/to/a/directory::mytest`
2020-08-23 12:05:22 +03:00
Ran Benita
b1354608cc
logging: fix handler level restored incorrectly if caplog.set_level is called more than once
2020-08-22 17:46:23 +03:00
Maximilian Cosmo Sitter
75af2bfa06
Reintroduce warnings postponed in 6.0 ( #7637 )
2020-08-22 11:17:50 -03:00
Ran Benita
5e39cd5e71
main: improve message on pytest path/to/a/directory::mytest
...
The path part of a `<path>::part1::part2` style collection argument must
be a file, not a directory.
Previously this crashed with an uncool assert "invalid arg".
2020-08-22 11:52:54 +03:00
Bruno Oliveira
372a094005
PytestDeprecationWarning no longer a hard error
2020-08-19 08:14:28 -03:00
Bruno Oliveira
ef946d557c
Remove resultlog plugin
2020-08-19 08:14:28 -03:00
Bruno Oliveira
52b0cc4f19
Remove broken pytest_collect_directory hook
2020-08-19 08:14:25 -03:00
Bruno Oliveira
457d351941
Remove deprecated TerminalReporter.writer property
2020-08-19 08:13:34 -03:00
Bruno Oliveira
6ecbd008c4
Change junit_family default to xunit2
2020-08-19 08:13:06 -03:00
Bruno Oliveira
73e06373dc
Hard failure when constructing Node subclasses
2020-08-19 08:13:03 -03:00
Bruno Oliveira
c747dc5248
Drop support for positional arguments in @pytest.fixture
2020-08-19 08:11:42 -03:00
Bruno Oliveira
98530184a5
Remove funcargnames compatibility property
2020-08-19 08:11:39 -03:00
Ran Benita
c98525bd21
Merge pull request #7648 from bluetech/pylint-abc2
...
Only define gethookproxy, isinitpath on Session
2020-08-18 15:45:11 +03:00
Bruno Oliveira
afa4760cb8
Merge pull request #7643 from nicoddemus/issue-7628
2020-08-17 16:58:56 -03:00
Ran Benita
0d5a65091d
capture: fix disabled()/global_and_fixture_disabled() enabling capturing when it was disabled
...
The `CaptureManager.global_and_fixture_disabled()` context manager (and
`CaptureFixture.disabled()` which calls it) did `suspend(); ...;
resume()` but if the capturing was already suspended, the `resume()`
would resume it when it shouldn't.
This caused caused some messages to be swallowed when `--log-cli` is
used because it uses `global_and_fixture_disabled` when capturing is not
necessarily resumed.
2020-08-16 23:21:45 +03:00
Bruno Oliveira
b426bb3443
Refactor Session._parsearg into a separate function for testing
2020-08-15 13:23:55 -03:00
Bruno Oliveira
2213016e40
Fix Module.name from full path without drive letter
...
Fix #7628
2020-08-15 09:39:14 -03:00
Bruno Oliveira
3f0abcc6a5
Merge pull request #7639 from nicoddemus/issue-7638
2020-08-15 09:17:37 -03:00
Ran Benita
eddd993cf4
Only define gethookproxy, isinitpath on Session
...
This fixes an issue where pylint complains about missing implementations
of abstract methods in subclasses of `File` which only override
`collect()` (as they should).
It is also cleaner and makes sense, these methods really don't need to
be overridden.
The previous methods defined directly on `FSCollector` and `Package` are
deprecated, to be removed in pytest 7.
See commits e2934c3f8c and
f10ab021e2 for reference.
2020-08-15 13:40:16 +03:00
Bruno Oliveira
f76b162263
Add ref to Python bug
2020-08-14 11:36:07 -03:00
Ran Benita
f28af14457
Don't use NotImplementedError in @overloads
...
We used it as a shortcut for avoiding coverage, but pylint has a special
interpretation of it as an abstract method which we don't want.
2020-08-14 13:54:46 +03:00
Bruno Oliveira
36c8bb492e
get_dirs_from_args handles paths with invalid syntax
...
Fix #7638
2020-08-12 17:20:09 -03:00
Ran Benita
acc9310c17
capture: add type annotations to CaptureFixture
...
It now has a str/bytes type parameter.
2020-08-10 18:14:47 +03:00
Ran Benita
8a66f0a96d
capture: overcome a mypy limitation by making CaptureResult a regular class
...
See the code comment for the rationale.
2020-08-10 18:14:47 +03:00
Ran Benita
f8c4e038fd
Replace some usages of py.path.local
2020-08-06 18:46:17 +03:00
Ran Benita
70f3ad1c1f
config/findpaths: convert from py.path.local to pathlib
2020-08-06 18:46:17 +03:00
Ran Benita
9e55288ba4
pathlib: add absolutepath() as alternative to Path.resolve()
...
Didn't call it absolute or absolute_path to avoid conflicts with
possible variable names.
Didn't call it abspath to avoid confusion with os.path.abspath.
2020-08-06 18:16:04 +03:00