Commit Graph

564 Commits

Author SHA1 Message Date
Alessio Izzo 6e478b0947
Fix walrus operator support in assertion rewriting (#10758)
Closes #10743
2023-03-10 07:32:36 -03:00
HTRafal 5e1c3d2477
Propagate timestamps from CallInfo to TestReport objects (#10711)
This makes it possible to correlate pytest stages with external events, and also makes it readable when TestReports are exported externall (for example with pytest-reportlog).

Closes #10710
2023-02-10 17:52:54 -03:00
Teejay 5dbfb8e108
Fix fixtures named teardown being considered by nose (#10696)
Closes #10597
2023-01-27 14:33:46 -03:00
Yannick PÉROUX af4143729f
Allow spaces in -p arguments (#10658) 2023-01-21 08:22:44 -03:00
q0w bd7919e03d
Initialize args and args_source during Config.__init__
Closes #10626

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2023-01-21 08:19:54 -03:00
Ramsey 4d4ed42c34
Fix crash if `--cache-show` and `--help` are passed at the same time
Closes #10592
2023-01-19 09:44:57 -03:00
s-padmanaban 8efb4bb9c1
Do not update cache from xdist worker (#10641) 2023-01-13 07:14:52 -03:00
Pierre Sassoulas b31db4809b
Avoid truncation when truncating means longer output (#10446)
Fixes #6267
2022-12-17 10:24:46 -03:00
Marko Pacak 9fbd67dd4b
Class methods can now be discovered as tests (#10552)
Fix #10525
2022-12-02 15:53:04 +00:00
Daniel Valenzuela 791b51d0fa
Show test name when skipping from fixture (#10482)
Fixes #10457
2022-11-18 09:20:38 -03:00
Yusuke Kadowaki cca029d55e
Add configuration options to control how `tmp_path` directories are kept (#10442)
Close #8141
2022-11-15 09:11:39 -03:00
Ashish Kurmi 1ada62e237
Update dependabot for GitHub Actions (#10464)
Signed-off-by: Ashish Kurmi <akurmi@stepsecurity.io>

Signed-off-by: Ashish Kurmi <akurmi@stepsecurity.io>
2022-11-04 07:41:34 -03:00
Cal Jacobson 692ab1160b
add Cal Jacobson to AUTHORS 2022-10-30 22:02:18 -05:00
Gabriel Landau 0bc9ffcc87 Add Gabriel Landau to AUTHORS 2022-10-14 14:01:20 -04:00
itxasos23 78c2c48c67
Handle NFC/NFD strings that normalize to the same string. (#10355)
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
2022-10-09 17:09:33 -07:00
Vivaan Verma 196f01965e
Replace entrypoint example with `pyproject.toml` in docs (#10359)
Fixes #10344
2022-10-09 17:42:42 -03:00
John Litborn 69f2855cc8
fallback to native traceback when handling ExceptionGroup (take 2) [SQUASH] (#10209)
* Squashed commit of the following:

commit 41d339c46763bbe26123e1e6504b6e32290e33e1
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 17:01:04 2022 +0800

    test in all py versions

commit b3572a5a12672228c3276fc8c8e05980dfb7888a
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 16:41:06 2022 +0800

    add test

commit 7166a2a51e4f99046b028b663c193d8b558c7fd4
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 16:00:07 2022 +0800

    update changelog

commit b958c73d489157f0c0d4e46425083a5e2e2bc851
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Thu Jun 23 07:50:52 2022 +0000

    [pre-commit.ci] auto fixes from pre-commit.com hooks

    for more information, see https://pre-commit.ci

commit ea7f376c6ca37c40c83df0e4a1cfaaedb34bae91
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 15:48:21 2022 +0800

    Fix MyPy

commit 97469beb1da40257e9a061a5e19548546c9312c4
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 15:03:48 2022 +0800

    fix if ExceptionGroup not exist

commit 84e553642cd69b4d499231d733df91ebfa84c7ad
Author: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date:   Thu Jun 23 03:43:27 2022 +0000

    [pre-commit.ci] auto fixes from pre-commit.com hooks

    for more information, see https://pre-commit.ci

commit 76bbef449b88bbd74fb5cca3b5293337a624ef03
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 11:40:41 2022 +0800

    adding changelog

commit db82bebc5a4969e2083adcd97bdfd2a63bb17d98
Author: Cheukting <cheukting.ho@gmail.com>
Date:   Thu Jun 23 11:33:10 2022 +0800

    fall back to native when handeling to exception groups

* Typed ExceptionGroupTypes and changed to BaseExceptionGroup, fixed exceptionchain (excinfo->excinfo_, set reprcrash. Extended tests, though they're wip.

* added exceptiongroup to pre-commit-config, moved away from tuple to directly defining BaseExceptionGroup, added block comment, added match line for inner exception, changked mark.skipif to importorskip to not need top-level import, changed tox.ini a bit - only uncovered should now be py37 without exceptiongroup, due to hypothesis

* added py311-exceptiongroup to github CI, exceptiongroup is now a hard dependency on py<3.11, renamed bad variable names

* added use_coverage to ubuntu-py311

* import BaseExceptionGroup with explicit version check instead of try/catch

* removed from CI, added comments to tox and pre-commit
2022-08-17 09:16:32 -07:00
holesch cc0092b9d8
JUnit XML: Escape error messages in setup/teardown (#10190)
Co-authored-by: Holesch, Simon (BSH) <simon.holesch@bshg.com>
2022-08-12 11:11:03 +02:00
Wolfremium 70cac3d464
Explicit note that tmpdir fixture is discouraged in favour of tmp_path #9937 (#10138)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: kevin.hierro-ext <kevin.hierro-ext@clarity.ai>
Co-authored-by: Dani Sancas <lord.sancas@gmail.com>
2022-07-15 08:40:18 -03:00
Nipunn Koorapati c1d134172c
Add typing for FixtureRequest.param (#10133)
For now, mark it as Any until #8073 is solved

Fixes #9514
2022-07-14 20:36:05 -03:00
Ronny Pfannschmidt 966d4fb3e4
Merge pull request #10051 from EmptyRabbit/dev_main
Fix stage caplog records not clear
2022-07-08 07:46:10 +02:00
Alice Purcell 85000f037f Added Alice Purcell to AUTHORS 2022-06-29 14:39:04 +01:00
Bruno Oliveira aafac5578c
Merge pull request #10056 from paulreece/fixture-path-doc-fix
Added Docstring description for the Path property of FixtureRequest #9975
2022-06-25 20:55:23 -03:00
zx.qiu c7e784f95d Fix stage caplog records not clear
Closes #9877
2022-06-24 23:03:37 +08:00
Kevin C 0a7b8722e5 Clarify writing_plugins naming instructions
Fixes: #10072
2022-06-23 18:03:18 -07:00
Paul Reece cdc287d21a Added self to Authors 2022-06-17 12:00:18 -04:00
Chris Wheeler fab696dcd1
Add support for .pytest.ini as an alternative to pytest.ini
Closes #9987
2022-06-14 08:24:35 -03:00
Zach OBrien 96412d19ab
Fix representation of tuples in approx
Closes #9917
2022-06-14 06:54:32 -03:00
Tony Narlock c2f684fcd6
docs(monkeypatch): Fix autodoc reference links (#10013)
Close #10014
2022-06-02 10:16:59 -03:00
Cheuk Ting Ho c988e49af6
Warn when test functions return other than None (#9956)
Closes #7337
2022-05-25 09:48:02 -03:00
Jon Parise 8ac6dce2c7
Add shell-style wildcard support to 'testpaths' (#9897)
This is especially useful for large repositories (e.g. monorepos) that
use a hierarchical file system organization for nested test paths.

    src/*/tests

The implementation uses the standard `glob` module to perform wildcard
expansion in Config.parse().

The related logic that determines whether or not to include 'testpaths'
in the terminal header was previously relying on a weak heuristic: if
Config.args matched 'testpaths', then its value was printed. That
generally worked, but it could also print when the user explicitly used
the same arguments on the command-line as listed in 'testpaths'. Not a
big deal, but it shows that the check was logically incorrect.

Now that 'testpaths' can contain wildcards, it's no longer possible to
perform this simple comparison, so this change also introduces a public
Config.ArgSource enum and Config.args_source attribute that explicitly
names the "source" of the arguments: the command line, the invocation
directory, or the 'testdata' configuration value.
2022-05-24 10:20:51 +02:00
Babak Keyvani 3444d35c54 improve `pytest.raises` 2022-04-30 17:56:36 -06:00
Tobias Diez 7df405747a
Merge branch 'pytest-dev:main' into patch-1 2022-04-22 12:11:03 +02:00
Paul Müller 8514fab409
Update AUTHORS 2022-04-20 20:15:29 +02:00
Tobias Diez 387ec02021
Add to AUTHORS 2022-03-29 12:38:34 +02:00
Kian Eliasi 3297bb24a9
Remove unnecessary numpy import (#9798)
Fix #9726
2022-03-21 00:01:59 +00:00
Samuel Colvin b75cbee290
Remove newlines from left/right operands with '-vv' (#9743)
The left/right operands produced when `verbose > 1` should not contain newlines, because they are used to 
build the `summary` string. The `assertrepr_compare` function returns a list of lines, and the summary is one of those lines and should not contain newlines itself. 

Fix #9742

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2022-03-19 11:55:39 +00:00
Kojo Idrissa e466a87bb0
Add the latest book edition of 'Python Testing with pytest' 2022-02-25 19:13:23 -03:00
Kian Meng, Ang 55debfad1f
Fix typos (#9424) 2021-12-27 09:23:15 -03:00
Yuval Shimon dc7091502d
Fixed error message prints function decorators when using assert in Python 3.9 and above. (#9359) 2021-12-07 11:31:03 +02:00
GergelyKalmar 82d450f98e Update authors 2021-11-30 19:04:00 +01:00
Harshna 9d17cebe64
Use correct input arg type for _bestrelpath (#9238)
Closes #8990
2021-11-01 17:43:05 +02:00
denivyruck 0191563fd6
DoctTest line numbers not found due to method wrapping (#8861)
Closes #8796
2021-11-01 09:01:25 +02:00
Alexander King 005690bd67
Add template for prereleases (#9165)
Fix #8820
2021-10-22 10:00:00 -03:00
Cristian Vera cbcfeca78c
Cache.set preserves key order when saving dicts (#9206)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-10-18 19:15:34 -03:00
Vijay Arora 307dbf15c4
Add Myself as Authors 2021-10-01 20:16:10 +05:30
ziebam 70a3c965ea Add myself to AUTHORS file 2021-09-22 00:23:13 +02:00
Éloi Rivard 7770dacb8d pygments themes are customizable 2021-08-13 19:15:01 +02:00
Terje Runde 2439729413
logging: Make it possible to add cli colors to custom log levels
Closes #8803
PR #8804

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Terje Runde <terje.runde@flir.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-08-09 13:48:47 +00:00
Emmanuel Arias 2834b39b65
Add examples of parametrizing classes and all tests in a module
Closes #8947

PR #8962
2021-07-31 13:26:25 +00:00
Graeme Smecher 5c04674e96 Generate useful parameterization IDs for complex() numbers. 2021-07-12 12:27:24 -07:00
Taneli Hukkinen e942b12b94 Support TOML v1.0.0 syntax in `pyproject.toml` 2021-07-06 00:26:01 +03:00
Eric Liu 8c25a14032
closes #8824 Changelog rewording for 7.0 (#8826)
* fixed changelog/*.rst docs

* add author name

* fixed-documents

* fix issue 8761 doc

* fix issue 8645 doc

* fix issue 8447 doc

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-07-03 12:20:12 +02:00
James Bourbeau 942789bace
Fix API links in 'How to capture warnings' documentation page (#8792) 2021-06-23 19:34:48 +00:00
Chris Rose 640b2c0e13 Make the test class instance behaviour clearer
In the "Getting Started" doc, the test class instance example for
instance sharing doesn't actually demonstrate anything about the
reinstantiation of the class. This change shows clearly how the instance
data isn't retained between test runs.
2021-05-26 09:12:29 -07:00
Olga Matoula 8b2f83772d Catch any warning on warns with no arg passed 2021-05-15 18:50:39 +01:00
Ran Benita 364bbe42fc
Merge pull request #8649 from Saiprasad16/main
UPDATE LICENSE
2021-05-13 17:34:18 +03:00
Saiprasad Kale 0d6e3b7005
Update AUTHORS 2021-05-11 16:39:25 +05:30
Zack Kneupper 045ad5ac2d
Replaced if-else statements with ternary expression (#8658)
* Replace if-else with ternary expression

* assign out variable in readouterr() with ternary expression

* assign err variable in readouterr() with ternary expression

* Assign precision with ternary expression

* ternary expression for collected/collecting

* Assign thread_name with ternary expression

* Update AUTHORS

Co-authored-by: Zachary Kneupper <zacharykneupper@Zacharys-MBP.lan>
2021-05-11 11:52:55 +02:00
Saiprasad Kale 7caf47acc6
Update AUTHORS 2021-05-08 23:50:17 +05:30
mobius-crypt 385988ca1a
Updated (#8620) 2021-05-05 14:16:21 +02:00
alshapton 4e048e0827
8625 - small grammar fix (#8627) 2021-05-03 20:42:23 +00:00
Parth Patel 992c403fc8
Improve `iterparentnodeids` to consume `/` parts until the first `::` (#8577)
* Fix issue where TestCase.setUpClass is not called for test methods with a / in its name by checking if there is ::  before the selected / or any :: after. Also added a test case for this.

* removed print statement that was added

* Change iterparentnodeids to consume / parts until the first ::. Then consider ::. Tests were changed to reflect this.

* Update changelog/8509.improvement.rst

Co-authored-by: Ran Benita <ran@unusedvar.com>
2021-04-29 17:02:43 +03:00
Abdelrahman Elbehery 9078c3ce23
fix #8464 wrong root dir when -c is passed (#8537)
fix #8464 wrong root dir when -c is passed
2021-04-16 14:38:35 -03:00
hauntsaninja 8be1628042 Fix assertion rewriting on Python 3.10
Fixes https://github.com/pytest-dev/pytest/issues/8539

This seems to have been the result of https://bugs.python.org/issue43798
2021-04-11 15:42:42 -07:00
Tadeu Manoel b706a2c048
Fix error with --import-mode=importlib and modules containing dataclasses or pickle (#7870)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>

Fixes #7856, fixes #7859
2021-04-05 17:10:03 -03:00
Daniele Procida 843e9eac2c Added myself to AUTHORS 2021-03-12 23:14:18 +00:00
Andreas Motl 9ba1821e91 Fix faulthandler for Twisted Logger when used with "--capture=no"
The Twisted Logger will return an invalid file descriptor since it is
not backed by an FD. So, let's also forward this to the same code path
as with `pytest-xdist`.
2021-01-18 17:51:08 +01:00
bengartner 8e00df4c4b
Add dot prefix if file makefile extension is invalid for pathlib (#8222) 2021-01-04 15:58:11 +02:00
Anton 48c9a96a03
Fix failing staticmethod tests if they are inherited (#8205)
* Fix failing staticmethod tests if they are inherited

* add comments, set default=None
2020-12-30 19:00:37 -08:00
Chris NeJame 534d174fd2
Clarify fixture execution order and provide visual aids (#7381)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-12-16 13:53:14 -03:00
Shubham Adep d1cb9de211
Custom multiple marker execution order (#8065)
* Custom multiple marker execution order

https://github.com/pytest-dev/pytest/issues/8020 issue stated that ordering of multiple custom markers is from inside - out. I have added example for the same in the documentation. Please let me know for further changes / concerns.

* remove trailing spaces

The last commit was failing due to extra spaces

* Ran tox tests locally to debug white space trimming issues

* Resolve: ERROR:   docs: commands failed for tox -e docs

* Update doc/en/reference.rst

Committed PR suggestions.

Co-authored-by: Florian Bruhin <me@the-compiler.org>

* Added reference to Node.iter_markers_with_node in documentation

* Add myself to Authors

Co-authored-by: Shubham <shubham.adep@wsu.edu>
Co-authored-by: Florian Bruhin <me@the-compiler.org>
2020-11-30 16:48:08 +01:00
Prakhar Gurunani 3405c7e6a8
Add more info about skipping doctests (#8080)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-28 12:47:02 -03:00
Dominic Mortlock 775ba63c67
Refactor acceptance_test to use pytester (#8070) 2020-11-25 14:42:47 +02:00
mickeypash ce825ed16c Add small section on migrating from nose to pytest
The section currently features the nose2pytest tool with plans to expand
on some of the common gotchas when performing such migrations.
2020-11-19 08:50:11 -03:00
Petter Strandmark eda681af2b
Call Python 3.8 doClassCleanups (#8033) 2020-11-19 12:07:15 +02:00
Garvit Shubham 6a5037a25b
#7942 test_setupplan.py migrate from testdir to Pytester (#8004)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-11-07 09:29:45 -03:00
duthades b815f430e5 #7942 test_session.py migrate from testdir to pytester
- Add name to AUTHORS
2020-11-04 21:55:07 +05:30
Ran Benita 7fb0ea3f68
Merge pull request #7956 from csernazs/fix-7951
Fix handling recursive symlinks
2020-10-31 18:59:50 +02:00
Cserna Zsolt 8a38e7a6e8 Fix handling recursive symlinks
When pytest was run on a directory containing a recursive symlink it failed
with ELOOP as the library was not able to determine the type of the
direntry:

src/_pytest/main.py:685: in collect
    if not direntry.is_file():
E   OSError: [Errno 40] Too many levels of symbolic links: '/home/florian/proj/pytest/tests/recursive'

This is fixed by handling ELOOP and other errors in the visit function in
pathlib.py, so the entries whose is_file() call raises an OSError with the
pre-defined list of error numbers will be exluded from the result.

The _ignore_errors function was copied from Lib/pathlib.py of cpython 3.9.

Fixes #7951
2020-10-31 17:40:56 +01:00
Ran Benita 1c18fb8ccc
Merge pull request #7553 from tirkarthi/namedtuple-diff
Add support to display field names in namedtuple diffs.
2020-10-31 15:02:31 +02:00
Karthikeyan Singaravelan 9a0f4e57ee Add support to display field names in namedtuple diffs. 2020-10-31 14:41:53 +02:00
Ariel Pillemer a7e38c5c61
pytest-dev#7942 test_runner_xunit.py (#7964) 2020-10-31 12:38:11 +02:00
Christine M 8d369f73ba
Migrate test_skipping.py from testdir to pytester (#7953) 2020-10-28 17:05:54 +02:00
Prashant Sharma 5182c73fea
Add example for registering multiple custom mark (#7886) 2020-10-14 15:17:50 +03:00
Tanvi Mehta d093931464 Added name to authors list 2020-10-07 22:57:52 -07:00
Jakob van Santen 91fa11bed0
python_api: let approx() take nonnumeric values (#7710)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-09-28 12:17:23 -03:00
Kamran Ahmad d3f47bf346
Improved 'Declaring new hooks' section in docs. (#7782)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-09-23 11:15:55 -03:00
Debi Mishra 25b56e9c69 docs: Add a note about -q option used in getting started guide 2020-07-20 01:28:11 +05:30
Lewis Cowles 71ab6236a1
Clearer guidance on pytest.raise(match=...) failure (#7499) 2020-07-15 22:26:47 +03:00
Vlad-Radz 678c1a0745
assertion: improve diff output of recursive dataclass/attrs
Co-authored-by: Vlad <uladzislau.radziuk@nordcloud.com>
2020-07-08 19:04:56 +03:00
Ram Rachum dd446bee5e Fix exception causes all over the codebase 2020-06-19 22:02:24 +03:00
piotrhm bde0ebcda9 Replace cleanup_numbered_dir with atexit.register 2020-06-09 11:17:31 -03:00
Bruno Oliveira fcbaab8b0b
Allow tests to override "global" `log_level` (rebased) (#7340)
Co-authored-by: Ruaridh Williamson <ruaridh.williamson@flexciton.com>
2020-06-08 22:05:46 -03:00
Prashant Anand e78207c936
7119: data loss with mistyped --basetemp (#7170)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-08 21:54:22 -03:00
Ronny Pfannschmidt 8faf1e8eca
Merge pull request #7286 from gnikonorov/issue_6856
Output a warning to stderr when an invalid key is read from an INI config file
2020-06-02 15:47:02 +02:00
Tor Colvin fe64093411
Fix removal of very long paths on Windows (#6755)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-02 08:56:33 -03:00
Gleb Nikonorov 9ae94b08e2 Add documentation 2020-05-31 11:58:39 -04:00
Anthony Sottile c594bbbd19
Merge pull request #7240 from DahlitzFlorian/fix-issue-7233
Add note about --strict and --strict-markers to references
2020-05-23 12:31:27 -07:00
Claire Cecil 79701c65ed
Added support for less verbose version information (#7169) 2020-05-23 11:27:58 -03:00