Ran Benita
74b9f46e40
Merge pull request #9401 from bluetech/doc-hooks-ref
...
doc: add a `hook` crossref type
(cherry picked from commit 8040cfd965
)
2021-12-12 18:05:19 +02:00
Bruno Oliveira
a335ade1f5
Rename pathlib hook parameters ( #9363 )
...
* Rename pytest_ignore_collect fspath parameter to collection_path
* Rename pytest_collect_file fspath parameter to file_path
* Rename pytest_pycollect_makemodule fspath parameter to module_path
* Rename pytest_report_header startpath parameter to start_path
* Rename pytest_report_collectionfinish startpath parameter to start_path
* Update docs with the renamed parameters
* Use pytest-flakes fork temporarily to prove it works
* Use pytest-flakes 4.0.5
2021-12-03 13:14:09 +01:00
Ran Benita
b0aa870b11
Export CollectReport and TestReport
...
Refs #7469 .
2021-11-02 20:58:51 +02:00
Ran Benita
755ce9bc80
hookspec: improve legacy path deprecation docs
2021-10-23 22:49:54 +03:00
Simon K
bacc8498e9
`pytest_assertion_pass` is no longer considered `experimental` ( #8967 )
...
* `pytest_assertion_pass` is no longer considered `experimental`
* adding changelog
2021-08-03 14:31:18 +01:00
Simon K
c27db3bd8e
Deprecate pytest_cmdline_preparse
...
Close #8592
PR #8956
2021-07-31 10:53:43 -03:00
Ran Benita
1ba5b48565
Merge pull request #8697 from bluetech/expose-config
...
config: expose Config and PytestPluginManager for typing purposes
2021-05-26 11:20:42 +03:00
Ran Benita
c0d525e44c
config: expose PytestPluginManager for typing purposes
...
This type is used in hooks and transitively through `Config`.
2021-05-24 12:27:07 +03:00
Ran Benita
88d84a5791
config: expose Config for typing purposes
...
This type is used in hooks and fixtures.
The constructor is publicly documented so is not marked private.
2021-05-24 12:26:22 +03:00
Ran Benita
538b5c2499
argparsing: export Parser and OptionGroup for typing purposes
...
`Parser` is used by many plugins and custom hooks. `OptionGroup` is
exposed by the `parser.addgroup` API.
The constructors of both are marked private, they are not meant to be
constructed directly.
2021-05-24 00:52:03 +03:00
symonk
42ece0ca81
remove conftest note on pytest_cmdline_main, the hook is invoked
2021-03-21 20:06:18 +00: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
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
pre-commit-ci[bot]
ee03e31831
[pre-commit.ci] pre-commit autoupdate ( #8201 )
...
* [pre-commit.ci] pre-commit autoupdate
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* manual fixes after configuration update
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anthony Sottile <asottile@umich.edu>
2020-12-30 11:56:09 +02:00
Ran Benita
592b32bd69
hookspec: add pathlib.Path alternatives to py.path.local parameters in hooks
...
As part of the ongoing migration for py.path to pathlib, make sure all
hooks which take a py.path.local also take an equivalent pathlib.Path.
2020-12-15 00:34:23 +02:00
Pedro Algarvio
b16c091253
Add `pytest_markeval_namespace` hook.
...
Add a new hook , `pytest_markeval_namespace` which should return a dictionary.
This dictionary will be used to augment the "global" variables available to evaluate skipif/xfail/xpass markers.
Pseudo example
``conftest.py``:
.. code-block:: python
def pytest_markeval_namespace():
return {"color": "red"}
``test_func.py``:
.. code-block:: python
@pytest.mark.skipif("color == 'blue'", reason="Color is not red")
def test_func():
assert False
2020-12-12 17:41:37 +02:00
symonk
751575fa97
make some hookspec docstrings technically correct
2020-10-24 10:59:25 +01:00
Anthony Sottile
a238d1f37d
py36+: remove TYPE_CHECKING from _pytest.compat
...
automated with:
```bash
git grep -l 'from .* import TYPE_CHECKING' |
xargs reorder-python-imports \
--application-directories .:src \
--remove-import 'from _pytest.compat import TYPE_CHECKING' \
--add-import 'from typing import TYPE_CHECKING'
```
2020-10-02 15:03:24 -07:00
Ran Benita
0ca2327069
doc: prefer to reference by public name when possible
...
When a name is exported from `pytest`, prefer to refer to it by that
rather than its `_pytest` import path. It is shorter and more
appropriate in user-facing documentation (although that's not really
visible).
Our plan is to expose more names for typing purposes, in which can this
could be more comprehensive.
2020-09-04 20:46:15 +03:00
Ran Benita
57aca11d4a
hookspec: type annotate parent argument to pytest_collect_file
2020-08-24 18:15:11 +03:00
Ran Benita
1dad5c6433
Merge pull request #7669 from bluetech/collection-doc
...
hookspec: improve collection phase documentation a bit
2020-08-24 14:57:37 +03:00
Ran Benita
172b6e15c5
hookspec: improve collection phase documentation a bit
...
Make it a bit more accurate and use the same format that
pytest_runtest_protocol uses.
2020-08-24 13:00:09 +03:00
Maximilian Cosmo Sitter
75af2bfa06
Reintroduce warnings postponed in 6.0 ( #7637 )
2020-08-22 11:17:50 -03:00
Bruno Oliveira
52b0cc4f19
Remove broken pytest_collect_directory hook
2020-08-19 08:14:25 -03:00
Ran Benita
be656dd4e4
typing: set disallow_any_generics
...
This prevents referring to a generic type without filling in its generic
type parameters.
The FixtureDef typing might need some more refining in the future.
2020-08-01 20:39:15 +03:00
Ran Benita
0242de4f56
Format docstrings in a consistent style
2020-08-01 17:14:37 +03:00
Bruno Oliveira
7ec6401ffa
Change pytest deprecation warnings into errors for 6.0 release ( #7362 )
...
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2020-07-22 21:36:51 -03:00
Ran Benita
168d9adefc
hookspec: change Node -> Union[Item, Collector] to avoid exposing Node
...
We don't really want `Node` itself as a public API, only its two
subclasses.
2020-07-10 13:08:56 +03:00
Ran Benita
f382a6bb20
hookspec: remove unused hookspec pytest_doctest_prepare_content()
...
It's been unused for 10 years at lest from bb50ec89a9
.
2020-06-25 17:44:56 +03:00
Ran Benita
256a5d8b14
hookspec: improve typing of some remaining hooks
2020-06-25 17:33:21 +03:00
Ran Benita
4655b79985
config: improve typing
2020-06-22 16:39:14 +03:00
Ran Benita
da1124eb98
hookspec: improve runtest hooks documentation
2020-06-14 17:31:38 +03:00
Ran Benita
314d00968a
hookspec: type annotate pytest_runtest_log{start,finish}
2020-06-14 12:51:06 +03:00
Ran Benita
bb7b3af9b9
hookspec: fix return type annotation of pytest_runtest_makereport
2020-06-13 22:30:00 +03:00
Ran Benita
0256cb3aae
hookspec: type annotate pytest_internalerror
...
Also switch to using ExceptionRepr instead of
`Union[ReprExceptionInfo, ExceptionChainRepr]`
which is somewhat annoying and less future proof.
2020-06-12 17:34:31 +03:00
Ran Benita
7081ed19b8
hookspec: type annotate pytest_keyboard_interrupt
2020-06-12 17:34:31 +03:00
Ran Benita
f8bb61ae5b
Type annotate _pytest.warnings
2020-06-05 11:34:20 +03:00
Ran Benita
01797e6370
Type annotate _pytest.debugging (a bit)
2020-06-05 11:34:20 +03:00
Ran Benita
90e58f8961
Type annotate some parts related to runner & reports
2020-06-05 11:34:20 +03:00
Ran Benita
e68a26199c
Type annotate misc functions
2020-06-05 11:34:19 +03:00
Ran Benita
247c4c0482
Type annotate some more hooks & impls
2020-06-05 11:34:19 +03:00
Ran Benita
ef34729541
Type annotate fixtures.py & related
2020-06-05 11:34:19 +03:00
Ran Benita
be00e12d47
Type annotate main.py and some parts related to collection
2020-06-05 11:34:19 +03:00
Ran Benita
0fb081aec6
Type annotate some hookspecs & impls
...
Annotate some "easy" arguments of hooks that repeat in a lot of internal
plugins.
Not all of the arguments are annotated fully for now.
2020-06-05 11:34:19 +03:00
Ran Benita
85b5a289f0
warnings: fix missing None in existing hook & add some docs ( #7288 )
2020-06-02 19:59:25 +03:00
Gleb Nikonorov
14de08011b
fix the unit tests, add the proper deprecation warning, and add in a changelog entry
2020-05-27 23:03:07 -04:00
Gleb Nikonorov
d742b386c3
provide missing location parameter, and add type annotations to the hookspec
2020-05-27 00:53:31 -04:00
Gleb Nikonorov
125b663f20
Address all feedback, minus the empty sring v None nodeid which is being discussed
2020-05-25 11:18:24 -04:00
Gleb Nikonorov
088d400b2d
rename pytest_warning_record -> pytest_warning_recorded
2020-05-24 20:43:23 -04:00
Gleb Nikonorov
9ee6550181
Add in a new hook pytest_warning_recorded for warning capture
...
communication
2020-05-24 19:05:24 -04:00