Commit Graph

13506 Commits

Author SHA1 Message Date
Bruno Oliveira dfe933cdb4 Remove mypy workaround after 0.800 update 2021-01-25 15:23:13 -03:00
pre-commit-ci[bot] 6806091b93
[pre-commit.ci] pre-commit autoupdate 2021-01-25 16:41:17 +00:00
Bruno Oliveira 33861098d9 Only re-enable fauthandler during unconfigure if it was enabled before 2021-01-25 12:28:00 -03:00
Christian Steinmeyer 781b73bb52
Mention that class variables are shared between tests
Close #8252
2021-01-25 12:02:59 -03:00
Bruno Oliveira f3efc4e049
Merge pull request #8277 from nicoddemus/cherry-pick-release
Merge pull request #8275 from pytest-dev/release-6.2.2
2021-01-25 12:02:49 -03:00
Bruno Oliveira 2a890286f8 Merge pull request #8275 from pytest-dev/release-6.2.2
Prepare release 6.2.2

(cherry picked from commit 8220eca963472e7918ef7e108bdc1cd8ed155a4a)
2021-01-25 11:53:05 -03:00
Ran Benita fff9f28fdd
Merge pull request #8272 from bluetech/setupstate-refactor-2
runner: avoid using node's store in SetupState
2021-01-25 16:00:05 +02:00
Bruno Oliveira 5cc295e74b
Merge pull request #8273 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-cov-2.11.1
build(deps): bump pytest-cov from 2.10.1 to 2.11.1 in /testing/plugins_integration
2021-01-25 09:12:14 -03:00
dependabot[bot] 83ee1a1f3b
build(deps): bump pytest-cov in /testing/plugins_integration
Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 2.10.1 to 2.11.1.
- [Release notes](https://github.com/pytest-dev/pytest-cov/releases)
- [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-cov/compare/v2.10.1...v2.11.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-25 03:16:50 +00:00
Ran Benita 48fb989a71 runner: avoid using node's store in SetupState
SetupState maintains its own state, so it can store the exception
itself, instead of using the node's store, which is better avoided when
possible.

This also reduces the lifetime of the reference-cycle-inducing exception
objects which is never a bad thing.
2021-01-24 15:05:03 +02:00
Ran Benita d5df8f99ab
Merge pull request #8219 from bluetech/setupstate-refactor
runner: refactor SetupState
2021-01-24 14:51:58 +02:00
Ran Benita c30feeef8b runner: add docstring to SetupState and improve variable naming a bit 2021-01-24 14:29:54 +02:00
Ran Benita 0d19aff562 runner: schedule node.teardown() call already at setup
This is more elegant.
2021-01-24 14:08:39 +02:00
Ran Benita 1db78bec31 runner: use insertion-ordered dict instead of stack, dict pair
Since dicts are now ordered, we can use the finalizers dict itself as
the dict, simplifying the code.
2021-01-24 14:08:39 +02:00
Ran Benita 03c3a90c68 runner: replace setdefault with an unconditional set
The already-exists case is not supposed to happen.
2021-01-24 14:08:39 +02:00
Ran Benita 960ebae943 runner: enable a commented assertion in SetupState.addfinalizer
The assertion ensures that when `addfinalizer(finalizer, node)` is
called, the node is in the stack. This then would ensure that the
finalization is actually properly executed properly during the node's
teardown. Anything else indicates something is wrong.

Previous commits fixed all of the tests which previously failed this, so
can be reenabeld now.
2021-01-24 14:08:39 +02:00
Ran Benita 6db082a448 fixtures: make sure to properly setup stack for _fill_fixtures_impl
This code is weird, dead, deprecated and will be removed in pytest 7,
but for now some tests execute it, so fix it up in preparation for
some changes.
2021-01-24 14:08:39 +02:00
Ran Benita 637300d13d testing: fix some tests to be more realistic
Perform the operations in the order and context in which they can
legally occur.
2021-01-24 14:08:39 +02:00
Ran Benita c83d030028 testing/test_runner: make SetupState tests use a proper SetupState
Previously the tests (probably unintentionally) mixed a fresh SetupState
and the generated item Session's SetupState, which led to some serious
head scratching when prodding it a bit.
2021-01-24 14:08:39 +02:00
Ran Benita 0d4121d24b runner: collapse exception handling in SetupState.teardown_exact()
This is equivalent but simpler.
2021-01-24 14:08:39 +02:00
Ran Benita bb3d43c9a6 runner: ensure item.teardown() is called even if a finalizer raised
If one finalizer fails, all of the subsequent finalizers still run, so
the `teardown()` method should behave the same.
2021-01-24 14:08:39 +02:00
Ran Benita 14d71b2c22 runner: make sure SetupState._finalizers is always set for a node in the stack
This makes the stack <-> _finalizers correspondence clearer.
2021-01-24 14:08:39 +02:00
Ran Benita d1fcd425a3 runner: inline SetupState._pop_and_teardown()
This will enable a simplification in the next commit.
2021-01-24 14:08:39 +02:00
Ran Benita 2b14edb108 runner: express SetupState.teardown_all() in terms of teardown_exact() and remove it
Makes it easier to understand with fewer methods.
2021-01-24 14:08:39 +02:00
Ran Benita ceb4d6f6d5 runner: inline a couple of SetupState methods
Code is clearer this way.
2021-01-24 14:08:39 +02:00
Ran Benita 5f4e55fb6d runner: remove dead code in teardown_all()
When the stack is empty, the finalizers which are supposed to be
attached to nodes in the stack really ought to be empty as well. So the
code here is dead. If this doesn't happen, the assert will trigger.
2021-01-24 14:08:39 +02:00
Ran Benita 42ae8180dd runner: inline SetupState._teardown_towards()
Doesn't add much.
2021-01-24 14:08:39 +02:00
Ran Benita 410622f719 runner: reorder SetupState method to make more sense
The setup stuff happens before the teardown stuff, so put it first so
that reading the code from top to bottom makes more sense.
2021-01-24 14:08:39 +02:00
Ran Benita f7b0b1dd1f runner: use node's Store to keep private SetupState state instead of an attribute
This way it gets proper typing and decoupling.
2021-01-24 14:08:39 +02:00
Ran Benita da70f61f67 runner: complete type annotations of SetupState 2021-01-24 14:08:39 +02:00
Hong Xu d4f8e4b40c
Explain how to create binary files in the doc of `pytest.makefile`. (#8255) 2021-01-21 09:58:52 -03:00
Bruno Oliveira adc0f29b8f Always handle faulthandler stderr even if already enabled
It seems the code that would not install pytest's faulthandler support
if it was already enabled is not really needed at all, and even detrimental
when using `python -X dev -m pytest` to run Python in "dev" mode.

Also simplified the plugin by removing the hook class, now the hooks
will always be active so there's no need to delay the hook definitions anymore.

Fix #8258
2021-01-20 10:29:05 -03:00
Bruno Oliveira bda9ce4e0f
Merge pull request #8250 from daq-tools/fix-twisted-capture 2021-01-20 09:45:58 -03:00
Jeff Widman eef2d1a8e2
Fix pep8 import order in docs (#8253) 2021-01-19 11:45:45 -03: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
Ran Benita 7f782c72ba
Merge pull request #8242 from bluetech/deprecate-unittest-skip-collection
Deprecate raising unittest.SkipTest to skip tests during collection
2021-01-18 17:46:00 +02:00
Ronny Pfannschmidt a9e43152bc alter the PyObjMixin to carry over typing information from Node
as PyObjMixin is always supposed to be mixed in the mro
before nodes.Node the behavior doesn't change,
but all the typing information carry over to help mypy.

extracted from #8037
2021-01-17 14:36:28 +01:00
Ran Benita c9e9a599fe
Merge pull request #8241 from bluetech/skip-improvements
Minor code improvements in nose, unittest, skipping
2021-01-15 15:35:57 +02:00
Ran Benita 25e657bfc1 Deprecate raising unittest.SkipTest to skip tests during collection
It is not very clear why this code exists -- we are not running any
unittest or nose code during collection, and really these frameworks
don't have the concept of collection at all, and just raising these
exceptions at e.g. the module level would cause an error. So unless I'm
missing something, I don't think anyone is using this.

Deprecate it so we can eventually clear up this code and keep unittest
more tightly restricted to its plugin.
2021-01-15 00:05:33 +02:00
Ran Benita 7f989203ed Improve way in which skip location is fixed up when skipped by mark
When `pytest.skip()` is called inside a test function, the skip location
should be reported as the line that made the call, however when
`pytest.skip()` is called by the `pytest.mark.skip` and similar
mechanisms, the location should be reported at the item's location,
because the exact location is some irrelevant internal code.

Currently the item-location case is implemented by the caller setting a
boolean key on the item's store and the `skipping` plugin checking it
and fixing up the location if needed. This is really roundabout IMO and
breaks encapsulation.

Instead, allow the caller to specify directly on the skip exception
whether to use the item's location or not. For now, this is entirely
private.
2021-01-14 18:07:25 +02:00
Ran Benita 3dde519f53 nose: type annotate with some resulting refactoring 2021-01-14 17:42:38 +02:00
Ran Benita 096bae6c68 unittest: add clarifying comment on unittest.SkipTest -> pytest.skip code
I was tempted to remove it, until I figured out why it was there.
2021-01-14 17:06:14 +02:00
Ran Benita addbd3161e nose,fixtures: use the public item API for adding finalizers 2021-01-14 16:53:07 +02:00
Anton 42d5545f42
unittest: cleanup unexpected success handling (#8231)
* unittest: cleanup unexpected success handling

* update comment
2021-01-13 17:02:26 -08:00
Bruno Oliveira 7a5a6cb51c
Merge pull request #8235 from pytest-dev/dependabot/pip/testing/plugins_integration/django-3.1.5
build(deps): bump django from 3.1.4 to 3.1.5 in /testing/plugins_integration
2021-01-11 08:24:47 -03:00
Bruno Oliveira 203a9b3ab2
Merge pull request #8234 from pytest-dev/dependabot/pip/testing/plugins_integration/pytest-mock-3.5.1
build(deps): bump pytest-mock from 3.4.0 to 3.5.1 in /testing/plugins_integration
2021-01-11 08:24:33 -03:00
dependabot[bot] cfa0c3b0d9
build(deps): bump django in /testing/plugins_integration
Bumps [django](https://github.com/django/django) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/django/django/releases)
- [Commits](https://github.com/django/django/compare/3.1.4...3.1.5)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 03:16:03 +00:00
dependabot[bot] af78efc7fa
build(deps): bump pytest-mock in /testing/plugins_integration
Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.4.0 to 3.5.1.
- [Release notes](https://github.com/pytest-dev/pytest-mock/releases)
- [Changelog](https://github.com/pytest-dev/pytest-mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.4.0...v3.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
2021-01-11 03:15:59 +00:00
Ran Benita f6529fd3a1
Merge pull request #8232 from imrehg/doc
Add missing import into example script in documentation
2021-01-08 14:08:47 +02:00
Gergely Imreh 80c33c8178
Add missing import into example script in documentation 2021-01-08 11:43:51 +00:00