Age | Commit message (Collapse) | Author |
|
|
|
file directories (#8365)
* retry writing pytest-of dir when invalid chars are in directory name
* add unit tests for getbasetemp() and changelog
* patch _basetemp & _given_basetemp for testing basetemp()
* Tweak changelog for #8317, tidy up comments
|
|
Similarly to #7143, at work we have a project with a custom pytest.Class
subclass, adding an additional argument to the constructor.
All from_parent implementations in pytest accept and forward *kw, except
Class (before this change) and DoctestItem - since I'm not familiar with
doctest support, I've left the latter as-is.
|
|
runner: a few more tweaks to SetupState
|
|
alter the PyObjMixin to carry over typing information from Node
|
|
FixtureRequest
|
|
This is the usual terminology we use, and matches better with
`teardown_exact()` and `pytest_runtest_setup()`.
|
|
This ensures that the teardown for the previous item was done properly
for this (next) item, i.e. there are no leftover teardowns.
|
|
|
|
config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
|
|
Proper for removing this in the next major pytest release.
|
|
* Type annotation polishing for symbols around Pytester.run
Hopefully these will help document readers understand pertinent methods
and constants better.
Following up #8294
* Use NOTSET instead of object
|
|
|
|
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
|
|
|
|
|
|
|
|
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.
|
|
|
|
This is more elegant.
|
|
Since dicts are now ordered, we can use the finalizers dict itself as
the dict, simplifying the code.
|
|
The already-exists case is not supposed to happen.
|
|
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.
|
|
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.
|
|
This is equivalent but simpler.
|
|
If one finalizer fails, all of the subsequent finalizers still run, so
the `teardown()` method should behave the same.
|
|
This makes the stack <-> _finalizers correspondence clearer.
|
|
This will enable a simplification in the next commit.
|
|
remove it
Makes it easier to understand with fewer methods.
|
|
Code is clearer this way.
|
|
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.
|
|
Doesn't add much.
|
|
The setup stuff happens before the teardown stuff, so put it first so
that reading the code from top to bottom makes more sense.
|
|
attribute
This way it gets proper typing and decoupling.
|
|
|
|
|
|
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
|
|
|
|
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`.
|
|
Deprecate raising unittest.SkipTest to skip tests during collection
|
|
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
|
|
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.
|
|
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.
|
|
|
|
I was tempted to remove it, until I figured out why it was there.
|
|
|
|
* unittest: cleanup unexpected success handling
* update comment
|
|
Misc small code improvements
|
|
|
|
I don't think it adds much value!
|