Commit Graph

15681 Commits

Author SHA1 Message Date
Ran Benita c7ee55993b
Merge pull request #11736 from pytest-dev/update-plugin-list/patch-52db918a2
[automated] Update plugin list
2023-12-30 12:49:17 +02:00
Ran Benita b9855b244d
Merge pull request #11737 from pytest-dev/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2023-12-30 12:35:31 +02:00
pre-commit-ci[bot] 1e5aab1b2b
[pre-commit.ci] pre-commit autoupdate
updates:
- [github.com/psf/black: 23.12.0 → 23.12.1](https://github.com/psf/black/compare/23.12.0...23.12.1)
- [github.com/pre-commit/mirrors-mypy: v1.7.1 → v1.8.0](https://github.com/pre-commit/mirrors-mypy/compare/v1.7.1...v1.8.0)
2023-12-25 20:43:18 +00:00
pytest bot f93c0fc34e [automated] Update plugin list 2023-12-24 00:20:08 +00:00
Michał Górny 52db918a27
Fix handling empty values of NO_COLOR and FORCE_COLOR (#11712)
* Fix handling empty values of NO_COLOR and FORCE_COLOR

Fix handling NO_COLOR and FORCE_COLOR environment variables to correctly
be ignored when they are set to an empty value, as defined
in the specification:

> Command-line software which adds ANSI color to its output by default
> should check for a NO_COLOR environment variable that, when present
> *and not an empty string* (regardless of its value), prevents
> the addition of ANSI color.

(emphasis mine, https://no-color.org/)

The same is true of FORCE_COLOR, https://force-color.org/.

* Streamline testing for FORCE_COLOR and NO_COLOR

Streamline the tests for FORCE_COLOR and NO_COLOR variables, and cover
all possible cases (unset, set to empty, set to "1").  Combine the two
assert functions into one taking boolean parameters.  Mock file.isatty
in all circumstances to ensure that the environment variables take
precedence over the fallback value resulting from isatty check (or that
the fallback is actually used, in the case of both FORCE_COLOR
and NO_COLOR being unset).
2023-12-23 10:12:13 +02:00
Ran Benita 54a0ee02ea
Merge pull request #11732 from bluetech/typing-tweaks
Some minor typing tweaks
2023-12-22 13:00:52 +02:00
Benjamin Schubert 88ae27da08
Add syntactic highlights to the error explanations (#11661)
* Put a 'reset' color in front of the highlighting

When doing the highlighting, some lexers will not set the initial color
explicitly, which may lead to the red from the errors being propagated
to the start of the expression

* Add syntactic highlighting to the error explanations

This updates the various error reporting to highlight python code when
displayed, to increase readability and make it easier to understand
2023-12-21 17:11:56 +00:00
Ran Benita e06a3d02f8
Merge pull request #11715 from pytest-dev/update-plugin-list/patch-047ba83da
[automated] Update plugin list
2023-12-21 17:16:29 +02:00
Ran Benita 75f292d9df Some minor typing tweaks 2023-12-19 23:29:27 +02:00
pre-commit-ci[bot] 581762fcba
[pre-commit.ci] pre-commit autoupdate (#11722)
updates:
- [github.com/psf/black: 23.11.0 → 23.12.0](https://github.com/psf/black/compare/23.11.0...23.12.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-12-18 21:43:27 +00:00
Benjamin Schubert 803b190a17
Merge pull request #11660 from BenjaminSchubert/bschubert/simplify-pprint
Remove more unused pprint features
2023-12-18 09:04:35 +00:00
Benjamin Schubert 283a746dad pprint: Remove conversion to int, we only accept those 2023-12-18 08:35:57 +00:00
Benjamin Schubert 64b5b665cf pprint: Remove the option to add underscore for numbers
This is never used, we can remove this. If we wanted instead, we could
always enable it
2023-12-18 08:35:57 +00:00
Benjamin Schubert 6aa35f772f pprint: Remove the option to sort dictionaries, we always do it 2023-12-18 08:35:57 +00:00
Benjamin Schubert 03b24e5b30 pprint: Remove the `format` method, it's not used outside of pprint
Let's reduce the API surface for the bundled PrettyPrinter to what we
really need and use
2023-12-18 08:35:57 +00:00
dependabot[bot] 7541c5a999
build(deps): Bump anyio[curio,trio] in /testing/plugins_integration (#11717)
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio) from 4.1.0 to 4.2.0.
- [Release notes](https://github.com/agronholm/anyio/releases)
- [Changelog](https://github.com/agronholm/anyio/blob/master/docs/versionhistory.rst)
- [Commits](https://github.com/agronholm/anyio/compare/4.1.0...4.2.0)

---
updated-dependencies:
- dependency-name: anyio[curio,trio]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 06:33:59 +01:00
pytest bot 27f7cee238 [automated] Update plugin list 2023-12-17 00:20:43 +00:00
Arthur Richard 047ba83dab
Improve pytest.exit docs (#11698)
Fixes #11695
2023-12-14 08:14:36 -03:00
Tom Mortimer-Jones 2b86d2bddc
Typo in fixtures.rst (#11699) 2023-12-13 13:24:43 +01:00
dependabot[bot] dfc910ee90
build(deps): Bump django from 4.2.7 to 5.0 in /testing/plugins_integration (#11692)
* build(deps): Bump django in /testing/plugins_integration

Bumps [django](https://github.com/django/django) from 4.2.7 to 5.0.
- [Commits](https://github.com/django/django/compare/4.2.7...5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>

* Bump python version on the plugin job

https://github.com/pytest-dev/pytest/pull/11692#issuecomment-1849963332

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
2023-12-11 14:18:43 +00:00
dependabot[bot] ab307b3402
build(deps): Bump actions/setup-python from 4 to 5 (#11690)
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-11 09:46:13 +01:00
dependabot[bot] 8ce76c307e
build(deps): Bump actions/stale from 8 to 9 (#11691)
Bumps [actions/stale](https://github.com/actions/stale) from 8 to 9.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v8...v9)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-11 09:28:50 +01:00
dependabot[bot] ef8bf82a78
build(deps): Bump pytest-asyncio in /testing/plugins_integration (#11693)
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.23.1 to 0.23.2.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.23.1...v0.23.2)

---
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-12-11 09:24:52 +01:00
Ran Benita e1c66ab0ad Different fix for conftest loading
--- Current main

In current main (before pervious commit), calls to gethookproxy/ihook
are the trigger for loading non-initial conftests. This basically means
that conftest loading is done almost as a random side-effect,
uncontrolled and very non-obvious. And it also dashes any hope of making
gethookproxy faster (gethookproxy shows up prominently in pytest
profiles).

I've wanted to improve this for a while, #11268 was the latest step
towards that.

--- PR before change

In this PR, I ran into a problem.

Previously, Session and Package did all of the directory traversals
inside of their collect, which loaded the conftests as a side effect. If
the conftest loading failed, it will occur inside of the collect() and
cause it to be reported as a failure.

Now I've changed things such that Session.collect and Package.collect no
longer recurse, but just collect their immediate descendants, and
genitems does the recursive expansion work.

The problem though is that genitems() doesn't run inside of specific
collector's collect context. So when it loads a conftest, and the
conftest loading fails, the exception isn't handled by any CollectReport
and causes an internal error instead.

The way I've fixed this problem is by loading the conftests eagerly in a
pytest_collect_directory post-wrapper, but only during genitems to make
sure the directory is actually selected.

This solution in turn caused the conftests to be collected too early;
specifically, the plugins are loaded during the parent's collect(), one
after the other as the directory entries are collected. So when the
ihook is hoisted out of the loop, new plugins are loaded inside the
loop, and due to the way the hook proxy works, they are added to the
ihook even though they're supposed to be scoped to the child collectors.
So no hoisting.

--- PR after change

Now I've come up with a better solution: since now the collection tree
actually reflects the filesystem tree, what we really want is to load
the conftest of a directory right before we run its collect(). A
conftest can affect a directory's collect() (e.g. with a
pytest_ignore_collect hookimpl), but it cannot affect how the directory
node itself is collected. So I just moved the conftest loading to be
done right before calling collect, but still inside the CollectReport
context.

This allows the hoisting, and also removes conftest loading from
gethookproxy since it's no longer necessary. And it will probably enable
further cleanups. So I'm happy with it.
2023-12-10 17:01:39 +02:00
Ran Benita 385796ba49 Rework Session and Package collection
Fix #7777.
2023-12-10 17:01:39 +02:00
Ran Benita f411c8d6d7 main: add `with_parents` parameter to `isinitpath`
Will be used in upcoming commit.
2023-12-10 16:32:54 +02:00
Ran Benita c7fcb3f281
Merge pull request #11689 from pytest-dev/update-plugin-list/patch-d1675646f
[automated] Update plugin list
2023-12-10 09:59:06 +02:00
Ran Benita c1339628d6
Merge pull request #11684 from bluetech/docs-nitpicky
docs: enable Sphinx nitpicky mode
2023-12-10 09:42:30 +02:00
Ran Benita 397769c45e
Merge pull request #11677 from bluetech/nodes-abc
nodes,python: mark abstract node classes as ABCs
2023-12-10 09:41:46 +02:00
pytest bot 5381cd083f [automated] Update plugin list 2023-12-10 00:20:38 +00:00
Ran Benita 0ae02e2165 nodes,python: mark abstract node classes as ABCs
Fixes #11676
2023-12-07 16:41:07 +02:00
Ran Benita 2aa8743bbe doc: enable Sphinx nitpicky mode
See:
https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-nitpicky

This ensures we have no more broken references.
2023-12-07 12:14:45 +02:00
Ran Benita ee91d095f6 doc: fix more broken Sphinx references 2023-12-07 11:50:02 +02:00
Ran Benita f76af423b0 doc/reference: document `FixtureLookupError` 2023-12-07 11:50:02 +02:00
Ran Benita 4918883336 python_api: remove unused function `_non_numeric_type_error` 2023-12-07 11:03:52 +02:00
Ran Benita d1675646f2
Merge pull request #11678 from pytest-dev/doc-nitpicks
doc: fix some broken Sphinx references
2023-12-07 09:40:52 +02:00
Ran Benita 9056db4de5 doc: fix some broken Sphinx references 2023-12-07 00:30:35 +02:00
Ran Benita a5ee9f2ecd doc: document `pytest.{hookspec,hookimpl}` in the API Reference
Makes sense for them to be there; also allows for Sphinx refs.
2023-12-07 00:11:42 +02:00
Benjamin Schubert a536f49d91
Separate the various parts of the error report with newlines (#11659)
Previously the error report would have all sections glued together:

- The assertion representation
- The error explanation
- The full diff

This makes it hard to see at a glance where which one starts and ends.

One of the representation (dataclasses, tuples, attrs) does display a
newlines at the start already.

Let's add a newlines before the error explanation and before the full
diff, so we get an easier to read report.

This has one disadvantage: we get one line less in the least verbose
mode, where the output gets truncated.
2023-12-06 09:25:00 +00:00
Ran Benita cd269f0e6d
Merge pull request #11668 from bluetech/rm-setup-py
Remove `setup.py`
2023-12-05 17:29:43 +02:00
Ran Benita b8118ab70d Remove `setup.py`
Fix #11667.
2023-12-04 22:45:59 +02:00
dependabot[bot] 022f1b4de5
build(deps): Bump pytest-bdd in /testing/plugins_integration (#11665)
Bumps [pytest-bdd](https://github.com/pytest-dev/pytest-bdd) from 7.0.0 to 7.0.1.
- [Release notes](https://github.com/pytest-dev/pytest-bdd/releases)
- [Changelog](https://github.com/pytest-dev/pytest-bdd/blob/master/CHANGES.rst)
- [Commits](https://github.com/pytest-dev/pytest-bdd/compare/7.0.0...7.0.1)

---
updated-dependencies:
- dependency-name: pytest-bdd
  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>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2023-12-04 13:58:18 +00:00
dependabot[bot] db8c6f1da8
build(deps): Bump pytest-asyncio in /testing/plugins_integration (#11664)
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.21.1 to 0.23.1.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.21.1...v0.23.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-04 10:41:34 -03:00
dependabot[bot] 3e14c4b3c4
build(deps): Bump pypa/gh-action-pypi-publish from 1.8.10 to 1.8.11 (#11663)
Bumps [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) from 1.8.10 to 1.8.11.
- [Release notes](https://github.com/pypa/gh-action-pypi-publish/releases)
- [Commits](https://github.com/pypa/gh-action-pypi-publish/compare/v1.8.10...v1.8.11)

---
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-12-04 10:41:20 -03:00
github-actions[bot] 714ce2e872
[automated] Update plugin list (#11658)
Co-authored-by: pytest bot <pytestbot@users.noreply.github.com>
2023-12-03 11:49:36 -03:00
touilleWoman 5689d806cf
Fix "Customizing Colors" documentation section (#11652)
Fixes #11573
2023-12-01 11:25:01 -03:00
Ran Benita 0f6c17ca83
Merge pull request #11654 from pytest-dev/testing-unnecessary-skip
testing: remove a no longer necessary skip
2023-12-01 00:28:23 +02:00
Ran Benita ef699f8c17 testing: remove a no longer necessary skip
pytest-xdist was released at 2019-02-15, seems enough time.
2023-11-30 19:53:31 +02:00
Ran Benita 81c06b3955
Merge pull request #11650 from bluetech/tr-test-isolation
testing: fix isolation issue in `tr` fixture
2023-11-28 20:14:20 +02:00
Ran Benita 968510b6aa testing: fix isolation issue in `tr` fixture
The default for `_prepareconfig` is to use `sys.argv`, which in this
case are the flags passed to (top-level) `pytest`. This is not the
intention, the tests themselves should not be affected by it.
2023-11-28 19:54:24 +02:00