Commit Graph

2200 Commits

Author SHA1 Message Date
Ronny Pfannschmidt e787d2ed48
Merge pull request #11317 from tjsmart/fix-issue-11237
Fix doctest collection of `functools.cached_property` objects.
2023-09-07 14:39:02 +02:00
Stefaan Lippens 3ce63bc768
Improve plugin list disclaimer (#11397)
Closes #11391
2023-09-06 07:34:38 -03:00
Bruno Oliveira 194a782e38
Fix import_path for packages (#11390)
For packages, `import_path` receives the path to the package's `__init__.py` file, however module names (as they live in `sys.modules`) should not include the `__init__` part.

For example, `app/core/__init__.py` should be imported as `app.core`, not as `app.core.__init__`.

Fix #11306
2023-09-05 19:42:40 -03:00
Israel Fruchter 917ce9aa01
Fix user_properties not saved to XML if fixture errors during teardown
Move handling of user_properties to `finalize()`.

Previously if a fixture failed during teardown, `pytest_runtest_logreport` would not be called with "teardown", resulting in the user properties not being saved on the JUnit XML file.

Fixes: #11367
2023-09-03 14:33:54 -03:00
Bruno Oliveira f08782d8d0 Merge pull request #11377 from pytest-dev/release-7.4.1
Prepare release 7.4.1

(cherry picked from commit 82eb86f707cac79f33d0ff69723ccf1cea7e75f7)
2023-09-02 12:45:58 -03:00
Ran Benita 77f7f59b2a Fixes for typed pluggy
Since version 1.3 pluggy added typing, which requires some fixes to
please mypy.
2023-08-26 22:13:24 +03:00
Jon Parise 7500fe44b2
Correct the spelling of ArgSource.INVOCATION_DIR (#11333)
Config.ArgsSource.INCOVATION_DIR remains as a backwards compatibility
alias.
2023-08-23 09:21:17 +00:00
Zac Hatfield-Dodds 050f402816
Merge pull request #11308 from reaganjlee/iter-reporting
Improve reporting from __iter__ exceptions
2023-08-21 16:27:42 -07:00
Reagan Lee 61133ba83d un-iterable fix 2023-08-20 14:46:09 -07:00
Reagan Lee 049eec8474 Revert iter raises checks
This reverts commit e938580257.

Revert "improve error msg and test"

This reverts commit c0cf822ca1.

Revert "error msg"

This reverts commit ec1053cc16.

Revert "changelog"

This reverts commit d2dc8a70b5.

Revert "simplify code / take out user-gen typeerror case"

This reverts commit b9cb87d862.
2023-08-20 14:06:42 -07:00
Tyler Smart d4fb6ac9f7 Fix doctest collection of `functools.cached_property` objects. 2023-08-16 00:55:16 -06:00
Ran Benita 9e164fc4fe fixtures: make FixtureRequest abstract, add TopRequest subclass
Fix #11218.
2023-08-12 11:55:08 +03:00
Reagan Lee d2dc8a70b5 changelog 2023-08-11 09:48:53 -07:00
Sadra Barikbin e8a8a5f320
python: fix scope assignment for indirect parameter sets (#11277)
Previously, when assigning a scope for a fully-indirect parameter set,
when there are multiple fixturedefs for a param (i.e. same-name fixture
chain), the highest scope was used, but it should be the lowest scope,
since that's the effective scope of the fixture.
2023-08-06 13:59:54 +00:00
Ran Benita a21fb87a90 python: change `Package` to no longer be a `Module`/`File`
Fix #11137.
2023-07-28 22:49:24 +03:00
Ran Benita 71e627aa8f fixtures: fix crash when `parametrize(scope="package")` is used without a Package
There as handling for `scope="class"` without a class, but not for
`scope="package"` without a package. It would fail the assert.
2023-07-28 16:13:02 +03:00
Isaac Virshup 1de0923e83
Have pytest.raises match against exception `__notes__` (#11227)
The doctest is skipped because add_note is only available in 3.11,

Closes #11223
2023-07-18 08:39:39 -03:00
Ran Benita c5262b0c42 fixtures: show test as skip location if skipped from an xunit setup function
Fix #11216.
2023-07-16 23:26:04 +03:00
Ran Benita 32f480814c
Merge pull request #11209 from bluetech/fixtures-doc-comments
fixtures: some tweaks & improvements
2023-07-15 19:40:48 +03:00
Ran Benita fb55615d5e Export `FixtureDef`
FixtureDef is used in the `pytest_fixture_setup` hook so needs to be
public. However since its current internals are quite dubious (and not
all marked with `_` prefix) I've added an explicit note that only
documented fields/methods are considered public.

Refs #7469.
2023-07-15 10:06:06 +03:00
Ran Benita 9d0ddb4625 fixtures: change `FixtureDef.cached_result[2]` from exception triplet to exception
Fix #11208.
2023-07-15 10:06:06 +03:00
Ran Benita b41acaea12 Switch to new-style pluggy hook wrappers
Fix #11122.
2023-07-14 22:47:48 +03:00
Kenny Y c5b13099e6
Fix error assertion handling in approx when None in dict comparison
Dict comparsion in the ApproxMapping class did not check if values were None before attempting to subtract for max_abs_diff stat, which was throwing an TypeError instead of being handled by pytest error assertion. Check for None has been added before these calculations, so that None will properly show as Obtained/Expected in pytest assert message
2023-07-07 14:42:59 -04:00
Zac Hatfield-Dodds 084d756ae6
Merge pull request #11143 from tushar-deepsource/patch-1 2023-07-04 10:47:13 -07:00
Zac Hatfield-Dodds cb732f7f49
Merge branch 'main' into patch-1 2023-07-04 10:17:06 -07:00
Milan Lesnek 6badb6f01e Apply suggestions from code review
chore(changelog): describe better the fix

Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
2023-07-04 10:30:19 +02:00
Lesnek 4517af1e28 test(warnings-recorder): Add attribute error test 2023-07-04 10:30:19 +02:00
Akhilesh Ramakrishnan 024e62e6d2
Added Akhilesh Ramakrishnan to AUTHORS (#11153)
* Added Akhilesh Ramakrishnan to AUTHORS

PR#10338

* Fix typo in changelog
2023-07-03 13:49:50 +02:00
Ronny Pfannschmidt 561f1a993b fix #10447 - consider marks in reverse mro order to give base classes priority 2023-07-01 22:27:18 +02:00
Bruno Oliveira b77d0deaf5
Fix duplicated imports with importlib mode and doctest-modules (#11148)
The initial implementation (in #7246) introduced the `importlib` mode, which
never added the imported module to `sys.modules`, so it included a test
to ensure calling `import_path` twice would yield different modules.

Not adding modules to `sys.modules` proved problematic, so we began to add the imported module to `sys.modules`
in #7870, but failed to realize that given we are now changing `sys.modules`, we might
as well avoid importing it more than once.

Then #10088 came along, passing `importlib` also when importing application modules
(as opposed to only test modules before), which caused problems due to imports
having side-effects and the expectation being that they are imported only once.

With this PR, `import_path` returns the module immediately if already in
`sys.modules`.

Fix #10811
Fix #10341
2023-07-01 15:37:46 +00:00
akhilramkee 2f7415cfbc
Add child modules as attributes of parent modules. (#10338)
Failing to add child modules as attributes of parent module will prevent them from being accessible through parent module.

Fix #10337
2023-07-01 15:12:41 +00:00
Cheukting 15524f34d2 capture warning when exception is raised (fix #9036) 2023-06-30 16:04:37 -07:00
Zac Hatfield-Dodds 2d48171e88 Tweak docs on review 2023-06-30 15:29:03 -07:00
Reagan Lee 9279ea2882 Emit unmatched warnings from pytest.warns() 2023-06-30 15:29:02 -07:00
Zac Hatfield-Dodds 0311fc3384
Apply suggestions from code review
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2023-06-30 20:18:25 -07:00
Zac Hatfield-Dodds f4e3b4ad98 Drop Python 3.7 2023-06-30 14:55:42 -07:00
Ran Benita 81cfb3fc87
Merge pull request #11017 from erik-hasse/caplog-root-logger-docs
add a warning about modifying the root logger during tests
2023-06-28 09:28:46 +03:00
pre-commit-ci[bot] 4719d998d8 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2023-06-26 11:34:03 +00:00
Tushar Sadhwani 5332656906
Add changelog and author 2023-06-26 17:02:33 +05:30
Thomas Grainger 4cd95eeabf
Merge branch 'main' into warn-when-a-mark-is-applied-to-a-fixture 2023-06-25 16:08:11 +01:00
Ran Benita c8b1790ee7 python: change `pytest pkg/__init__.py` to only collect the `__init__.py` Module
Previously it would collect the entire package, but this is not what
users expect.

Refs #3749
Fixes #8976
Fixes #9263
Fixes #9313
2023-06-23 20:42:50 +03:00
Ran Benita a4a189ad99 Change PytestRemovedIn8Warning to error by default
Per our backward compatibility policy.
2023-06-23 16:42:24 +03:00
Ran Benita a14745550a Merge pull request #11131 from pytest-dev/release-7.4.0
Prepare release 7.4.0

(cherry picked from commit fb03d1388b002f63973c663cb4929908a2ca81f5)
2023-06-23 14:19:51 +03:00
Zac Hatfield-Dodds f6b995e9d5 Use utf-8 debug file 2023-06-20 04:55:40 -07:00
Ran Benita 14890329dc config: fix the paths considered for initial conftest discovery
Fixes #11104.

See the issue for a description of the problem.

Now, we use the same logic for initial conftest paths as we do for
deciding the initial args, which was the idea behind checking
`namespace.file_or_dir` and `testpaths` previously.

This fixes the issue of `testpaths` being considered for initial
conftests even when it's not used for the args.

(Another issue in faeb16146b was that the
`testpaths` were not glob-expanded, this is also fixed.)
2023-06-21 09:01:42 +03:00
Zac Hatfield-Dodds b5ec092525
Merge pull request #9149 from Vijay-Arora/main 2023-06-19 20:35:01 -07:00
Ran Benita ecb23106d8
Merge pull request #11097 from bluetech/cherry-pick-release
Cherry-pick 7.3.2 release notes
2023-06-10 22:57:31 +03:00
Ran Benita 8174a30164
changelog: add note to `norecursedir`/`pytest_ignore_collect` change (#11095) 2023-06-10 19:34:59 +00:00
Ran Benita 0142bb6687 Merge pull request #11096 from pytest-dev/release-7.3.2
Prepare release 7.3.2

(cherry picked from commit 5dcd2be4661bc606b3399bff3614c0691ce9c13f)
2023-06-10 22:31:49 +03:00
Ran Benita 7d5207a736 Declare support for Python 3.12 2023-06-07 17:05:52 +03:00