Commit Graph

2763 Commits

Author SHA1 Message Date
Bruno Oliveira 443b081c27 [7.1.x] Fix a few broken links in the documentation. 2022-10-06 17:16:51 +00:00
github-actions[bot] 14b276309a
[7.1.x] fallback to native traceback when handling ExceptionGroup (take 2) [SQUASH] (#10305)
Co-authored-by: John Litborn <11260241+jakkdl@users.noreply.github.com>
2022-09-20 10:12:44 -07:00
Bruno Oliveira aae93d6127 Ignore type-errors related to attr.asdict 2022-08-26 09:57:18 -03:00
Gergely Kalmár 71b79fcda5 [7.1.x] Ignore editable installation modules 2022-08-26 12:48:36 +00:00
Bruno Oliveira 9b2c6cedc7 [7.1.x] Add reference to the Where to patch docs in monkeypatch.setattr 2022-08-15 17:13:13 +00:00
Sviatoslav Sydorenko f5cdd18b6a [7.1.x] Mention `monkeypatch.context()` in the docs 2022-08-13 19:08:56 +00:00
github-actions[bot] 6f8c4fa742
[7.1.x] JUnit XML: Escape error messages in setup/teardown (#10207)
Co-authored-by: holesch <8659229+holesch@users.noreply.github.com>
2022-08-12 10:06:32 +00:00
Wolfremium da7daaac92 [7.1.x] Explicit note that tmpdir fixture is discouraged in favour of tmp_path #9937 2022-07-15 11:41:58 +00:00
Nipunn Koorapati 9b3affc006 [7.1.x] Add typing for FixtureRequest.param 2022-07-14 23:37:36 +00:00
Anthony Sottile 55189ebda6 [7.1.x] Fix mypy pre-commit run 2022-07-11 12:49:27 +00:00
Anthony Sottile 199367168b [7.1.x] replace atomicwrites with os.replace
(cherry picked from commit 7dc540f258)
2022-07-08 19:13:28 -07:00
Anthony Sottile 549e3136cc [7.1.x] Pass importmode to import_path in DoctestModule 2022-06-30 05:46:18 -07:00
Bruno Oliveira 9a16e69835 [7.1.x] Do not call tearDown for skipped unittest.TestCases with --pdb 2022-06-28 15:51:30 +00:00
Bruno Oliveira 0e7a6a769e [7.1.x] Use PurePath directly instead of os.path.sep in rewrite.py 2022-06-27 13:00:17 +00:00
Bruno Oliveira 9c3bc106dd [7.1.x] Added Docstring description for the Path property of FixtureRequest #9975 2022-06-25 23:56:46 +00:00
Zach OBrien dc0812610d [7.1.x] Fix representation of tuples in approx 2022-06-14 09:56:12 +00:00
Bruno Oliveira 796574f3b8 [7.1.x] Fix rst markup in TempdirFactory's docstring. 2022-05-17 11:23:53 +00:00
Bruno Oliveira 91d84e9256 [7.1.x] Move documentation contents from reference.rst to docstrings 2022-05-10 20:23:08 +00:00
Zac Hatfield-Dodds 3a7ead6bcf [7.1.x] fix: move 'import getpass' statement to try-clause 2022-04-21 02:46:24 +00:00
Hugo van Kemenade ddbb998aed [7.1.x] Increase stacklevel to point at user's code 2022-04-20 16:09:01 +00:00
Anthony Sottile 5ef96fdb53 [7.1.x] fix comparison of dataclasses with `InitVar` 2022-04-09 00:48:09 +00:00
Kian Eliasi 78356dc353 [7.1.x] Remove unnecessary numpy import 2022-03-21 01:35:22 +00:00
Bruno Oliveira 93fad3286b [7.1.x] [style]: fix typo in docstring 2022-03-18 21:59:16 +00:00
Ran Benita f1df8074b3 [7.1.x] config: restore pre-pytest 7.1.0 confcutdir exclusion behavior 2022-03-17 16:15:03 +00:00
Bruno Oliveira e38d1cac48 Improve error message for malformed pyproject.toml files
Including the file name is enough to let the user know what the problem is.

The same is not needed for `.ini` files because the error message includes the path to the file by default.

Fix #9730
2022-03-05 08:59:28 -03:00
Bruno Oliveira f943d1944a pytester now requests monkeypatch instead of creating its own instance
It is tempting to use `monkeypatch` to replace the other mechanisms in pytester which change global
state: `CwdSnapshot`, `SysModulesSnapshot`, `SysPathsSnapshot`, however those are more delicate
than they look at first glance so leaving those alone for now.

Close #9708
2022-03-04 08:58:44 -05:00
Bruno Oliveira 5f3d94c47e
Disallow unordered sequences in pytest.approx (#9709)
Fix #9692
2022-02-24 10:16:35 -03:00
Ran Benita 7b6e477e2f
Revert "Deprecate raising unittest.SkipTest to skip tests during collection" (#9710)
This reverts commit 25e657bfc1.

Turns out that this *is* a working unittest feature, which pytest should
support, so undo the deprecation.
2022-02-23 15:59:54 +02:00
Bruno Oliveira 9af3e23695
Expand warnings output for ResourceWarning (#9682)
Fix #9644
2022-02-15 13:00:50 +00:00
Ran Benita bdbad91493
Merge pull request #9546 from bluetech/fixturedef-attr-doc
fixtures: document FixtureDef's attributes
2022-02-15 14:52:50 +02:00
Bruno Oliveira fac8f284cd
Fix diff output for data types where `-v` would show less information (#9661)
Close #5192
2022-02-15 09:43:20 -03:00
Ran Benita afe41e5273
Merge pull request #9678 from bluetech/consistent-idval
python: unify code to generate ID from value
2022-02-15 13:23:35 +02:00
eduardo naufel schettino c9cf2d4424
Fix count of selected tests on terminal collection summary (#9628) 2022-02-15 11:17:34 +00:00
Bruno Oliveira 747b8372ea Try to import module before creating dummy modules with 'importmode=importlib'
The dummy modules we introduce in `insert_missing_modules` (due to #7856 and #7859)
would cause problems if the dummy modules actually end up replacing modules
which could be imported normally because they are available in `PYTHONPATH`.

Now we attempt to first import the module via normal mechanisms, and only
introduce the dummy modules if the intermediary modules don't actually exist.

Close #9645
2022-02-14 09:42:05 -03:00
Ran Benita c3aa4647c7 python: unify code to generate ID from value
In the following

    @pytest.mark.parametrize(..., ids=[val])

the ID values are only allowed to be `str`, `float`, `int` or `bool`.

In the following

    @pytest.mark.parametrize(..., [val])

    @pytest.mark.parametrize(..., [pytest.param(..., id=val])

a different code path is used, which also allows `bytes`, `complex`,
`re.Pattern`, `Enum` and anything with a `__name__`.

In the interest of consistency, use the latter code path for all cases.
2022-02-12 19:22:37 +02:00
Bruno Oliveira 8afec9a64d
Add autoflake to pre-commit configuration (#9666) 2022-02-11 14:34:02 -03:00
Bruno Oliveira 3586edc1c9
Merge pull request #9646 from nicoddemus/9643-delay-warning 2022-02-10 14:11:21 -03:00
Bruno Oliveira 88c35123b8 Delay warning about collector/item diamond inheritance
This allows that warning to be filtered by `filterwarnings`.

Fix #9643
2022-02-10 13:50:25 -03:00
Ran Benita 2b6708b892
Merge pull request #9624 from bluetech/unittest-getobj
unittest: restore `UnitTestFunction.obj` to return unbound rather than bound method
2022-02-09 22:43:31 +02:00
Ran Benita 01e1de7a1a Rename ``pythonpath`` plugin to ``python_path``
Fix #9636.
2022-02-09 10:03:20 +02:00
Ran Benita 44290d1f6c
Merge pull request #9609 from kdelee/patch-1
importlib.readers not valid until python 3.10
2022-02-08 15:57:48 +02:00
Anthony Sottile 2442034a1e allow running testids which contain :: in the parametrized portion 2022-02-07 20:19:59 -05:00
Ran Benita d00ca3f8e5 unittest: restore `UnitTestFunction.obj` to return unbound rather than bound method
This fixes #9610.

pytest 7.0.0 (unintentionally) changed `UnitTestFunction.obj`'s' behavior
to match `Function.obj`. That is probably a good thing to have, however
it evidently causes some regressions as described in the issue, so
restore the previous behavior for now. In the future we might want to
make this change again, but with proper consideration.
2022-02-08 00:46:00 +02:00
pre-commit-ci[bot] 2073cce105 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-02-08 00:44:52 +02:00
Elijah DeLee d45a19cfde move function specific imports to function
re: review from @asottile that this should only get imported in the function
modify the else/if logic since inside the function we already know the python version is >= 3.10, and just have to know if it is 3.11 or greater
2022-02-08 00:44:52 +02:00
Bruno Oliveira f86a87a315 Update src/_pytest/assertion/rewrite.py
Co-authored-by: Ran Benita <ran@unusedvar.com>
2022-02-08 00:44:52 +02:00
Bruno Oliveira 5f1a2f33da Fix invalid importing of `importlib.reader` in Python 3.9
Fix #9608
2022-02-08 00:44:52 +02:00
Elijah DeLee 15ddccf700 importlib.readers not valid until python 3.10
This exists https://github.com/python/cpython/blob/3.10/Lib/importlib/readers.py and FileReader is in there
This is a 404 https://github.com/python/cpython/blob/3.9/Lib/importlib/readers.py

This change needs to get backported to the 7.0.z branch(s) too
Fixes https://github.com/pytest-dev/pytest/issues/9608
2022-02-08 00:44:52 +02:00
Ran Benita 20c2c30ff2 mark/structures: use class-based NamedTuple syntax
Should hopefully work now in Python>=3.7.
2022-02-05 11:52:36 +02:00
pre-commit-ci[bot] 9d2ffe207b [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2022-01-31 22:20:16 +00:00