Bruno Oliveira
5936a79fdb
Use _pytest.pathlib.safe_exists in get_dirs_from_args ( #11407 )
...
Related to #11394
2023-09-07 15:44:47 -03:00
Bruno Oliveira
28ccf476b9
Fix crash when passing a very long cmdline argument ( #11404 )
...
Fixes #11394
2023-09-07 12:49:25 -03:00
Fraser Stark
333e4eba6b
Change PytestReturnNotNoneWarning to return a normal warning ( #11211 )
...
Fixes #10465
2023-09-07 15:11:59 +00:00
Ronny Pfannschmidt
e787d2ed48
Merge pull request #11317 from tjsmart/fix-issue-11237
...
Fix doctest collection of `functools.cached_property` objects.
2023-09-07 14:39:02 +02:00
Ran Benita
faa8f2ea08
Merge pull request #11393 from pytest-dev/fixtures-tweaks
...
Fixtures tweaks
2023-09-06 09:15:28 +03:00
Bruno Oliveira
194a782e38
Fix import_path for packages ( #11390 )
...
For packages, `import_path` receives the path to the package's `__init__.py` file, however module names (as they live in `sys.modules`) should not include the `__init__` part.
For example, `app/core/__init__.py` should be imported as `app.core`, not as `app.core.__init__`.
Fix #11306
2023-09-05 19:42:40 -03:00
Ran Benita
bc71561ad9
python: avoid an Any
2023-09-05 22:32:46 +03:00
Ran Benita
574e0f45d9
fixtures: avoid using the mildly expensive fixturenames property
...
Avoid creating a list copy + 2 sets + a linear search through the list
(in the common case).
2023-09-05 22:15:37 +03:00
Ran Benita
b8906b29a7
fixtures: require item.fixturenames to exist in _fillfixtures
...
I could find 2 plugins that would be broken by this (pytest-play and
pytest-wdl), but they will be better served by just copying
`_fillfixtures` instead of use the private function.
2023-09-05 22:15:37 +03:00
Ran Benita
d2b5177dd6
fixtures: avoid some redundant work in _fillfixtures
2023-09-05 22:15:37 +03:00
Ran Benita
65c01f531b
fixtures: use the item fixturenames in request.fixturenames
...
`_pyfuncitem.fixturenames` is just an alias for
`_pyfuncitem._fixtureinfo.names_closure` (at least in core pytest), so
let's do the less abstraction-breaking thing.
2023-09-05 22:15:37 +03:00
Ran Benita
82bd63d318
doctest: add fixturenames field to DoctestItem
...
The field is used in `_fillfixtures`, in preference to
`request.fixturenames`, which also includes already-computed which is
not needed.
2023-09-05 22:15:37 +03:00
Ran Benita
d4872f5df7
fixtures: tiny code cleanup
2023-09-05 22:15:37 +03:00
Ran Benita
8d815ca55b
python: type some CallSpec2 fields as immutable
...
Knowing that a field is immutable makes it easier to understand the
code.
2023-09-05 22:15:37 +03:00
Israel Fruchter
917ce9aa01
Fix user_properties not saved to XML if fixture errors during teardown
...
Move handling of user_properties to `finalize()`.
Previously if a fixture failed during teardown, `pytest_runtest_logreport` would not be called with "teardown", resulting in the user properties not being saved on the JUnit XML file.
Fixes : #11367
2023-09-03 14:33:54 -03:00
Sean Patrick Malloy
76ba7db6ce
Improve docs for last-failed-no-failures
...
Improve documentation for last-failed-no-failures to make the different options and the functionality more clear.
Closes #11354
2023-08-29 00:14:45 +00:00
Warren Markham
ff23347f1f
Fix platform-dependent type-check errors ( #11345 )
...
Use more explicit `sys.platform` checks, instead of the previous check using `in`, which mypy understands.
Fixes #11343
2023-08-27 09:40:24 -03:00
Ran Benita
77f7f59b2a
Fixes for typed pluggy
...
Since version 1.3 pluggy added typing, which requires some fixes to
please mypy.
2023-08-26 22:13:24 +03:00
Jon Parise
7500fe44b2
Correct the spelling of ArgSource.INVOCATION_DIR ( #11333 )
...
Config.ArgsSource.INCOVATION_DIR remains as a backwards compatibility
alias.
2023-08-23 09:21:17 +00:00
WarrenTheRabbit
3f446b68fd
doc: fix docstring spelling in pytester
2023-08-22 14:36:39 +10:00
Zac Hatfield-Dodds
050f402816
Merge pull request #11308 from reaganjlee/iter-reporting
...
Improve reporting from __iter__ exceptions
2023-08-21 16:27:42 -07:00
Tyler Smart
a357c7abc8
Ignore dip in branch coverage (since py3.13+ isn't tested in CI)
2023-08-20 20:55:30 -06:00
Reagan Lee
61133ba83d
un-iterable fix
2023-08-20 14:46:09 -07:00
Reagan Lee
049eec8474
Revert iter raises checks
...
This reverts commit e938580257 .
Revert "improve error msg and test"
This reverts commit c0cf822ca1 .
Revert "error msg"
This reverts commit ec1053cc16 .
Revert "changelog"
This reverts commit d2dc8a70b5 .
Revert "simplify code / take out user-gen typeerror case"
This reverts commit b9cb87d862 .
2023-08-20 14:06:42 -07:00
Tyler Smart
7a625481da
PR suggestions
2023-08-19 22:20:40 -06:00
Tyler Smart
ebd571bb18
Move _from_module override to pre-existsing DocTestFinder subclass
2023-08-19 12:04:59 -06:00
Tyler Smart
d4fb6ac9f7
Fix doctest collection of functools.cached_property objects.
2023-08-16 00:55:16 -06:00
Ran Benita
15fadd8c5c
Merge pull request #11219 from bluetech/fixtures2
...
fixtures: make FixtureRequest abstract, add TopRequest subclass
2023-08-15 21:52:46 +03:00
Ran Benita
1827d8d5f9
doc: fix a few pytest.mark.xfail nits
...
Refs #9027 , #10094 .
2023-08-12 18:30:58 +03:00
Ran Benita
9e164fc4fe
fixtures: make FixtureRequest abstract, add TopRequest subclass
...
Fix #11218 .
2023-08-12 11:55:08 +03:00
Reagan Lee
c0cf822ca1
improve error msg and test
2023-08-11 10:33:34 -07:00
Reagan Lee
ec1053cc16
error msg
2023-08-11 10:03:19 -07:00
Reagan Lee
b9cb87d862
simplify code / take out user-gen typeerror case
2023-08-10 17:43:01 -07:00
Reagan Lee
e938580257
check for user-generated exceptions
2023-08-10 17:37:48 -07:00
Ran Benita
3ad3fc6b8f
python: use clearer terminology for _resolve_arg_value_types
2023-08-09 20:36:24 +03:00
Sadra Barikbin
09b78737a5
Move fixtures.py::add_funcarg_pseudo_fixture_def to Metafunc.parametrize ( #11220 )
...
To remove fixtures.py::add_funcargs_pseudo_fixture_def and add its logic
i.e. registering funcargs as params and making corresponding fixturedefs,
right to Metafunc.parametrize in which parametrization takes place.
To remove funcargs from metafunc attributes as we populate metafunc
params and make pseudo fixturedefs simultaneously and there's no need to
keep funcargs separately.
2023-08-09 17:13:45 +00:00
Ran Benita
b2186e2455
Merge pull request #11268 from bluetech/conftest-load
...
config: split `_getconftestmodules` and `_loadconftestmodules`
2023-08-08 14:44:29 +03:00
Bruno Oliveira
24c9aa6c30
Merge pull request #11291 from calestyo/improve-duplicate-values-documentation
...
Improve duplicate values documentation
2023-08-07 08:14:39 -03:00
Christoph Anton Mitterer
1cc58ed67f
improve exception message on duplicate parametrization
...
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name >
2023-08-06 17:43:37 +02:00
Christoph Anton Mitterer
84a342e27c
doc: parametrize() can be called multiple times only on different args
...
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name >
2023-08-06 17:39:31 +02:00
Sadra Barikbin
e8a8a5f320
python: fix scope assignment for indirect parameter sets ( #11277 )
...
Previously, when assigning a scope for a fully-indirect parameter set,
when there are multiple fixturedefs for a param (i.e. same-name fixture
chain), the highest scope was used, but it should be the lowest scope,
since that's the effective scope of the fixture.
2023-08-06 13:59:54 +00:00
Sadra Barikbin
4797deab99
Add FixtureArgKey class to represent fixture deps in fixtures.py ( #11231 )
2023-08-02 14:28:31 +03:00
pre-commit-ci[bot]
c9163402e0
[pre-commit.ci] pre-commit autoupdate ( #11269 )
...
* [pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/PyCQA/flake8: 6.0.0 → 6.1.0](https://github.com/PyCQA/flake8/compare/6.0.0...6.1.0 )
- [github.com/asottile/pyupgrade: v3.9.0 → v3.10.1](https://github.com/asottile/pyupgrade/compare/v3.9.0...v3.10.1 )
* Use is instead of type comparison with equal to appease the linter
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com >
2023-08-01 23:52:09 +02:00
Ran Benita
01ac13a77d
config: split _getconftestmodules and _loadconftestmodules
...
Previously, the `_getconftestmodules` function was used both to load
conftest modules for a path (during `pytest_load_initial_conftests`),
and to retrieve conftest modules for a path (during hook dispatch and
for fetching `collect_ignore`). This made things muddy - it is usually
nicer to have clear separation between "command" and "query" functions,
when they occur in separate phases.
So split into "load" and "get".
Currently, `gethookproxy` still loads conftest itself. I hope to change
this in the future.
2023-08-01 09:46:17 +03:00
Ran Benita
a21fb87a90
python: change Package to no longer be a Module/File
...
Fix #11137 .
2023-07-28 22:49:24 +03:00
Ran Benita
71e627aa8f
fixtures: fix crash when parametrize(scope="package") is used without a Package
...
There as handling for `scope="class"` without a class, but not for
`scope="package"` without a package. It would fail the assert.
2023-07-28 16:13:02 +03:00
Sadra Barikbin
e8aa906e06
fixtures: move _get_direct_parametrize_args to a standalone function
...
So it can be used independently of the FixtureManager.
2023-07-27 09:38:42 +03:00
Sadra Barikbin
12054a4972
config: avoid list[], set[], dict[]
...
Should wait with this until Python 3.8 is dropped.
2023-07-27 09:33:34 +03:00
Ran Benita
13e2b00258
config: don't pass the entire Config to determine_setup()
...
Seems better to make the function a bit more pure, and avoids the
circular import.
2023-07-24 00:00:34 +03:00
Ran Benita
4e42421ebf
config: fix an incorrect type
...
Was a mistake in d97d44a97a .
2023-07-24 00:00:34 +03:00