Ran Benita
4108174777
code/source: remove Source(deindent: bool) parameter
...
Not used, except in tests.
2020-07-01 20:20:07 +03:00
Ran Benita
2fe178488a
code/source: expose deindent kwarg in signature
...
Probably was done to avoid the shadowing issue, but work around it
instead.
2020-07-01 20:20:06 +03:00
Ran Benita
7b1ba7c0db
pytester: slightly clean up LsofFdLeakChecker
2020-07-01 19:39:48 +03:00
Ruaridh Williamson
304f2916fc
logging: use unique handlers for caplog and reports
...
Setting log_level via the CLI or .ini will control the log level of the
report that is dumped upon failure of a test.
If caplog modified the log level during the execution of that test, it
should not impact the level that is displayed upon failure in the
"captured log report" section.
[
ran:
- rebased
- reused handler
- changed store keys also to "caplog_handler_*"
- added changelog
all bugs are mine :)
]
2020-07-01 19:30:03 +03:00
Ran Benita
ae83dbd4cf
python: remove ancient Function.repr_failure(outerr) parameter
...
This has been asserted like this since 04e9197fd6
(i.e. 11 years, pytest 1.0), seems safe to simply remove at this point.
2020-06-30 13:14:03 +03:00
Ran Benita
40c355f8c3
python: pytest_pycollect_makeitem doesn't need to be a hookwrapper
...
A trylast is more appropriate for this usecase.
hookwrappers are more complicated and more expensive than regular
hookimpls, so better avoided.
2020-06-30 13:14:03 +03:00
Ran Benita
e492b1d567
python: don't pass entire Item for generating ID
...
Just the nodeid is enough for the error messages.
This removes an import cycle.
2020-06-30 13:13:45 +03:00
Ran Benita
e6e300e729
Merge pull request #7396 from gnikonorov/issue_7295
...
Refactor src/_pytest/config/__init__.py to use the warnings module instead of stderr for warnings
2020-06-28 18:02:07 +03:00
Gleb Nikonorov
49ec2aed0f
change stacklevel in warnings from 2 to 3
2020-06-28 10:48:33 -04:00
Ran Benita
992a7a8d38
Merge pull request #7397 from lgeiger/reduce-ihook-calls
...
Reduce calls to item.ihook
2020-06-28 15:01:43 +03:00
Gleb Nikonorov
c39655725a
change if else structure of _warn_bout_missing_assertion
2020-06-27 19:49:19 -04:00
Gleb Nikonorov
72a39117a8
Merge remote-tracking branch 'origin' into issue_7295
2020-06-27 19:43:03 -04:00
Bruno Oliveira
289197ff22
Remove package scope experimental status
...
Close #7389
2020-06-27 11:16:50 -03:00
Ran Benita
7450b6dd95
Merge pull request #7418 from bluetech/typing-3
...
More typing work
2020-06-27 10:54:29 +03:00
gdhameeja
03230b4002
Fix-6906: Added code-highlight option to disable highlighting optionally
...
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-26 13:24:56 -07:00
Lukas Geiger
97d2c711e6
Reduce calls of Node.ihook
2020-06-26 14:46:37 +02: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
97a11726e2
freeze_support: type annotate
2020-06-25 15:28:34 +03:00
Ran Benita
8f8f472379
python_api: type annotate some parts of pytest.approx()
2020-06-25 15:15:24 +03:00
Ran Benita
142d8963e6
recwarn: type annotate pytest.deprecated_call
...
Also improve its documentation.
2020-06-25 14:40:26 +03:00
Ran Benita
653c83e127
recwarn: type annotate recwarn fixture
2020-06-25 14:30:42 +03:00
Ran Benita
4d813fdf5e
recwarn: improve return type annotation of non-contextmanager pytest.warns
...
It returns the return value of the function.
2020-06-25 14:30:42 +03:00
Ran Benita
f00bec2a12
Replace yield_fixture -> fixture in internal code
...
`yield_fixture` is a deprecated alias to `fixture`.
2020-06-25 14:05:46 +03:00
Gleb Nikonorov
0dd77b3e39
Merge remote-tracking branch 'origin/master' into issue_7295
2020-06-23 23:21:36 -04:00
David Diaz Barquero
617bf8be5b
Add details to error message for junit ( #7390 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-23 13:03:46 -03:00
Ran Benita
3624acb665
Merge pull request #7401 from bluetech/typing-config
...
config: improve typing
2020-06-23 18:58:21 +03:00
Ran Benita
8994e1e3a1
config: make _get_plugin_specs_as_list a little clearer and more general
2020-06-23 11:47:52 +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
Ran Benita
4655b79985
config: improve typing
2020-06-22 16:39:14 +03:00
Ran Benita
83891d9022
Merge pull request #7387 from cool-RR/2020-06-11-raise-from
...
Fix exception causes all over the codebase
2020-06-21 22:42:18 +03:00
Ran Benita
99d34ba029
Merge pull request #7388 from bluetech/mark-evaluate
...
skipping: refactor mark evaluation
2020-06-21 21:47:56 +03:00
Ran Benita
27492cf7a0
Merge pull request #7379 from bluetech/typing-builtin-marks
...
Type annotate pytest.mark.{skip,skipif,xfail,parametrize,usefixtures,filterwarnings}
2020-06-21 20:44:27 +03:00
Ran Benita
b3fb5a2d47
Type annotate pytest.mark.* builtin marks
2020-06-21 20:18:52 +03:00
Ran Benita
7d8d1b4440
skipping: better links in --markers output
...
Suggested by Bruno.
2020-06-21 20:15:10 +03:00
Ran Benita
c9737ae914
skipping: simplify xfail handling during call phase
...
There is no need to do the XPASS check here, pytest_runtest_makereport
already handled that (the current handling there is dead code).
All the hook needs to do is refresh the xfail evaluation if needed, and
check the NOTRUN condition again.
2020-06-21 19:54:29 +03:00
Gleb Nikonorov
ac89d6532a
replace stderr warnings with the warnings module
2020-06-20 12:15:58 -04:00
Ran Benita
3e6fe92b7e
skipping: refactor skipif/xfail mark evaluation
...
Previously, skipif/xfail marks were evaluated using a `MarkEvaluator`
class. I found this class very difficult to understand.
Instead of `MarkEvaluator`, rewrite using straight functions which are
hopefully easier to follow.
I tried to keep the semantics exactly as before, except improving a few
error messages.
2020-06-20 16:15:28 +03:00
Ram Rachum
dd446bee5e
Fix exception causes all over the codebase
2020-06-19 22:02:24 +03:00
Ran Benita
6072c9950d
skipping: move MarkEvaluator from _pytest.mark.evaluate to _pytest.skipping
...
This type was actually in `_pytest.skipping` previously, but was moved to
`_pytest.mark.evaluate` in cf40c0743c
.
I think the previous location was more appropriate, because the
`MarkEvaluator` is not a generic mark facility, it is explicitly and
exclusively used by the `skipif` and `xfail` marks to evaluate their
particular set of arguments. So it is better to put it in the plugin
code.
Putting `skipping` related functionality into the core `_pytest.mark`
module also causes some import cycles which we can avoid.
2020-06-19 13:33:54 +03:00
Ran Benita
a1f841d5d2
skipping: use pytest_runtest_call instead of pytest_pyfunc_call
...
`@pytest.mark.xfail` is meant to work with arbitrary items, and there is
a test `test_mark_xfail_item` which verifies this.
However, the code for some reason uses `pytest_pyfunc_call` for the
call phase check, which only works for Function items. The test
mentioned above only passed "accidentally" because the
`pytest_runtest_makereport` hook also runs a `evalxfail.istrue()` which
triggers and evaluation, but conceptually it shouldn't do that.
Change to `pytest_runtest_call` to make the xfail checking properly
generic.
2020-06-19 13:33:53 +03:00
Gleb Nikonorov
4cc4ebf3c9
Don't treat ini keys defined in conftest.py as invalid ( #7384 )
2020-06-18 12:58:41 -03:00
Andrew
a67c553beb
Disable caching when evaluating expressions in marks ( #7373 )
2020-06-16 12:39:36 +03:00
Ran Benita
b6fd89ef31
Merge pull request #7370 from bluetech/typing3
...
Some type annotations, doc improvements
2020-06-16 11:23:57 +03:00
Bruno Oliveira
db00612b84
Merge pull request #7364 from nicoddemus/parseoutcomes-plural-6505
...
assertoutcomes() only accepts plural forms
2020-06-15 20:27:40 -03:00
Ronny Pfannschmidt
4e5a7b7d2f
Merge pull request #7366 from gnikonorov/issue_7346
...
Allow users to provide version information to the required_plugins INI key
2020-06-15 20:19:05 +02:00
Ran Benita
7b77fc086a
Merge pull request #7368 from bluetech/teardown-in-setup
...
runner: don't try to teardown previous items from pytest_runtest_setup
2020-06-15 19:41:21 +03:00
Ran Benita
4f4c2638d0
Merge pull request #7351 from cool-RR/2020-06-11-raise-from
...
Fix exception causes in config/__init__.py
2020-06-14 18:03:56 +03:00
Ran Benita
da1124eb98
hookspec: improve runtest hooks documentation
2020-06-14 17:31:38 +03:00
Ran Benita
2a38ca8a0c
doc/reference: add CollectReport
...
CollectReport appears in several hooks, so we should document it. It's
runtest equivalent TestReport is already documented.
2020-06-14 16:55:41 +03:00
Ran Benita
bb878a2b13
runner: don't try to teardown previous items from pytest_runtest_setup
...
While working on improving the documentation of the
`pytest_runtest_setup` hook, I came up with this text:
> Called to perform the setup phase of the test item.
>
> The default implementation runs ``setup()`` on item and all of its
> parents (which haven't been setup yet). This includes obtaining the
> values of fixtures required by the item (which haven't been obtained
> yet).
But upon closer inspection I noticed this line at the start of
`SetupState.prepare` (which is what does the actual work for
`pytest_runtest_setup`):
self._teardown_towards(needed_collectors)
which implies that the setup phase of one item might trigger teardowns
of *previous* items. This complicates the simple explanation. It also
seems like a completely undesirable thing to do, because it breaks
isolation between tests -- e.g. a failed teardown of one item shouldn't
cause the failure of some other items just because it happens to run
after it.
So the first thing I tried was to remove that line and see if anything
breaks -- nothing did. At least pytest's own test suite runs fine. So
maybe it's just dead code?
2020-06-14 13:48:05 +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
Gleb Nikonorov
320625527a
Add more tests and docs
2020-06-13 11:22:18 -04: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
Bruno Oliveira
2c37585f58
Merge pull request #7258 from piotrhm/issue_6471
2020-06-13 11:14:18 -03:00
Gleb Nikonorov
8a022c0ce3
test to make sure precommit is fixed
2020-06-13 09:57:13 -04:00
Gleb Nikonorov
7ea116d74c
Merge remote-tracking branch 'origin' into issue_7346
2020-06-13 09:54:23 -04:00
Bruno Oliveira
3151219785
assertoutcomes() only accepts plural forms
...
Fix #6505
2020-06-13 10:29:22 -03:00
Ran Benita
f551cab877
Merge pull request #7358 from bluetech/typing2
...
More type annotations, fix some typing bugs
2020-06-13 10:44:11 +03:00
Gleb Nikonorov
6f8633cc17
add in solution barring documentation
2020-06-13 02:47:15 -04:00
Bruno Oliveira
aaa6f1c3fa
Merge pull request #7330 from gnikonorov/issue_7305
2020-06-12 19:35:38 -03:00
Ram Rachum
caa984c029
Fix exception causes in config/__init__.py
2020-06-12 18:49:57 +03:00
Ran Benita
a5ab7c19fb
config: reject minversion if it's a list instead of a single string
...
Fixes:
src/_pytest/config/__init__.py:1071: error: Argument 1 to "Version" has incompatible type "Union[str, List[str]]"; expected "str" [arg-type]
2020-06-12 17:34:31 +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
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
b4f046b777
monkeypatch: add type annotations
2020-06-12 17:34:31 +03:00
Ran Benita
f84ffd9747
Remove unused type: ignores
...
Not needed since update from mypy 0.770 -> 0.780.
2020-06-12 17:34:31 +03:00
Zac Hatfield-Dodds
0f30103d9c
Merge pull request #7356 from Zac-HD/emancipate
...
Finish deprecation of "slave"
2020-06-12 23:13:11 +10:00
Zac-HD
564b2f707d
Finish deprecation of "slave"
2020-06-12 22:49:33 +10:00
Gleb Nikonorov
2c8e356174
rename _emit_warning_or_fail to _warn_or_fail_if_strict and fix a doc typo
2020-06-12 08:27:55 -04:00
Bruno Oliveira
ab331c906e
Suppress errors while removing tmpdir's lock files
...
Fix #5456
2020-06-11 18:59:51 -03:00
Gleb Nikonorov
c18afb59f5
final touches
2020-06-10 19:09:24 -04:00
Gleb Nikonorov
95cb7fb676
review feedback
2020-06-10 00:44:22 -04:00
ibriquem
e2e7f15b71
Make dataclasses/attrs comparison recursive, fixes #4675
2020-06-09 14:39:40 -03:00
piotrhm
f0e47c1ed6
Fix typo
2020-06-09 11:17:31 -03:00
piotrhm
bde0ebcda9
Replace cleanup_numbered_dir with atexit.register
2020-06-09 11:17:31 -03:00
Bruno Oliveira
357f9b6e83
Add type annotations
2020-06-08 22:26:14 -03:00
piotrhm
51fb11c1d1
Added tests
2020-06-08 22:26:14 -03:00
piotrhm
0b70300ba4
Added requested modifications
2020-06-08 22:26:14 -03:00
Bruno Oliveira
fcbaab8b0b
Allow tests to override "global" `log_level` (rebased) ( #7340 )
...
Co-authored-by: Ruaridh Williamson <ruaridh.williamson@flexciton.com>
2020-06-08 22:05:46 -03:00
Prashant Anand
e78207c936
7119: data loss with mistyped --basetemp ( #7170 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-08 21:54:22 -03:00
Fabio Zadrozny
322190fd84
Fix issue where working dir becomes wrong on subst drive on Windows. Fixes #5965 ( #6523 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-06-08 10:56:40 -03:00
Bruno Oliveira
c17d50829f
Add pyproject.toml support ( #7247 )
2020-06-08 10:03:10 -03:00
Gleb Nikonorov
d2bb67bfda
validate plugins before keys in config files
2020-06-07 14:10:20 -04:00
Gleb Nikonorov
f1746c50ea
Merge remote-tracking branch 'origin/master' into issue_7305
2020-06-06 12:37:56 -04:00
Gleb Nikonorov
3f6b3e7faa
update help for --strict-config
2020-06-06 11:33:28 -04:00
Gleb Nikonorov
f760b105ef
Touchup pre-PR
2020-06-06 11:06:08 -04:00
Gleb Nikonorov
2a3c21645e
Commit solution thus far, needs to be polished up pre PR
2020-06-06 02:38:18 -04:00
Ran Benita
1deaa74345
mark/expression: prevent creation of illegal Python identifiers
...
This is rejected by Python DEBUG builds, as well as regular builds in
future versions.
2020-06-05 15:57:48 +03:00
Ran Benita
2b05faff0a
Improve types around repr_failure()
2020-06-05 11:34:20 +03:00
Ran Benita
54ad048be7
Enable check_untyped_defs mypy option for testing/ too
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
848ab00663
Type annotate `@pytest.mark.foo`
2020-06-05 11:34:20 +03:00
Ran Benita
c0af19d8ad
Type annotate more of _pytest.terminal
2020-06-05 11:34:20 +03:00
Ran Benita
2833884688
Type annotate pytest.fixture and more improvements to _pytest.fixtures
2020-06-05 11:34:20 +03:00
Ran Benita
8bcf1d6de1
Remove duplicated conversion of pytest.fixture() params argument
...
The FixtureFunctionMarker attrs class already converts the params
itself.
When adding types, the previous converter composition causes some type
error, but extracting it to a standalone function fixes the issue (a
lambda is not supported by the mypy plugin, currently).
2020-06-05 11:34:20 +03:00
Ran Benita
1bd7d025d9
Type annotate more of _pytest.fixtures
2020-06-05 11:34:20 +03:00
Ran Benita
f8bb61ae5b
Type annotate _pytest.warnings
2020-06-05 11:34:20 +03:00