Commit Graph

484 Commits

Author SHA1 Message Date
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
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