Ran Benita
4059000834
testing/python/collect: replace use of deprecated/removed imp module
2023-06-07 17:05:52 +03:00
dependabot[bot]
85c5bd26b6
build(deps): Bump pytest-xvfb in /testing/plugins_integration ( #11079 )
...
Bumps [pytest-xvfb](https://github.com/The-Compiler/pytest-xvfb ) from 2.0.0 to 3.0.0.
- [Changelog](https://github.com/The-Compiler/pytest-xvfb/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/The-Compiler/pytest-xvfb/compare/v2.0.0...v3.0.0 )
---
updated-dependencies:
- dependency-name: pytest-xvfb
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-06-05 12:06:55 +02:00
Ran Benita
fda8024622
cacheprovider: make file-skipping work with any File, not just Modules
...
No reason for `--lf`'s whole-file-skipping feature to not for for
non-Python files.
Fix #11068 .
2023-06-03 09:32:26 +03:00
Ran Benita
c76ae74bd7
cacheprovider: fix file-skipping functionality across packages
...
Continuation of fc538c5766 .
Fixes #11054 again.
2023-05-30 23:16:43 +03:00
Ran Benita
24534cdd29
Merge pull request #11043 from bluetech/confcutdir-rootpath
...
config: fallback confcutdir to rootpath if inipath is not set
2023-05-30 20:21:20 +03:00
Ran Benita
99c78aa93a
Merge pull request #10921 from bluetech/tb-simplify-2
...
Fix hidden traceback entries of chained exceptions getting shown
2023-05-30 20:09:13 +03:00
Ran Benita
3a6bdcd76b
Merge pull request #11055 from bluetech/lf-skipped-package
...
cacheprovider: fix file-skipping feature for files in packages
2023-05-30 20:04:06 +03:00
Ran Benita
4a1bba25b9
config: fallback confcutdir to rootpath if inipath is not set
...
Currently, if `--confcutdir` is not set, `inipath.parent` is used, and
if `initpath` is not set, then `confcutdir` is None, which means there
is no cutoff.
Having no cutoff is not great, it means we potentially start probing
stuff all the way up to the filesystem root directory. So let's add
another fallback, to `rootpath`, which is always something reasonable.
2023-05-30 19:52:59 +03:00
Alessio Izzo
9e1add75f7
Fix warlus operator behavior when called by a function ( #11041 )
...
In #10758 we introduced the support for the use of the walrus operator in the test cases. There was a case which was not handled that caused a bug report #11028 . This PR aims to fix the issue and also to improve how the walrus operator is handled in the AssertionRewriter class.
Closes #11028
2023-05-30 11:59:24 -03:00
theirix
4da9026766
Handle microseconds with custom logging.Formatter ( #11047 )
...
Added handling of %f directive to print microseconds in log format options, such as log-date-format. It is impossible to do with a standard logging.Formatter because it uses time.strftime which doesn't know about milliseconds and %f. In this PR I added a custom Formatter which converts LogRecord to a datetime.datetime object and formats it with %f flag. This behaviour is enabled only if a microsecond flag is specified in a format string.
Also added a few tests to check the standard and changed behavior.
Closes #10991
2023-05-30 09:35:33 -03:00
Kenny Y
7c231baa64
Add warning when testpaths is set but paths are not found by glob ( #11044 )
...
Closes #11013
---------
Co-authored-by: Ran Benita <ran@unusedvar.com >
2023-05-30 07:06:13 -03:00
Ran Benita
fc538c5766
cacheprovider: fix file-skipping feature for files in packages
...
`--lf` has a feature where if a certain `Module` (python file) does not
contain any failed tests, it is skipped entirely at the collector level
instead of being collected and each item skipped individually. When this
happens the collection summary looks like this:
run-last-failure: rerun previous 1 failure (skipped 1 file)
However, this feature didn't work for `Module`s inside of `Package`s,
only for those directly beneath the `Session`.
Fix #11054 .
2023-05-29 22:55:44 +03:00
dependabot[bot]
fbfd4b5005
build(deps): Bump anyio[curio,trio] in /testing/plugins_integration ( #11050 )
...
Bumps [anyio[curio,trio]](https://github.com/agronholm/anyio ) from 3.6.2 to 3.7.0.
- [Changelog](https://github.com/agronholm/anyio/blob/3.7.0/docs/versionhistory.rst )
- [Commits](https://github.com/agronholm/anyio/compare/3.6.2...3.7.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-05-29 07:55:42 +02:00
dependabot[bot]
ec752537ea
build(deps): Bump pytest-cov in /testing/plugins_integration ( #11051 )
...
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov ) from 4.0.0 to 4.1.0.
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst )
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v4.0.0...v4.1.0 )
---
updated-dependencies:
- dependency-name: pytest-cov
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-05-29 07:55:13 +02:00
Ran Benita
dd667336ce
nodes: apply same traceback filtering for chained exceptions as main exception
...
Fix #1904 .
2023-05-28 17:20:50 +03:00
Chris Mahoney
4f3f36c396
Add alias --config-file to -c ( #11036 )
...
Fixes #11031
Signed-off-by: Chris Mahoney <chrismahoey@hotmail.com >
Co-authored-by: Chris Mahoney <chrismahoey@hotmail.com >
2023-05-26 07:56:18 -03:00
Alex Lambson
ba32a3bd87
Handle disabled logging in 'caplog.set_level' and 'caplog.at_level' ( #8758 )
...
Forces requested `caplog` logging levels to be enabled if they were disabled via `logging.disable()`
`[attr-defined]` mypy error ignored in `logging.py` because there were existing errors with the imports
and `loggin.Logger.manager` is an attr set at runtime. Since it's in the standard lib I can't really fix that.
Ignored an attr-defined error in `src/_pytest/config/__init__.py` because the re-export is necessary.
Fixes #8711
2023-05-18 10:18:59 -03:00
Ville Skyttä
c8641f879f
Include reason in cache path warnings to aid debugging ( #11005 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com >
2023-05-18 10:11:47 -03:00
Ville Skyttä
6041511fb4
Spelling and grammar fixes ( #11014 )
2023-05-18 10:10:44 -03:00
Adam J. Stewart
3b5b3cf50e
monkeypatch: add support for TypedDict ( #11000 )
2023-05-14 22:17:00 +03:00
Bruno Oliveira
2d57d5c32f
Do not break on very long command-line options
...
`_set_initial_conftests` could break on some systems if a very long
option was passed, because the `Path.exists()` call raises an
`OSError` instead of returning `False`.
Fix #10169
2023-05-12 09:34:15 -03:00
Bruno Oliveira
faeb16146b
Consider testpaths for initial conftests
...
The 'testpaths' option is meant to be identical to execute
pytest passing the 'testpaths' directories explicitly.
Fix #10987
2023-05-12 09:34:15 -03:00
dependabot[bot]
6514041a35
build(deps): Bump django in /testing/plugins_integration
...
Bumps [django](https://github.com/django/django ) from 4.2 to 4.2.1.
- [Commits](https://github.com/django/django/compare/4.2...4.2.1 )
---
updated-dependencies:
- dependency-name: django
dependency-type: direct:production
update-type: version-update:semver-patch
...
Signed-off-by: dependabot[bot] <support@github.com >
2023-05-08 03:56:49 +00:00
Brian Larsen
7d548c38e2
Improve verbose output by wrapping skip/xfail reasons with margin ( #10958 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com >
2023-05-06 12:15:11 -03:00
Ran Benita
6f7f89f3c4
code: make TracebackEntry immutable
...
TracebackEntry being mutable caught me by surprise and makes reasoning
about the exception formatting code harder. Make it a proper value.
2023-04-28 11:47:45 +03:00
Ran Benita
0a20452f78
code: inline Traceback.getcrashentry into ExceptionInfo._getreprcrash
...
Since `Traceback.getcrashentry` takes the `ExceptionInfo`, it is not
really independent of it and is in the wrong layer. Prevent nonsensical
mistakes by inlining it.
2023-04-28 11:47:45 +03:00
Ran Benita
cc23ec91d0
code: stop storing weakref to ExceptionInfo on Traceback and TracebackEntry
...
TracebackEntry needs the excinfo for the `__tracebackhide__ = callback`
functionality, where `callback` accepts the excinfo.
Currently it achieves this by storing a weakref to the excinfo which
created it. I think this is not great, mixing layers and bloating the
objects.
Instead, have `ishidden` (and transitively, `Traceback.filter()`) take
the excinfo as a parameter.
2023-04-28 11:47:45 +03:00
Miro Hrončok
e03f82c359
Filter new pkg_resources deprecations ( #10938 )
...
Fixes https://github.com/pytest-dev/pytest/issues/10815
2023-04-25 10:51:10 +02:00
Ran Benita
11965d1c27
Merge pull request #10920 from bluetech/testing-no-testdir
...
testing: remove usages of testdir that sneaked back in
2023-04-18 22:49:23 +03:00
dependabot[bot]
2d6206b89a
build(deps): Bump pytest-sugar in /testing/plugins_integration ( #10922 )
...
Bumps [pytest-sugar](https://github.com/Teemu/pytest-sugar ) from 0.9.5 to 0.9.7.
- [Release notes](https://github.com/Teemu/pytest-sugar/releases )
- [Changelog](https://github.com/Teemu/pytest-sugar/blob/main/CHANGES.rst )
- [Commits](https://github.com/Teemu/pytest-sugar/commits/v0.9.7 )
---
updated-dependencies:
- dependency-name: pytest-sugar
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-04-17 08:55:36 +02:00
Alex
41f57ef95d
Fix pytrace=False and --tb=line reports None ( #10905 )
...
Closes #10831 .
This fixes a small bug where running tests that contained
`pytest.fail(pytrace=False)` with the `--tb=line` flag set results in
an output of "None" in the Failures section of the output, and adds
a test to ensure the behavior is correct.
2023-04-16 20:31:45 +00:00
Ran Benita
819f5abd73
testing: remove usages of testdir that sneaked back in
2023-04-16 19:18:50 +03:00
Ran Benita
b893d2a0fe
Merge pull request #10907 from bluetech/empty-traceback
...
code: handle repr'ing empty tracebacks gracefully
2023-04-13 19:36:09 +03:00
Ran Benita
e3b1799766
code: handle repr'ing empty tracebacks gracefully
...
By "empty traceback" I mean a traceback all of whose entries have been
filtered/cut/pruned out.
Currently, if an empty traceback needs to be repr'ed, the last entry
before the filtering is used instead (added in
accd962c9f ).
Showing a hidden frame is not so good IMO. This commit does the
following instead:
1. Shows details of the exception.
2. Shows a message about how the full trace can be seen.
Example:
```
_____________ test _____________
E ZeroDivisionError: division by zero
All traceback entries are hidden. Pass `--full-trace` to see hidden and internal frames.
```
Also handles `--tb=native`, though there the `--full-trace` bit is not
shown.
This commit contains some pieces from
431ec6d34e (which has been reverted).
Helps towards fixing issue # 1904.
Co-authored-by: Felix Hofstätter <Felhof1@hotmail.com >
2023-04-13 19:11:37 +03:00
Ran Benita
5d1385320f
Merge pull request #10901 from bluetech/exceptioninfo-from-exception
...
code: add `ExceptionInfo.from_exception`
2023-04-13 16:04:48 +03:00
Ran Benita
90412827c3
Revert "Correctly handle tracebackhide for chained exceptions ( #10772 )"
...
This reverts commit 431ec6d34e .
Fix #10903 .
Reopen #1904 .
2023-04-12 19:23:25 +03:00
Ran Benita
424c3eebde
code: add ExceptionInfo.from_exception
...
The old-style `sys.exc_info()` triplet is redundant nowadays with
`(type(exc), exc, exc.__traceback__)`, and is beginning to get
soft-deprecated in Python 3.12.
Add a nicer API to ExceptionInfo which takes just the exc instead of the
triplet. There are already a few internal uses which benefit.
2023-04-12 13:16:48 +03:00
Ran Benita
1b196fbeaf
pathlib: fix Python 3.12 rmtree(onerror=...) deprecation
...
Fixes #10890
Ref: https://docs.python.org/3.12/library/shutil.html#shutil.rmtree
2023-04-11 13:24:32 +03:00
dependabot[bot]
e4e13dd913
build(deps): Bump django in /testing/plugins_integration ( #10886 )
...
Bumps [django](https://github.com/django/django ) from 4.1.7 to 4.2.
- [Release notes](https://github.com/django/django/releases )
- [Commits](https://github.com/django/django/compare/4.1.7...4.2 )
---
updated-dependencies:
- dependency-name: django
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-04-10 08:21:27 -03:00
Kodi Arfer
3683722bcb
FormattedExcinfo.get_source: avoid crash when line number is out-of-bounds/negative
...
pytest could crash given pathological AST position attributes, which shouldn't happen when testing real Python code, but could happen when testing AST produced by e.g. Hylang.
Another example of the failure is in the nightly CI for the JAX project: https://github.com/google/jax/actions/runs/4607513902/jobs/8142126075
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com >
Co-authored-by: Jake VanderPlas <jakevdp@google.com >
2023-04-05 22:48:24 -03:00
dependabot[bot]
549cc512f7
build(deps): Bump pytest-asyncio in /testing/plugins_integration ( #10827 )
...
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio ) from 0.20.2 to 0.21.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases )
- [Commits](https://github.com/pytest-dev/pytest-asyncio/compare/v0.20.2...v0.21.0 )
---
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-03-24 11:40:06 -03:00
Ronny Pfannschmidt
407b330fe1
split up report header lines
...
i found it painful to read crammed in a single line
thus rootdir, config file and testpaths now have own lines
2023-03-17 21:58:26 +01:00
Felix Hofstätter
431ec6d34e
Correctly handle tracebackhide for chained exceptions ( #10772 )
2023-03-15 08:10:25 -03:00
dependabot[bot]
ab069247cd
build(deps): Bump pytest-rerunfailures in /testing/plugins_integration ( #10812 )
...
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures ) from 11.1.1 to 11.1.2.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases )
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst )
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/11.1.1...11.1.2 )
---
updated-dependencies:
- dependency-name: pytest-rerunfailures
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-03-13 08:00:07 -03:00
Alessio Izzo
6e478b0947
Fix walrus operator support in assertion rewriting ( #10758 )
...
Closes #10743
2023-03-10 07:32:36 -03:00
Paul Kehrer
a869141b3d
New option to allow a progress report even when capture=no ( #10755 )
2023-03-07 17:49:37 -03:00
Bruno Oliveira
97a2761d72
Fix test_cmdline_python_namespace_package ( #10788 )
...
pgk_resources.declare_namespace has been deprecated, so added an ignore warnings option
to the test.
2023-03-03 12:25:33 -03:00
dependabot[bot]
44afed9b13
build(deps): Bump pytest-rerunfailures in /testing/plugins_integration ( #10754 )
...
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures ) from 11.1 to 11.1.1.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases )
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst )
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/11.1...11.1.1 )
---
updated-dependencies:
- dependency-name: pytest-rerunfailures
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-02-27 08:56:25 -03:00
dependabot[bot]
835cac8d8b
build(deps): Bump django in /testing/plugins_integration
...
Bumps [django](https://github.com/django/django ) from 4.1.6 to 4.1.7.
- [Release notes](https://github.com/django/django/releases )
- [Commits](https://github.com/django/django/compare/4.1.6...4.1.7 )
---
updated-dependencies:
- dependency-name: django
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com >
2023-02-15 20:40:12 +00:00
dependabot[bot]
00c94ab01b
build(deps): Bump pytest-rerunfailures in /testing/plugins_integration ( #10731 )
...
Bumps [pytest-rerunfailures](https://github.com/pytest-dev/pytest-rerunfailures ) from 11.0 to 11.1.
- [Release notes](https://github.com/pytest-dev/pytest-rerunfailures/releases )
- [Changelog](https://github.com/pytest-dev/pytest-rerunfailures/blob/master/CHANGES.rst )
- [Commits](https://github.com/pytest-dev/pytest-rerunfailures/compare/11.0...11.1 )
---
updated-dependencies:
- dependency-name: pytest-rerunfailures
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-02-13 08:05:47 -03:00