Commit Graph

1677 Commits

Author SHA1 Message Date
Daniel Hahler e7a833635d
Merge pull request #6635 from blueyed/fix-todo
minor: doc: getfuncargnames: move TODO out of docstring
2020-01-30 23:37:41 +01:00
Daniel Hahler fed5356941
Merge pull request #6634 from blueyed/fixtures-move-import
fixtures: move import of ParameterSet to top level
2020-01-30 23:22:39 +01:00
Daniel Hahler 5b81bd862c minor: doc: getfuncargnames: move TODO out of docstring 2020-01-30 23:22:10 +01:00
Daniel Hahler 2902c7263c fixtures: move import of ParameterSet to top level
This gets typically used always (via `getfixtureinfo`).
2020-01-30 23:03:02 +01:00
Daniel Hahler 442dccef65 python: factor out async_warn 2020-01-30 22:55:23 +01:00
Daniel Hahler 88b800355a typing: pytest_collection 2020-01-30 19:58:43 +01:00
Daniel Hahler 28b8f3ca3a
Merge pull request #6461 from blueyed/test-package-upstream
Package: typing, cleanup
2020-01-30 16:41:47 +01: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
Anthony Sottile 595d62bc3e
Merge pull request #6607 from asottile/empty_string_parametrize_nodeid
Fix node ids which contain a parametrized empty-string variable
2020-01-29 08:42:04 -08:00
Daniel Hahler 55e5817570 Merge master into features 2020-01-29 03:07:35 +01:00
Daniel Hahler 3ccf2a5e61
Merge pull request #6524 from blueyed/reportchars-default
terminal: default to `fE` with `-r` (reportchars)
2020-01-29 01:00:41 +01:00
Bruno Oliveira d282424589
Fix unguarded `==` comparison in fixtures. (#6541)
Fix unguarded `==` comparison in fixtures.
2020-01-28 20:54:14 -03:00
Daniel Hahler ddaa5d88ac terminal: default to `fE` with `-r` (reportchars)
Adds handling of `N` to reset `reportchars`, which can be used to get
the old behavior (`-rN`), and also allows for an alternative to
`--disable-warnings` (https://github.com/pytest-dev/pytest/issues/5066),
since `w` was included by default (without `--disable-warnings`).

Fixes https://github.com/pytest-dev/pytest/issues/6454
2020-01-29 00:33:15 +01:00
Daniel Hahler 4ff90b1fcf
Merge pull request #6606 from blueyed/typing-monkeypatch-context
typing: MonkeyPatch.context
2020-01-29 00:12:53 +01:00
Anthony Sottile abd5fc80e8 Fix node ids which contain a parametrized empty-string variable 2020-01-28 13:27:54 -08:00
Holger Kohr 80d4dd6f0b Replace `==` with `is` for comparison of cache keys
Closes #6497
2020-01-28 18:05:53 -03:00
Ran Benita e440b43258
Merge pull request #6555 from bluetech/nodes-cache-split
Split Session._collection_node_cache to 3 mutually exclusive parts
2020-01-28 22:49:42 +02:00
Daniel Hahler e25d46aae6 typing: MonkeyPatch.context 2020-01-28 21:44:30 +01:00
Daniel Hahler 7c87874277 source_path: py.path.local directly
Via bc7282576.
2020-01-28 19:02:41 +01:00
Daniel Hahler 1cf9e68dbc tests: cover absolute path handling in _compute_fixture_value 2020-01-28 18:53:28 +01:00
Daniel Hahler 18ac7e0b79
Merge pull request #6593 from blueyed/typing-ignore-more-itertools
typing: ignore false positive with more-itertools
2020-01-28 14:24:24 +01:00
Daniel Hahler 12c5a6af64 typing: fix Code.path
Fixes:

> src/_pytest/_code/code.py:83: error: Incompatible types in assignment
>   (expression has type "str", variable has type "local")  [assignment]
2020-01-28 01:49:45 +01:00
Daniel Hahler 30922ee694 Merge master into features 2020-01-28 01:40:14 +01:00
Daniel Hahler 35ba053f00 typing: ignore false positive with more-itertools
Fixed in https://github.com/erikrose/more-itertools/pull/374.
2020-01-28 01:23:44 +01:00
Daniel Hahler 9c716e4d74 typing: Testdir.plugins 2020-01-28 00:41:46 +01:00
Daniel Hahler 94ac0f7e6b typing: self._mod_collections, collect_by_name 2020-01-28 00:41:46 +01:00
Daniel Hahler 440881d63a typing: Testdir.__init__ 2020-01-28 00:41:46 +01: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 bf5c76359c fixup! typing: tests: tmpfile 2020-01-26 23:14:32 +01:00
Daniel Hahler 3f8f395210 typing: EncodedFile 2020-01-25 19:20:48 +01:00
Daniel Hahler e2934c3f8c Move common code between Session and Package to FSCollector 2020-01-25 19:04:01 +01:00
Daniel Hahler 6b7e1a246c Sync `{Session,Package}.gethookproxy`
Only copy'n'paste error from c416b1d935.
2020-01-25 19:04:01 +01:00
Daniel Hahler 817c094ce6 Clean up Package.__init__
Makes `parent` a required arg, which would have failed before via
`parent.session` anyway.

Keeps calling/passing unused args for B/C.
2020-01-25 19:04:01 +01:00
Daniel Hahler 039d582b52 Fix `EncodedFile.writelines`
This is implemented by the underlying stream already, which additionally
checks if the stream is not closed, and calls `write` per line.

Ref/via: https://github.com/pytest-dev/pytest/pull/6558#issuecomment-578210807
2020-01-25 18:06:50 +01:00
Daniel Hahler 9b8039cf09 Sync `{Session,Package}._recurse` 2020-01-25 16:44:20 +01:00
Daniel Hahler c51173d426 Merge master into features 2020-01-25 14:18:02 +01:00
Ran Benita 94d8c071b6 Remove a couple of redundant commas
Mypy complains about this once the function is typed:

src/_pytest/main.py:85: error: "_addoption" of "OptionGroup" does not return a value
src/_pytest/main.py:133: error: "addoption" of "OptionGroup" does not return a value
2020-01-25 14:12:47 +01:00
Ran Benita f3967333a1 Split Session._collection_node_cache to 3 mutually exclusive parts
Previously, this cache was used with 3 different and mutually exclusive
key-type -> value-type combinations. Mypy can't properly type this. It's
also quite confusing.

Split to 3 different dicts instead.
2020-01-25 14:31:12 +02:00
Ran Benita a76bc64c54
Merge pull request #6547 from bluetech/session-initialparts
Refactor Session._initialparts to have a more explicit type
2020-01-25 14:30:26 +02:00
Ran Benita dd5c2b22bd Refactor Session._initialparts to have a more explicit type
Previously, _initialparts was a list whose first item was a
`py.path.local` and the rest were `str`s. This is not something that
mypy is capable of modeling. The type `List[Union[str, py.path.local]]`
is too broad and would require asserts for every access.

Instead, make each item a `Tuple[py.path.local, List[str]]`. This way
the structure is clear and the types are accurate.

To make sure any users who might have been accessing this (private)
field will not break silently, change the name to _initial_parts.
2020-01-25 13:57:49 +02:00
Tomáš Gavenčiak 5e15c86cc6 Fix EncodedFile.write return value
Make EncodedFile, used for captured output streams, method .write return
the number of characters written. Add test for captured stderr write.
Fixes #6557.

Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2020-01-25 10:36:23 +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
Daniel Hahler 03bc8aba4e config: typing for create_terminal_writer, re-export TerminalWriter
This also imports `TerminalWriter` explicitly via `_pytest._io`,
allowing for easier extending / replacing it.
2020-01-23 14:09:37 +01:00
Daniel Hahler 6b13379f37
Merge pull request #6521 from blueyed/harden-nose-raises
tests: improve test for `nose.raises`
2020-01-23 13:42:14 +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 8521503246
Merge pull request #6527 from blueyed/typing-getfslineno
typing: fix/adjust _code.source.getfslineno
2020-01-23 13:17:47 +01:00
Ran Benita 0b6258ab5b PyCollector.collect: use explicit cast to `str`
Ref: https://github.com/pytest-dev/pytest/pull/6521#pullrequestreview-347234792
2020-01-23 12:54:52 +01:00
Daniel Hahler 9c7b3c57d7 typing: PyobjMixin.reportinfo, getfslineno 2020-01-23 10:45:31 +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
Daniel Hahler ad02f6f879
Merge pull request #6525 from blueyed/typing-session
typing: Session.__init__
2020-01-23 00:16:08 +01:00
Daniel Hahler bd6ba3f3e1 typing: Session.__init__
Pulled out of https://github.com/pytest-dev/pytest/pull/6491.
2020-01-23 00:07:59 +01:00
Bruno Oliveira e17f5fad14
Clear node collection cache after collection is done (#6491)
Clear node collection cache after collection is done
2020-01-22 16:08:59 -03:00
Daniel Hahler aca1723d45 Merge master into features 2020-01-22 19:18:13 +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
Daniel Hahler b8787b8732 tests: fix test_cwd_snapshot
Without restoring the cwd, successive tests might fail to parse the
config (via `_pytest.config._prepareconfig()`, for when `--lsof` is
used).

And it is good practice to restore the cwd in any case anyway.
2020-01-22 14:34:11 +01:00
Daniel Hahler 62db3f7abc typing: fix/adjust _code.source.getfslineno 2020-01-21 19:48:17 +01:00
Daniel Hahler 7ee27fedee doc: fix Code.path: might return str 2020-01-21 19:46:43 +01:00
Bruno Oliveira 7b1e3d1c9a Clear collection caches after collection is done
Also rename the involved variables to convey its intent better and
add type hints
2020-01-21 07:29:13 -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
Bruno Oliveira cdaa9c06e1
Revert "fixtures register finalizers with all fixtures before t… (#6496)
Revert "fixtures register finalizers with all fixtures before them in the stack"
2020-01-20 13:49:00 -03:00
Ran Benita 3392be37e1 Fix check_untyped_defs in test_runner 2020-01-19 20:01:07 +02:00
Ran Benita 3d2680b31b Fix type of pytest.warns, and fix check_untyped_defs in test_recwarn
The expected_warning is optional.
2020-01-19 19:39:14 +02:00
Ran Benita 0c247be769 Add a few missing type annotations in _pytest._code
These are more "dirty" than the previous batch (that's why they were
left out). The trouble is that `compile` can return either a code object
or an AST depending on a flag, so we need to add an overload to make the
common case Union free. But it's still worthwhile.
2020-01-19 19:39:14 +02:00
Ran Benita 3e6f0f34ff Cleanup unhelpful alias _AST_FLAG
Also replace one direct call to `compile` with this flag with the
equivalent wrapper `ast.parse`. This function can have a more precise
type.
2020-01-19 19:19:34 +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 d347a30656
Merge pull request #6510 from blueyed/typing-fixes
typing: fix some "incompatible types in assignment" with py
2020-01-19 13:01:35 +01:00
Daniel Hahler 32b62f770f
Merge pull request #6509 from blueyed/typing-minor
typing: minor improvements
2020-01-19 11:33:41 +01:00
Daniel Hahler aaae43e0ba typing: fix some "incompatible types in assignment" with py 2020-01-19 11:32:45 +01:00
Daniel Hahler 09e9a01df3 typing: fix _TracebackStyle: add "line" 2020-01-19 11:22:47 +01:00
Daniel Hahler 5c445b05e7 typing: py.io.TerminalWriter for tw arguments 2020-01-19 11:21:16 +01:00
Daniel Hahler 4e0dbe92dd Node.name: str 2020-01-19 11:21:16 +01:00
Daniel Hahler 956389fa8c Session._fixturemanager 2020-01-19 11:21:16 +01:00
Bruno Oliveira cc7f294cfe Revert "fixtures register finalizers with all fixtures before them in the stack"
This reverts commit 99180939fe.
2020-01-17 12:55:57 -03:00
Daniel Hahler 4a42deee7e typing: Node.reportinfo: might return py.path.local via fspath 2020-01-17 11:05:46 +01:00
Daniel Hahler 36944157f8 pytester: typing for `spawn`/`spawn_pytest` 2020-01-17 05:58:25 +01:00
Daniel Hahler 1667cf3350
Merge pull request #6384 from pv/showlocals-short
Make --showlocals work together with --tb=short

Fixes https://github.com/pytest-dev/pytest/issues/494
Ref: https://github.com/pytest-dev/pytest/issues/1715
2020-01-16 22:04:14 +01:00
Daniel Hahler 5f4cd536f9 Use _pytest.compat.TYPE_CHECKING 2020-01-16 19:47:23 +01:00
Daniel Hahler 83813bf515 Merge master into features
Conflicts:
	.github/workflows/main.yml
2020-01-16 19:45:52 +01:00
Daniel Hahler 4630e2725e Use `TYPE_CHECKING` instead of `False`
This allows for e.g. Jedi to infer types (it checks the name).

It was only used to support Python 3.5.0/3.5.1, where this is is not
available in the `typing` module.

Ref: https://github.com/davidhalter/jedi/issues/1472

Uses `TYPE_CHECKING = False` in `_pytest.outcomes` to avoid having to
work around circular import.
2020-01-16 16:11:39 +01:00
Jakub Mitoraj ab6406b42e Update junit_logging with no,log,system-out,system-err,out-err,all 2020-01-16 08:14:46 +01:00
Chris NeJame 99180939fe fixtures register finalizers with all fixtures before them in the stack 2020-01-15 11:00:42 -05:00
Ronny Pfannschmidt 8ba0b7bc2a fix #6341 - disallow session/config in Node.from_parent 2020-01-15 13:00:46 +01:00
Daniel Hahler f5844449a8
Merge pull request #6442 from blueyed/rP
terminal: summary_passes: handle teardown sections
2020-01-15 03:02:09 +01:00
Pauli Virtanen fd1691a2b3 Make --showlocals work together with --tb=short
Enable showing local variables when asked to do so in the short
traceback mode.

Fixes #494
2020-01-14 21:30:58 +02:00
Daniel Hahler 910d5df6a8
Merge pull request #6456 from blueyed/fix-doc-_splitnode
minor: fix doc/example for _pytest.nodes._splitnode
2020-01-14 15:22:01 +01:00
Bruno Oliveira e9d9f71374 Merge remote-tracking branch 'upstream/master' into mm 2020-01-14 09:17:52 -03:00
Daniel Hahler 189fe3ba1d minor: fix doc/example for _pytest.nodes._splitnode 2020-01-14 12:40:36 +01:00
Daniel Hahler f0c7f21312 Remove "pragma: no cover" comments 2020-01-14 09:15:36 +01:00
Daniel Hahler 8eec42f040
Merge pull request #6455 from blueyed/mypy-master
master: update mypy 0.740 -> 0.761
2020-01-14 08:56:51 +01:00
Ran Benita 090e260517 master: update mypy 0.740 -> 0.761
(cherry picked from commit 16ff9f591e)
(cherry picked from commit 4848bbdf9a)
2020-01-14 06:31:41 +01:00
Daniel Hahler 117072d64c typing: fix _pytest.config.findpaths.determine_setup 2020-01-13 11:45:20 +01:00
Daniel Hahler 61d04d3084 terminal: summary_passes: handle teardown sections
Fixes https://github.com/pytest-dev/pytest/issues/2780.
2020-01-11 21:58:19 +01:00
Daniel Hahler 1356d20e90 Merge master into features 2020-01-10 05:20:41 +01:00
Daniel Hahler 1e28cb855d
Merge pull request #6425 from blueyed/xfail-yellow
terminal: use "yellow" with any "xpassed" tests
2020-01-09 23:22:58 +01:00
Bruno Oliveira 29db2da9a7
tmpdir_factory.mktemp now fails given absolute and non-normaliz… (#6323)
tmpdir_factory.mktemp now fails given absolute and non-normalized paths.
2020-01-09 19:10:03 -03:00
Bruno Oliveira 5b295ec68e Merge remote-tracking branch 'upstream/features' into gftea/features 2020-01-09 18:41:47 -03:00
Bruno Oliveira fa645a7003 Improve docstrings for mktemp 2020-01-09 18:20:46 -03:00
Daniel Hahler 13baab746d terminal: use "yellow" with any "xpassed" tests
Closes https://github.com/pytest-dev/pytest/issues/449.
2020-01-09 22:20:41 +01:00
Daniel Hahler 2d2c67d7c0 cacheprovider: pytest_collection_modifyitems: copy items 2020-01-09 21:48:54 +01:00