Bruno Oliveira
35df3e68d5
Merge pull request #8459 from bluetech/unnecessary-py-path-3
2021-03-18 09:05:45 -03:00
Jürgen Gmach
fb481c7e6f
fix typo ( #8460 )
2021-03-18 12:34:01 +01:00
Ran Benita
4690e4c510
reports: support any PathLike instead of only Path, py.path
...
The goal is to avoid referring to the legacy py.path.
2021-03-18 10:23:48 +02:00
Ran Benita
202dd9f423
pytester: add & use our own copytree instead of py.path's
...
Fixes the TODO note.
2021-03-18 10:23:48 +02:00
Ran Benita
ccdadb64ea
main: add Session.startpath, make Session.startdir a property that can be deprecated
...
Same as in Config.
2021-03-18 10:23:48 +02:00
Ran Benita
6a174afdfe
terminal: move startdir attribute to a property that can be deprecated
...
Same as in Config.
2021-03-18 10:23:48 +02:00
Ran Benita
e515264eb1
Remove yet more unnecessary py.path uses
2021-03-18 10:23:48 +02:00
Ran Benita
fe215bda6b
Merge pull request #8446 from bluetech/unnecessary-py-path-2
...
More py.path removal work
2021-03-18 10:20:59 +02:00
Kale Kundert
dd3709718d
Merge pull request #8453 from encukou/rel-error-message
...
Fix value in error message about negative relative tolerance
2021-03-16 16:43:31 -04:00
Petr Viktorin
1f131afb07
Fix value in error message about negative relative tolerance
2021-03-16 18:54:52 +01:00
Ran Benita
f0c7043138
Remove/replace some more unnecessary uses of py.path
2021-03-15 10:39:44 +02:00
Ran Benita
a03ee02817
config: make `collect_ignore` accept any PathLike
...
The main reason is to remove a reference to `py.path`.
2021-03-15 10:39:32 +02:00
Ran Benita
b26d1bb18f
cacheprovider: add cache.mkdir() as a Path-returning replacement to makedir()
...
It is not possible to change a return type in a compatible way, so a new
method is added.
2021-03-15 10:39:31 +02:00
Ran Benita
59251e8a2a
Remove/replace some unneeded usages of py.path
2021-03-14 14:12:28 +02:00
Ran Benita
db539ed2b0
Merge pull request #8437 from bluetech/rm-typevar-prefix
...
Remove `_` prefix from TypeVars, expose ExceptionInfo
2021-03-13 19:01:29 +02:00
Pierre Mourlanne
af9f27a874
Approx decimal sequence mapping ( #8422 )
2021-03-13 16:01:23 +02:00
Ran Benita
f2d65c85f4
code: export ExceptionInfo for typing purposes
...
This type is most prominent in `pytest.raises` and we should allow to
refer to it by a public name.
The type is not in a perfectly "exposable" state. In particular:
- The `traceback` property with type `Traceback` which is derived from
the `py.code` API and exposes a bunch more types transitively. This
stuff is *not* exported and probably won't be.
- The `getrepr` method which probably should be private.
But they're already used in the wild so no point in just hiding them
now.
The __init__ API is hidden -- the public API for this are the `from_*`
classmethods.
2021-03-13 15:59:44 +02:00
Ran Benita
96ef7d678b
code: fix outdated reference in ExceptionInfo.exconly docstring
...
No such thing as `_pytest._code.AssertionError`, it's just the built-in
`AssertionError`.
2021-03-13 14:44:50 +02:00
Ran Benita
5bbfb4e058
Remove `_` prefix from TypeVars which appear in public API
...
The prefixes make the API Reference docs (for e.g. `pytest.raises`,
`pytest.fixture`) uglier.
Being under `_pytest` is sufficient from a privacy perspective, so let's
drop them.
2021-03-13 14:44:50 +02:00
Ronny Pfannschmidt
77cb110258
drop usage of py.path.local calls
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-03-06 21:32:03 +01:00
Ronny Pfannschmidt
22dad53a24
implement Node.path as pathlib.Path
...
* reorganize lastfailed node sort
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-03-06 21:32:03 +01:00
Alexandros Tzannes
19a2f7425d
Merge pull request #8399 from atzannes/master
...
closes #8394
Generated fixture names for unittest/xunit/nose should start with underscore
2021-03-04 22:45:57 +02:00
Florian Bruhin
c14a9adba3
Fix skip signature ( #8392 )
...
* Fix test_strict_and_skip
The `--strict` argument was removed in #2552 , but the removal wasn't
actually correct - see #1472 .
* Fix argument handling in pytest.mark.skip
See #8384
* Raise from None
* Fix test name
2021-03-04 11:56:21 +01:00
Simon K
22c0dace3b
change istestfunction to callable() ( #8374 )
2021-02-25 20:32:27 +00:00
Simon K
b7f2d7ca61
Fixed an issue where `getpass.getuser()` contained illegal characters for 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-25 08:28:57 +00:00
Florian Bruhin
54a154c86f
Allow Class.from_parent to forward custom parameters to the constructor
...
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-23 18:00:56 +01:00
Ran Benita
1003beaffa
Merge pull request #8323 from bluetech/setupstate-refactor-3
...
runner: a few more tweaks to SetupState
2021-02-08 13:56:04 +02:00
Ronny Pfannschmidt
325d701f6e
Merge pull request #8248 from RonnyPfannschmidt/mixin-mro-position
...
alter the PyObjMixin to carry over typing information from Node
2021-02-07 18:44:44 +01:00
Ran Benita
5822888d73
runner: add clarifying comments on why runtestprotocol re-inits the FixtureRequest
2021-02-06 20:46:08 +02:00
Ran Benita
f42b68ccaa
runner: rename SetupState.prepare -> setup
...
This is the usual terminology we use, and matches better with
`teardown_exact()` and `pytest_runtest_setup()`.
2021-02-06 20:46:08 +02:00
Ran Benita
f674f6da9f
runner: add a safety assert to SetupState.prepare
...
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-06 20:46:08 +02:00
Pax
bcfe253f5b
Type annotation for request.param ( #8319 )
2021-02-05 22:03:58 +02:00
Ran Benita
b3115c1b06
Merge pull request #8315 from bluetech/parser-proper-deprecation
...
config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
2021-02-05 00:37:38 +02:00
Ran Benita
d358a060ad
config/argparsing: use proper deprecations instead of ad-hoc DeprecationWarning
...
Proper for removing this in the next major pytest release.
2021-02-05 00:05:47 +02:00
Hong Xu
80c223474c
Type annotation polishing for symbols around Pytester.run ( #8298 )
...
* 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-02-04 23:44:22 +02:00
Ran Benita
afea190797
Remove some no longer needed type-ignores
2021-01-29 20:40:43 +02:00
Hong Xu
07f0eb26b4
Doc: Clarify pytester.run ( #8294 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2021-01-29 12:54:06 -03:00
Bruno Oliveira
6a5d47a243
Merge pull request #8260 from nicoddemus/faulthandler-mode-X-8258
2021-01-28 13:03:24 -03:00
Bruno Oliveira
dfe933cdb4
Remove mypy workaround after 0.800 update
2021-01-25 15:23:13 -03:00
Bruno Oliveira
33861098d9
Only re-enable fauthandler during unconfigure if it was enabled before
2021-01-25 12:28:00 -03: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
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
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