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
Ran Benita
85732e2b08
Merge pull request #6993 from blueyed/doc-pytest_collection-upstream
...
[WIP] doc: pytest_collection: has to set `session.items`
2020-05-05 21:05:56 +03:00
Daniel Hahler
a98a62723e
revisit
2020-04-09 01:57:46 +02:00
Daniel Hahler
1fd14685c5
doc: document inversed lines with terminal report hooks ( #7016 )
...
It was surprising that `tryfirst=True` would not result in lines being
added to the beginning with `pytest_report_header`.
This is due to lines being reversed, and therefore the same applies to
`pytest_report_collectionfinish`.
2020-04-07 08:08:28 +02:00
Ran Benita
1ce30fd38f
Document the pytest_report_teststatus hook better and test uncovered functionality
...
This hook has some functionality to provide explicit markup for the test
status. It seemed unused and wasn't tested, so I was tempted to remove
it, but I found that the pytest-rerunfailures plugin uses it, so
document it and add a test instead.
2020-04-04 17:27:59 +03:00
Daniel Hahler
354602abe6
Update src/_pytest/hookspec.py
...
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2020-04-02 12:01:43 +02:00
Daniel Hahler
607f7603af
doc: pytest_collection: has to set `session.items`
...
Would make sense to use its return value etc, but this helps for now.
2020-03-31 09:39:50 +02:00
Ronny Pfannschmidt
9fd71d6fe0
fix #571 : deprecate pytest_collect_directory as ... ( #6847 )
...
Deprecate pytest_collect_directory
Fix #571
Co-authored-by: Daniel Hahler <github@thequod.de>
2020-03-03 18:58:14 -03:00
Ran Benita
d839686c7b
Don't delete FixtureDef.cached_result, set it to None instead
...
Previously `cached_result` was either set or deleted. Type annotations
cannot handle this, so use `None` for the non-set state instead.
2020-02-14 14:18:58 +02:00
Bruno Oliveira
39b25ddcf3
Remove deprecated 'pytest_itemstart' hook ( #6637 )
...
Remove deprecated 'pytest_itemstart' hook
2020-01-31 16:12:27 -03:00
Ran Benita
a435faad5c
Merge branch 'master' into master-to-features
2020-01-31 11:27:06 +02:00
Bruno Oliveira
70739296e1
Remove deprecated 'pytest_itemstart' hook
...
This hook has been deprecated/removed for more than 10 years
in a2fe6714f8
.
2020-01-30 21:03:29 -03:00
Daniel Hahler
88b800355a
typing: pytest_collection
2020-01-30 19:58:43 +01:00
Philipp Loose
a02310a140
Add stacklevel tests for warnings, 'location' to pytest_warning_captured
...
Resolves #4445 and #5928 (thanks to allanlewis)
Add CHANGELOG for location parameter
2019-11-22 17:50:00 -03:00
Daniel Hahler
55bc084dcc
doc: s/_pytest.config.Parser/_pytest.config.argparsing.Parser/
2019-11-13 23:22:25 +01:00
Bruno Oliveira
74f4ec5986
Making it possible to access the pluginmanager in the pytest_ad… ( #6106 )
...
Making it possible to access the pluginmanager in the pytest_addoptio…
2019-11-06 15:18:59 -03:00