Commit Graph

15235 Commits

Author SHA1 Message Date
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 18bc6c9a0e
Merge pull request #11292 from pytest-dev/dependabot/pip/testing/plugins_integration/django-4.2.4
build(deps): Bump django from 4.2.3 to 4.2.4 in /testing/plugins_integration
2023-08-07 08:15:17 -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
dependabot[bot] 9c67b7aeb6
build(deps): Bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 4.2.3 to 4.2.4.
- [Commits](https://github.com/django/django/compare/4.2.3...4.2.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 03:39:31 +00: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
Florian Bruhin 1c04a92503
doc: Link pytest.main to how-to guide (#11287) 2023-08-06 12:39:11 +02:00
Christoph Anton Mitterer cc0adf6bf3
doc: update information about assertion messages (#11285)
It was pointed out[0] that the previous behaviour has been obsoleted by
commit 37bd1e03cb.

[0] https://github.com/pytest-dev/pytest/issues/11265#issuecomment-1666581197

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-08-05 19:30:41 +00:00
Christoph Anton Mitterer b8b74331b4
Improve docs for Parametrizing conditional raising (#11279)
What one typically actually wants in such a case is both, checking for some
resulting values *and* checking for some expected exception.

Since this is easily possible with the `nullcontext` context manager, adapt the
example accordingly (needlessly using a different name rather just confuses people).

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2023-08-03 13:31:17 -03: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 485c555812
Merge pull request #11138 from bluetech/pkg-mod
python: change `Package` to no longer be a `Module`/`File`
2023-07-28 23:15:08 +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 c754da10d2
Merge pull request #11256 from bluetech/scope-pkg-crash
fixtures: fix crash when `parametrize(scope="package")` is used without a Package
2023-07-28 22:48:47 +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
Uday Kumar d3552ef4c0
Clarify doc for running tests by nodeid section (#11249) 2023-07-28 07:06:38 +00:00
Ran Benita 448563caaa
Merge pull request #11253 from bluetech/11243-cherry-picks
11243 cherry picks
2023-07-27 10:19:40 +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 430ad145c1
Merge pull request #11244 from bluetech/rootdir-tweaks
Rootdir tweaks
2023-07-27 09:16:13 +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
Ran Benita 161ba87300 doc/usage: clarify "Run tests by node ids"
Fix #11107, #11235.
2023-07-24 00:00:25 +03:00
Ran Benita f2b6040e9e
Merge pull request #11238 from bluetech/doc-not-indirect
doc/example/parametrize: a few fixes/improvements
2023-07-23 13:07:40 +03:00
Florian Bruhin e3247834e2
Remove ep2023 training (#11241) 2023-07-22 20:16:59 +02:00
bowugit 0b4a557087
Extend pytest.raises to support Exception having __repr__ method and initialized with kwargs (#11073)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2023-07-20 13:29:29 -03:00
Bruno Oliveira ffdcce67f4
Merge pull request #10927 from RonnyPfannschmidt/pypi-json-for-plugin-list
update-plugin-list: use json, use http caching, use gh action caches
2023-07-20 10:42:32 -03:00
Ronny Pfannschmidt 1ded74739b update-plugin-list: use json, use http caching, use gh action caches
this change
* switches from html index usage to json index usage
* adds using requests-cache as http cache to trim down runtime
* adds gh action caches for pip and the new http cache
2023-07-20 15:04:41 +02:00
Ran Benita 497a1d798a doc/example/parametrize: a few fixes/improvements
Remove "Indirect" from a few section names -- not actually indirect.

Also few minor updates to the related multipython.py example.
2023-07-20 09:51:11 +03:00
Isaac Virshup 1de0923e83
Have pytest.raises match against exception `__notes__` (#11227)
The doctest is skipped because add_note is only available in 3.11,

Closes #11223
2023-07-18 08:39:39 -03:00
Ronny Pfannschmidt 7c30f674c5
Merge pull request #11228 from bluetech/fixtures-check-scope-test
fixtures: add a test for a currently non-covered scope mismatch scenario
2023-07-18 08:59:55 +02:00
Ran Benita 396bfbf30b fixtures: add a test for a currently non-covered scope mismatch scenario
This test makes clear the need for the `_check_scope()` call in the
`pytest_setup_fixture` impl in fixtures.py, which otherwise seems
redundant with the one in `_compute_fixture_value`.
2023-07-18 00:01:40 +03:00
Ran Benita 02ba39bfcd
Merge pull request #11215 from bluetech/fixtures-tweaks2
fixtures: minor tweaks
2023-07-17 17:30:24 +03:00
Ran Benita 29010d23a6
Merge pull request #11217 from bluetech/fixtures-skip-xunit-loc
fixtures: show test as skip location if skipped from an xunit setup function
2023-07-17 17:30:06 +03:00
dependabot[bot] de1f6f58ba
build(deps): Bump pypa/gh-action-pypi-publish from 1.8.7 to 1.8.8 (#11221)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.7 to 1.8.8.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.7...v1.8.8)

---
updated-dependencies:
- dependency-name: pypa/gh-action-pypi-publish
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-17 09:31:06 +02:00
dependabot[bot] cfda801ebf
build(deps): Bump pytest-asyncio in /testing/plugins_integration (#11222)
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.21.0 to 0.21.1.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.21.0...v0.21.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-17 09:27:38 +02:00
Ran Benita c5262b0c42 fixtures: show test as skip location if skipped from an xunit setup function
Fix #11216.
2023-07-16 23:26:04 +03:00
Ran Benita ff6e110161 fixtures: remove inaccurate comment
unittest TestCases can also use `usefixtures`. Just remove this comment,
it's not very helpful.
2023-07-16 23:19:33 +03:00
Ran Benita 0e0ed2af95 fixtures: some code comments and minor improvements 2023-07-16 23:19:33 +03:00
Ran Benita a3fbf24389 unittest: hide access to _request
Let the parent class (Function) do this. Tiny bit better abstraction.
There seems to be no reason for the `hasattr` bit.
2023-07-16 23:19:33 +03:00
Ran Benita bf451d47a1
Merge pull request #11213 from bluetech/py38-literal
Use typing.Literal without TYPE_CHECKING checks
2023-07-16 23:17:12 +03:00
Ran Benita 578fbe3dfd
Merge pull request #11214 from pytest-dev/update-plugin-list/patch-32f480814
[automated] Update plugin list
2023-07-16 13:07:40 +03:00
pytest bot a668719626 [automated] Update plugin list 2023-07-16 00:28:56 +00:00
Ran Benita 04e0db7e48 Use typing.Literal without TYPE_CHECKING checks
Literal was added in Python 3.8 which we now require so can use it
freely.
2023-07-16 01:11:21 +03:00
Ran Benita 32f480814c
Merge pull request #11209 from bluetech/fixtures-doc-comments
fixtures: some tweaks & improvements
2023-07-15 19:40:48 +03:00
Ran Benita 40ed678885 fixtures: remove two unused functions
Not used since 310b67b227.
2023-07-15 10:06:06 +03:00