Bruno Oliveira
cb91c5033e
Merge pull request #7697 from nicoddemus/file-docs
...
(cherry picked from commit 21aa6c42b7
)
2020-09-04 21:23:53 +03:00
Ran Benita
a2f021b6f3
Remove no longer needed `noqa: F821` uses
...
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
Ran Benita
04a6d37823
nodes: fix string possibly stored in Node.keywords instead of MarkDecorator
...
This mistake was introduced in 7259c453d6
.
2020-06-22 16:51:11 +03:00
Bruno Oliveira
ab6dacf1d1
Introduce --import-mode=importlib ( #7246 )
...
Fix #5821
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-13 11:29:01 -03:00
Ran Benita
1cf9405075
Fix some type errors around py.path.local
...
These errors are found using a typed version of py.path.local.
2020-06-12 17:34:31 +03:00
Ran Benita
2b05faff0a
Improve types around repr_failure()
2020-06-05 11:34:20 +03:00
Ran Benita
71dfdca4df
Enable check_untyped_defs mypy option for src/
...
This option checks even functions which are not annotated. It's a good
step to ensure that existing type annotation are correct.
In a Pareto fashion, the last few holdouts are always the ugliest,
beware.
2020-06-05 11:34:20 +03:00
Ran Benita
216a010ab7
Type annotate _pytest.junitxml
2020-06-05 11:34:20 +03:00
Ran Benita
fc325bc0c3
Type annotate more of _pytest.nodes
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
43fa1ee8f9
Type annotate some misc places with no particular connection
2020-06-05 11:34:19 +03:00
Bruno Oliveira
757bded135
Use Path() instead of str for path comparison
...
On Windows specifically is common to have drives diverging just by
casing ("C:" vs "c:"), depending on the cwd provided by the user.
2020-05-30 20:05:21 -03:00
Daniel Hahler
fb9f277a99
Node._repr_failure_py: use abspath with changed cwd
...
Fixes https://github.com/pytest-dev/pytest/issues/6428 .
2020-05-30 20:02:47 -03:00
Katarzyna Król
94c7b8b47c
Issue 1316 - longrepr is a string when pytrace=False ( #7100 )
2020-05-30 14:10:58 +03:00
Florian Dahlitz
95bd232e57
Apply suggestions from @bluetech
2020-05-26 10:31:53 +02:00
Florian Dahlitz
5ebcb34fb5
Move ConftestImportFailure check to correct position and add typing
2020-05-25 20:19:28 +02:00
Florian Dahlitz
6546d1f725
Prevent pytest from printing ConftestImportFailure traceback
2020-05-25 13:57:03 +02:00
Ran Benita
8d841ab0b8
nodes: remove unused argument from FSHookProxy
2020-05-22 14:33:28 +03:00
Ran Benita
23c9856857
Remove no longer needed noqa's
2020-05-12 09:29:47 +03:00
Ran Benita
d16ae0bbdc
Merge pull request #7171 from bluetech/code-import-cycles
...
code: fix import cycles between code.py and source.py
2020-05-06 18:15:32 +03:00
Ran Benita
b90f34569f
nodes: micro-optimize Node attribute access
2020-05-06 11:58:30 +03:00
Ran Benita
5702c86f4c
nodes: micro-optimize hash(node)
...
Turns out it's called alot, and saving the function call makes it
faster.
2020-05-06 11:58:30 +03:00
Ran Benita
69143fe5b0
code: fix import cycles between code.py and source.py
...
These two files were really intertwined. Make it so code.py depends on
source.py without a reverse dependency.
No functional changes.
2020-05-06 11:01:32 +03:00
Bruno Oliveira
7f5978c34c
Allow File.from_parent to forward custom parameters to the constructor
2020-05-01 11:00:52 -03:00
Andreas Maier
c9386ada29
Squash: Resolved 2nd round of review comments
2020-04-12 13:19:45 +02:00
Andreas Maier
b2582b0314
Squash: Applied review comments
2020-04-12 12:12:00 +02:00
Andreas Maier
869c089887
Fixes #7077 : Added & improved docs for repr_failure() in Node & Collector
2020-04-12 09:28:40 +02:00
Bruno Oliveira
92767fec51
Merge pull request #6836 from bluetech/store
...
Add a typing-compatible mechanism for ad-hoc attributes on various objects
2020-03-01 09:30:10 -03:00
Daniel Hahler
f10ab021e2
Move _collectfile to FSCollector ( #6830 )
...
Previously this was implemented both on `Session` and `Package`, where
the extra code in `Package._collectfile` was not covered/used.
Ref: https://github.com/pytest-dev/pytest/pull/6830#issuecomment-592663236
2020-02-29 11:40:11 +01:00
Ran Benita
d636fcd557
Add a typing-compatible mechanism for ad-hoc attributes on various objects
...
pytest has several instances where plugins set their own attributes on
objects they receive in hooks, like nodes and config. Since plugins are
detached from these object's definition by design, this causes a problem
for type checking because these attributes are not defined and mypy
complains.
Fix this by giving these objects a "store" which can be used by plugins
in a type-safe manner.
Currently this mechanism is private. We can consider exposing it at a
later point.
2020-02-28 14:34:44 +02:00
Ran Benita
24dcc76495
Use a hack to make typing of pytest.fail.Exception & co work
...
Mypy currently is unable to handle assigning attributes on function:
https://github.com/python/mypy/issues/2087 .
pytest uses this for the outcome exceptions -- `pytest.fail.Exception`,
`pytest.exit.Exception` etc, and this is the canonical name by which they
are referred.
Initially we started working around this with type: ignores, and later
by switching e.g. `pytest.fail.Exception` with the direct exception
`Failed`. But this causes a lot of churn and is not as nice. And I also
found that some code relies on it, in skipping.py:
def pytest_configure(config):
if config.option.runxfail:
# yay a hack
import pytest
old = pytest.xfail
config._cleanup.append(lambda: setattr(pytest, "xfail", old))
def nop(*args, **kwargs):
pass
nop.Exception = xfail.Exception
setattr(pytest, "xfail", nop)
...
So it seems better to support it. Use a hack to make it work. The rest
of the commit rolls back all of the workarounds we added up to now.
`pytest.raises.Exception` also exists, but it's not used much so I kept
it as-is for now.
Hopefully in the future mypy supports this and this ugliness can be
removed.
2020-02-18 23:17:27 +02:00
Ran Benita
a7a1686433
Add Item.runtest stub implementation
...
Every Item must implement this method (called on all items collected in
a session). Add a stub for typing and clarity.
2020-02-15 16:58:55 +02:00
Bruno Oliveira
78baa7b575
Merge remote-tracking branch 'upstream/master' into mm
...
Conflicts:
src/_pytest/main.py
src/_pytest/mark/structures.py
src/_pytest/python.py
testing/test_main.py
testing/test_parseopt.py
2020-02-11 19:22:28 -03:00
Daniel Hahler
30cb598e9c
Typing around/from types in docs ( #6699 )
2020-02-09 11:42:07 +01:00
Daniel Hahler
b0d45267c5
internal: clean up getfslineno
...
Everything was using `_pytest.compat.getfslineno` basically, which
wrapped `_pytest._code.source.getfslineno`.
This moves the extra code from there into it directly, and uses the
latter everywhere.
This helps to eventually remove the one in compat eventually, and also
causes less cyclic imports.
2020-02-03 19:09:08 +01:00
Ran Benita
a435faad5c
Merge branch 'master' into master-to-features
2020-01-31 11:27:06 +02:00
Bruno Oliveira
64ab68ff0a
Fix 6341 disallow session config in fromparent ( #6387 )
...
Fix 6341 disallow session config in fromparent
2020-01-29 19:21:02 -03:00
Ran Benita
ae5d16be10
typing: FSHookProxy/gethookproxy
...
Taken out of https://github.com/pytest-dev/pytest/pull/6556 .
2020-01-27 20:57:44 +01:00
Daniel Hahler
e2934c3f8c
Move common code between Session and Package to FSCollector
2020-01-25 19:04:01 +01:00
Daniel Hahler
09bdbffbde
Merge master into features
...
Conflicts:
src/_pytest/_code/code.py
src/_pytest/main.py
2020-01-24 23:44:50 +01:00
Ran Benita
9dcdea5de7
Rewrite Item.location to be clearer with regard to types
2020-01-23 13:25:15 +01:00
Daniel Hahler
1350c601dc
Node.location: handle str with _node_location_to_relpath
2020-01-23 10:45:31 +01:00
Daniel Hahler
ef112fd7dd
Revert "Revert "Fix type errors after adding types to the `py` dependency""
...
Without changes to test_itemreport_reportinfo.
This reverts commit fb99b5c66e
.
Conflicts:
testing/test_nose.py
2020-01-23 10:45:27 +01:00
Bruno Oliveira
93b74d28d2
Merge remote-tracking branch 'upstream/master' into mm
...
Conflicts:
* src/_pytest/_code/code.py
* src/_pytest/main.py
* testing/python/metafunc.py
* testing/test_parseopt.py
* testing/test_pytester.py
2020-01-22 11:03:45 -03:00
Ran Benita
fb99b5c66e
Revert "Fix type errors after adding types to the `py` dependency"
...
This reverts commit 930a158a6a
.
Regression test from Bruno Oliveira.
2020-01-20 23:44:56 +02:00
Ran Benita
930a158a6a
Fix type errors after adding types to the `py` dependency
2020-01-19 14:48:24 +02:00
Daniel Hahler
4e0dbe92dd
Node.name: str
2020-01-19 11:21:16 +01:00
Daniel Hahler
4a42deee7e
typing: Node.reportinfo: might return py.path.local via fspath
2020-01-17 11:05:46 +01:00
Daniel Hahler
83813bf515
Merge master into features
...
Conflicts:
.github/workflows/main.yml
2020-01-16 19:45:52 +01:00