summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2021-02-25change istestfunction to callable() (#8374)Simon K
2021-02-25Fixed an issue where `getpass.getuser()` contained illegal characters for ↵Simon K
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
2021-02-23Allow Class.from_parent to forward custom parameters to the constructorFlorian Bruhin
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.
2021-02-08Merge pull request #8323 from bluetech/setupstate-refactor-3Ran Benita
runner: a few more tweaks to SetupState
2021-02-07Merge pull request #8248 from RonnyPfannschmidt/mixin-mro-positionRonny Pfannschmidt
alter the PyObjMixin to carry over typing information from Node
2021-02-06runner: add clarifying comments on why runtestprotocol re-inits the ↵Ran Benita
FixtureRequest
2021-02-06runner: rename SetupState.prepare -> setupRan Benita
This is the usual terminology we use, and matches better with `teardown_exact()` and `pytest_runtest_setup()`.
2021-02-06runner: add a safety assert to SetupState.prepareRan Benita
This ensures that the teardown for the previous item was done properly for this (next) item, i.e. there are no leftover teardowns.
2021-02-05Type annotation for request.param (#8319)Pax
2021-02-05Merge pull request #8315 from bluetech/parser-proper-deprecationRan Benita
config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
2021-02-05config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarningRan Benita
Proper for removing this in the next major pytest release.
2021-02-04Type annotation polishing for symbols around Pytester.run (#8298)Hong Xu
* 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
2021-01-29Remove some no longer needed type-ignoresRan Benita
2021-01-29Doc: Clarify pytester.run (#8294)Hong Xu
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-01-28Merge pull request #8260 from nicoddemus/faulthandler-mode-X-8258Bruno Oliveira
2021-01-25Remove mypy workaround after 0.800 updateBruno Oliveira
2021-01-25Only re-enable fauthandler during unconfigure if it was enabled beforeBruno Oliveira
2021-01-24runner: avoid using node's store in SetupStateRan Benita
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-24runner: add docstring to SetupState and improve variable naming a bitRan Benita
2021-01-24runner: schedule node.teardown() call already at setupRan Benita
This is more elegant.
2021-01-24runner: use insertion-ordered dict instead of stack, dict pairRan Benita
Since dicts are now ordered, we can use the finalizers dict itself as the dict, simplifying the code.
2021-01-24runner: replace setdefault with an unconditional setRan Benita
The already-exists case is not supposed to happen.
2021-01-24runner: enable a commented assertion in SetupState.addfinalizerRan Benita
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-24fixtures: make sure to properly setup stack for _fill_fixtures_implRan Benita
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-24runner: collapse exception handling in SetupState.teardown_exact()Ran Benita
This is equivalent but simpler.
2021-01-24runner: ensure item.teardown() is called even if a finalizer raisedRan Benita
If one finalizer fails, all of the subsequent finalizers still run, so the `teardown()` method should behave the same.
2021-01-24runner: make sure SetupState._finalizers is always set for a node in the stackRan Benita
This makes the stack <-> _finalizers correspondence clearer.
2021-01-24runner: inline SetupState._pop_and_teardown()Ran Benita
This will enable a simplification in the next commit.
2021-01-24runner: express SetupState.teardown_all() in terms of teardown_exact() and ↵Ran Benita
remove it Makes it easier to understand with fewer methods.
2021-01-24runner: inline a couple of SetupState methodsRan Benita
Code is clearer this way.
2021-01-24runner: remove dead code in teardown_all()Ran Benita
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-24runner: inline SetupState._teardown_towards()Ran Benita
Doesn't add much.
2021-01-24runner: reorder SetupState method to make more senseRan Benita
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-24runner: use node's Store to keep private SetupState state instead of an ↵Ran Benita
attribute This way it gets proper typing and decoupling.
2021-01-24runner: complete type annotations of SetupStateRan Benita
2021-01-21Explain how to create binary files in the doc of `pytest.makefile`. (#8255)Hong Xu
2021-01-20Always handle faulthandler stderr even if already enabledBruno Oliveira
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-20Merge pull request #8250 from daq-tools/fix-twisted-captureBruno Oliveira
2021-01-18Fix faulthandler for Twisted Logger when used with "--capture=no"Andreas Motl
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-18Merge pull request #8242 from bluetech/deprecate-unittest-skip-collectionRan Benita
Deprecate raising unittest.SkipTest to skip tests during collection
2021-01-17alter the PyObjMixin to carry over typing information from NodeRonny Pfannschmidt
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-15Deprecate raising unittest.SkipTest to skip tests during collectionRan Benita
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-14Improve way in which skip location is fixed up when skipped by markRan Benita
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-14nose: type annotate with some resulting refactoringRan Benita
2021-01-14unittest: add clarifying comment on unittest.SkipTest -> pytest.skip codeRan Benita
I was tempted to remove it, until I figured out why it was there.
2021-01-14nose,fixtures: use the public item API for adding finalizersRan Benita
2021-01-13unittest: cleanup unexpected success handling (#8231)Anton
* unittest: cleanup unexpected success handling * update comment
2021-01-04Merge pull request #8218 from bluetech/reports2Ran Benita
Misc small code improvements
2021-01-04Add dot prefix if file makefile extension is invalid for pathlib (#8222)bengartner
2021-01-01python: inline a simple methodRan Benita
I don't think it adds much value!