Ronny Pfannschmidt
38a4c7e56c
Merge pull request #6986 from RonnyPfannschmidt/fix-6951-tw.writer-writable
...
fix #6951 : allow to write TerminalReporter.writer
2020-04-10 08:12:34 +02:00
Daniel Hahler
554f600fb4
Fix TerminalRepr instances to be hashable ( #6988 ) ( #7006 )
...
pytest-xdist assumes `ExceptionChainRepr` is hashable.
Fixes https://github.com/pytest-dev/pytest/issues/6925 .
Fixes https://github.com/pytest-dev/pytest-xdist/issues/515 .
(cherry picked from commit 20f6331afd
)
2020-04-03 10:59:23 +02:00
Ran Benita
e3a3c90d94
[5.4.x] Fix crash when printing while capsysbinary is active ( #7002 )
...
Backport of 1fda861190
from master.
2020-04-02 14:31:32 +03:00
Bruno Oliveira
b9e2cd0a81
Merge pull request #6914 from nicoddemus/revert-6330
...
Revert "[parametrize] enforce explicit argnames declaration (#6330 )"
2020-03-13 10:18:06 -03:00
Bruno Oliveira
a84fcbf5b2
Revert "[parametrize] enforce explicit argnames declaration ( #6330 )"
...
This reverts commit 9e262038c8
.
Fix #6909
2020-03-13 09:59:53 -03:00
Bruno Oliveira
3267f64724
Merge pull request #6910 from nicoddemus/resultlog-logreport
...
Handle unknown stats in pytest_report_teststatus hook
2020-03-13 09:30:14 -03:00
Ran Benita
4f8fff9cab
Merge pull request #6868 from bluetech/simplify-exc
...
Simplify some exception handling code
2020-03-10 20:32:08 +02:00
Daniel Hahler
ac7ebfa22e
doc: internal: fix `MultiCapture.readouterr` ( #6878 )
...
Remove wrong docstring: it might actually return bytes.
Replace it with a type annotation which is clear enough.
2020-03-08 12:38:21 +01:00
Daniel Hahler
db92cea14c
black: --target-version py35 ( #6872 )
2020-03-08 01:24:31 +01:00
Daniel Hahler
bce1d40fb0
tests: harden test_reprcompare_notin, factor out callop ( #6764 )
...
* tests: assertion: factor out `callop`, typing
* tests: harden test_reprcompare_notin
2020-03-08 01:23:19 +01:00
Daniel Hahler
dc86fb6758
pre-commit run --all-files
2020-03-07 23:47:55 +01:00
Ran Benita
978b315861
Simplify some exception handling code
...
Mostly avoid unnecessary usage of sys.exc_info(). Since Python3,
exception objects themselves have all that's needed. They are also
easier to type.
2020-03-07 13:18:54 +02:00
Ran Benita
580edc13e7
Merge pull request #6867 from bluetech/inline-pyobjmixin
...
Inline PyobjContext
2020-03-07 11:58:38 +02:00
Ran Benita
b7f2e3d4f5
Inline PyobjContext
...
When it was introduced in 8adac2878f
it
seems to have had some use, but now it doesn't.
2020-03-06 14:55:20 +02:00
Ran Benita
f011bc642c
Store mark's evalcache in config's store instead of attribute
...
Part of moving away from ad-hoc attributes to using the config's store.
2020-03-06 11:42:20 +02:00
Ran Benita
b1d7a187f2
Add setdefault() method to Store
...
Can be useful in some cases.
2020-03-06 11:42:20 +02:00
Ran Benita
678d65f051
Store AssertionState in config's store instead of attribute
...
Part of moving away from ad-hoc attributes to using the config's store.
2020-03-06 11:27:01 +02:00
Daniel Hahler
fcd3fad03d
Minor internal improvements to logging's log_level ( #6849 )
2020-03-06 03:12:57 +01:00
Bruno Oliveira
19bb2c6235
Merge pull request #6859 from nicoddemus/kw-mapping-attr-typing
...
Use attrs in KeywordMapping
2020-03-05 08:47:22 -03:00
Bruno Oliveira
bc8e52c3c2
Use attrs in KeywordMapping
...
Also added type hinting.
2020-03-05 08:33:20 -03:00
Kyle Altendorf
dce2621710
Add pytest-twisted to list of async def handling plugins
...
https://github.com/pytest-dev/pytest-twisted/tree/v1.12#ensuredeferred
[pytest-twisted](https://github.com/pytest-dev/pytest-twisted ) supports `async def` test functions and fixtures as well as `async def`/`yield` fixtures.
2020-03-04 17:42:08 -05:00
Daniel Hahler
acec0b688f
Fix usage of pytester with doctests ( #6802 )
...
Use `request.node.name` instead of `request.function.__name__`:
`request.function` is `None` with `DoctestItem`s.
2020-03-04 05:33:50 +01:00
Daniel Hahler
37d074efc8
Fix (internal) documentation for pytester's LineComp ( #6850 )
2020-03-04 05:25:32 +01: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
Daniel Hahler
b11bfa106c
Use attrs with all Repr classes ( #6739 )
...
Co-authored-by: Ran Benita <ran234@gmail.com>
2020-03-03 21:53:28 +01:00
Daniel Hahler
ddc8edffbc
logging: minor typing, rename function
...
`get_log_level_for_setting` reflects better what the function does, and
it does not require a (trivial) docstring.
2020-03-01 22:02:46 +01:00
Daniel Hahler
bdd22fdd52
logging: improve help for log_level
2020-03-01 22:02:46 +01:00
Ronny Pfannschmidt
194b52145b
Merge pull request #6834 from RonnyPfannschmidt/fix-6833-summarize-warning-item-locations
...
summarize warning summaries if the number of locations is high
2020-03-01 20:21:36 +01:00
Ronny Pfannschmidt
23c43a37e0
summarize warning summaries if the number of locations is high
2020-03-01 14:08:15 +01: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
Ran Benita
2f60548e08
Mark AssertionRewritingHook as implementing importlib.abc.Loader
...
It implements the required methods. This is useful for typing but also a
nice indicator.
2020-02-29 16:55:56 +02: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
Bruno Oliveira
ff7b5dbbde
Merge pull request #6784 from nicoddemus/deprecate-terminal-writer
...
Deprecate TerminalReporter.writer
2020-02-28 21:07:02 -03:00
Daniel Hahler
5819536f00
Improve UsageError with invalid `-o` style ( #6795 )
...
This started from fixing the test, where `"xdist_strict True"` was used
as a single argument, although you typically would see `["xdist_strict",
"True"]`.
Improves the error message to mention the option that caused the error.
2020-02-28 19:41:56 +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
Daniel Hahler
16c683dff9
Remove unused `setns` ( #6804 )
...
Last usage of it was removed in ba17363d7
.
2020-02-26 15:35:14 +01:00
Daniel Hahler
ac3a42bafd
doctest: strip newlines with unexpected exceptions ( #6801 )
2020-02-24 15:18:08 +01:00
Daniel Hahler
be23aeb989
Remove unused `pytester.getdecoded` ( #6805 )
...
Last usage was removed in 22dc47d9f
.
2020-02-24 14:33:26 +01:00
Daniel Hahler
9928c7794b
minor: fix trace msg: s/loaded/loading ( #6798 )
2020-02-23 17:12:30 +01:00
Daniel Hahler
706ea86bba
capture: factor out _get_multicapture ( #6788 )
...
Ref: https://github.com/pytest-dev/pytest/pull/6671#issuecomment-588408992
2020-02-22 23:39:20 +01:00
Daniel Hahler
1d5a0ef284
Fix pytest_ignore_collect hooks: do not return False ( #6778 )
...
It should only return `True` when something is to be ignored, not
`False` otherwise typically.
This caused e.g. bad interaction with the cacheprovider (before
https://github.com/pytest-dev/pytest/pull/6448 ).
2020-02-22 23:35:47 +01:00
Daniel Hahler
c8b4a1a471
Handle `match` with `pytest.raises()` ( #6753 )
...
Fixes https://github.com/pytest-dev/pytest/issues/6752 .
2020-02-22 23:32:55 +01:00
Daniel Hahler
68fe0eb8f3
Minor cosmetic fixes ( #6792 )
2020-02-22 19:24:41 +01:00
Daniel Hahler
de854c6ee1
doc: `pytest.raises`: remove mention of removed `message` ( #6793 )
...
Follow-up to 13f7f27fd
.
2020-02-22 19:24:00 +01:00
Daniel Hahler
04126feea7
doc: `pytest.raises`: link to `python:try` ( #6794 )
2020-02-22 19:23:35 +01:00
Daniel Hahler
478a244f5e
main: `args` must be a list, not tuple ( #6791 )
...
Passing in a tuple crashes in `_prepareconfig`:
def test_invoke_with_tuple(self):
> pytest.main(("-h",))
src/_pytest/config/__init__.py:82: in main
config = _prepareconfig(args, plugins)
src/_pytest/config/__init__.py:229: in _prepareconfig
return pluginmanager.hook.pytest_cmdline_parse(
…
src/_pytest/helpconfig.py:98: in pytest_cmdline_parse
config = outcome.get_result() # type: Config
src/_pytest/config/__init__.py:808: in pytest_cmdline_parse
self.parse(args)
src/_pytest/config/__init__.py:1017: in parse
self._preparse(args, addopts=addopts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def _preparse(self, args: List[str], addopts: bool = True) -> None:
…
if addopts:
ini_addopts = self.getini("addopts")
if ini_addopts:
> args[:] = self._validate_args(ini_addopts, "via addopts config") + args
E TypeError: can only concatenate list (not "tuple") to list
addopts = True
args = ('-h',)
env_addopts = ''
ini_addopts = ['-rfEX', …]
src/_pytest/config/__init__.py:956: TypeError: can only concatenate list (not "tuple") to list
Might be worth handling (converting it to a list for example), but it
was documented to be a list to begin with when removing support for
strings (a7e401656
).
2020-02-22 13:16:46 +01:00
Daniel Hahler
47ccd58fb4
Fix typo in doc with syspath_prepend
2020-02-22 13:15:17 +01:00
Daniel Hahler
260f848c05
minor: remove outdated, superfluous comment
2020-02-22 13:15:17 +01:00
Daniel Hahler
2be06ba67e
Improve doc/typing/message for `ExceptionInfo.match` ( #6776 )
2020-02-21 16:41:57 +01:00
Daniel Hahler
4c9b850e13
help: --deselect: mention that this uses node id prefixes ( #6770 )
...
Ref: https://github.com/pytest-dev/pytest/issues/6751
2020-02-21 12:53:27 +01:00