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
57512aa997
_get_main_color: no yellow ("boring") for non-last item
...
- refactor _get_main_color/build_summary_stats_line
- factor out property _is_last_item; test_summary_stats: tr._is_last_item
- _write_progress_information_filling_space: remove color arg
- use setter for stats, handling main color
- _get_main_color: skip cache for last item
- Handle random order in test for py35.
2020-01-25 15:09:02 +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
Bruno Oliveira
0e00069340
Fix serialization of 'None' reprcrashes
...
Tracebacks coming from remote processes crated by the multiprocess module
will contain "RemoteTracebacks" which don't have a 'reprcrash' attribute
Fix #5971
2020-01-06 22:04:38 -03:00
Bruno Oliveira
91a96ec3d6
Remove usage of parser module, deprecated in Python 3.9
...
Fix #6404
2020-01-06 08:57:07 -03:00
Bruno Oliveira
12f74a28fa
Revert "Remove unused _pytest.code.Source.isparseable function"
...
This reverts commit c627ac4e59
.
2020-01-05 14:12:40 -03:00
Bruno Oliveira
c627ac4e59
Remove unused _pytest.code.Source.isparseable function
...
Besides unused, it uses the (deprecated in Python 3.9) parser module
Fix #6404
2020-01-05 12:33:12 -03:00
Daniel Hahler
7aac48c418
Merge pull request #6382 from blueyed/fix-parseoutcomes
...
Fix `RunResult.parseoutcomes` (follow-up to #6353 )
2020-01-04 00:49:24 +01:00
Ran Benita
0375c1b728
Merge pull request #6388 from bluetech/mypy-761
...
Update mypy 0.750 -> 0.761
2020-01-01 16:07:55 +02:00
Ran Benita
4848bbdf9a
Update mypy 0.750 -> 0.761
...
This fixes some type: ignores due to typeshed update.
Newer mypy seem to ignore unannotated functions better, so add a few
minor annotations so that existing correct type:ignores make sense.
2020-01-01 15:22:16 +02:00
Daniel Hahler
1c0242dec1
Fix `RunResult.parseoutcomes` (follow-up to #6353 )
2019-12-30 17:08:52 +01:00
Daniel Hahler
a5224f7490
Revert black formatting of essential_plugins
...
Done in a02310a140
(likely automatic), but loses information of the
comment obviously.
2019-12-30 15:28:37 +01:00
Daniel Hahler
a5863ca760
minor: split doc with _early_rewrite_bailout
2019-12-30 09:41:36 +01:00
Bruno Oliveira
8077168387
pytester: quick fix error introduced in #5990 ( #6353 )
...
pytester: quick fix error introduced in #5990
2019-12-27 13:28:11 -03:00
Alexandre Mulatinho
dc7bf518b3
pytester: quick fix error introduced in #5990
...
- added a test to check this condition
Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
2019-12-18 16:36:24 -03:00
Bruno Oliveira
75493f78bf
Merge master into features ( #6346 )
...
Merge master into features
2019-12-16 21:57:26 -03:00
Bruno Oliveira
c487cf9dd5
Deprecate no print logs ( #6333 )
...
Deprecate no print logs
2019-12-16 19:01:16 -03:00
Seth Junot
d4879c7afb
Optimized renaming of test parameter ids
...
While using pytest-repeat, I noticed the previous implementation is slow
for a large number of duplicate test ids. To optimize, this commit
reduces the amount of data copied and avoids using `in` with List
(unhashable type, and therefore is very slow for many elements).
2019-12-16 18:53:48 -03:00
Vinay Calastry
afbaee7649
Deprecate --no-print-logs option
2019-12-14 16:46:30 -08:00
Bruno Oliveira
853889e5db
Merge remote-tracking branch 'upstream/master' into mm
2019-12-14 10:45:44 -03:00
Bruno Oliveira
f7409f8685
Improve warning about incoming change to 'junitxml_family' default
...
Fix #6265
2019-12-13 09:17:12 -03:00
Bruno Oliveira
66c1a120ba
Bugfix 5430 pass logs to junit report ( #6274 )
...
Bugfix 5430 pass logs to junit report
2019-12-12 09:35:25 -03:00
gftea
226f0c48bf
fix #5686 , mktemp now fails given absolute and non-normalized paths.
2019-12-12 13:00:23 +01:00
Bruno Oliveira
fa51a26743
Make -r letters "s" and "S" aliases
...
Similar reasons as the previous commit
2019-12-12 07:48:07 -03:00
Bruno Oliveira
59067ad33d
Make -r letters "f" and "F" aliases
...
As far as the output is concerned, they are both identical so it doesn't
make sense to have both.
setup, teardown, and collect failures are already reported as "errors", "E".
2019-12-12 07:43:37 -03:00
Bruno Oliveira
cbb2f9541b
Merge pull request #6316 from cb109/make-keyword-expression-matching-case-insensitive
...
Make keyword expression matching case-insensitive
2019-12-12 06:47:59 -03:00
cmachalo
e13ad22364
Include new --capture-mode=tee-sys option
...
Fix #4597
2019-12-09 13:05:23 -03:00
Christoph Bülter
3a0f436c1a
Iterate a generator expression instead of a temporary list
...
Co-Authored-By: Bruno Oliveira <nicoddemus@gmail.com>
2019-12-06 08:40:49 +01:00
Christoph Buelter
ac5929eef3
Update docs about case-insensitive expression matching
2019-12-05 14:13:22 +01:00
Christoph Buelter
e24b6b0388
Change -k EXPRESSION matching to be case-insensitive
2019-12-05 14:03:10 +01:00
Bruno Oliveira
c7f9fda42d
Fix assertion rewriting module detection for egg dists
...
Fix #6301
2019-12-04 15:30:45 -03:00
Bruno Oliveira
985ac09048
Merge master into features ( #6312 )
...
Merge master into features
2019-12-03 13:36:58 -03:00
Bruno Oliveira
59f95b7f59
Merge remote-tracking branch 'upstream/master' into mm
2019-12-03 11:07:34 -03:00
Bruno Oliveira
41b7b109e9
Merge branch 'features' into unittest-debug
2019-12-03 10:52:53 -03:00
Bruno Oliveira
e5bd7fb053
Convert pytest.py into a package
...
As discussed in https://github.com/pytest-dev/pytest/issues/3342 , this
is the first step to make pytest support static typing fully
2019-12-02 19:27:11 -03:00
Ran Benita
16ff9f591e
Update mypy 0.740 -> 0.750
...
Release notes:
https://mypy-lang.blogspot.com/2019/11/mypy-0.html
2019-12-02 21:52:11 +02:00
Bruno Oliveira
172b82875a
Ensure cache supporting files still exist after --cache-clear
...
Fix #6290
2019-12-01 10:36:47 -03:00
Anthony Sottile
209d99102d
Merge pull request #6234 from asottile/remove_none_warning
...
Revert "A warning is now issued when assertions are made for `None`"
2019-11-26 13:04:42 -08:00
Daniel Hahler
a1219ab8fc
pytester: use no colors with inline runs by default
...
Sets `PY_COLORS=0` in the environment by default, which is used by pylib.
Via https://github.com/blueyed/pytest/pull/58
(initially cherry picked from commit f153ad33d10)
2019-11-25 23:48:11 +01:00
Claudio Madotto
31d5cedc6d
Avoid duplicating system-out and system-error tags
2019-11-25 12:59:03 +01:00
Claudio Madotto
b66dc80008
Fix for issue #5430 - junit-xml: logs are not passed to junit report for tests failed not in a teardown phase
2019-11-25 12:59:03 +01:00
Daniel Hahler
bc7282576f
typing: minor improvements
2019-11-24 23:20:03 +01:00
Daniel Hahler
d7d5cf4136
Merge pull request #6215 from blueyed/cleanup-exc
...
_idval: remove trailing newline from exception
2019-11-24 20:29:46 +01:00
Felix Yan
b7bc52f770
Correct a typo in _pytest/config/__init__.py
2019-11-24 20:28:10 +08:00
Ronny Pfannschmidt
c99c7d0f95
deprecate direct node construction and introduce Node.from_parent
2019-11-23 21:54:11 +01:00
Bruno Oliveira
886b8d27c6
Merge pull request #5984 from phloose/acceptance-tests_pytest-dev/pytest/#4445
...
Add acceptance tests for "config warnings" stacklevel (#4445 )
2019-11-22 19:45:41 -03:00
Daniel Hahler
b0ebcfb785
pytester: remove special handling of env during inner runs
...
Closes https://github.com/pytest-dev/pytest/issues/6213 .
2019-11-22 21:50:31 +01:00
Nikolay Kondratyev
5e097970df
Fix line detection for properties in doctest tests
...
Co-Authored-By: Daniel Hahler <github@thequod.de>
2019-11-22 23:50:20 +03: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
0601f5cdad
Merge pull request #6261 from blueyed/stats-keys
...
terminal: _get_main_color: help pytest-parallel
2019-11-22 17:12:33 +01:00
Daniel Hahler
1f736a663d
terminal: _get_main_color: help pytest-parallel
...
Use `dict.keys()` to work around `__iter__` not working with a
multiprocessing DictProxy.
Ref: https://github.com/python/cpython/pull/17333
Fixes https://github.com/pytest-dev/pytest/issues/6254 .
Ref: https://github.com/browsertron/pytest-parallel/issues/36
2019-11-22 05:48:10 +01:00
Daniel Hahler
2344982d7f
main: wrap_session: handle exit.Exception with notify_exception
...
Fixes https://github.com/pytest-dev/pytest/issues/6257 .
Via https://github.com/blueyed/pytest/pull/132 .
2019-11-21 22:50:33 +01:00
Daniel Hahler
df0c652333
Merge master into features
2019-11-21 20:31:52 +01:00
Mark Dickinson
2ffbe41ae5
clear sys.last_traceback via del instead of = None
2019-11-21 13:06:47 +00:00
Ran Benita
5820c5c5a6
Merge pull request #6241 from bluetech/type-annotations-9
...
Add type annotations to _pytest.config.argparsing and corresponding Config code
2019-11-21 13:33:13 +02:00
Daniel Hahler
b96e0a71a6
pytester: LineMatcher: __tracebackhide__ with _fail
...
Follow-up to 2228ccb
(gone lost in resolving the conflict).
2019-11-21 01:23:36 +01:00
Daniel Hahler
ed012c808a
Merge pull request #6174 from blueyed/ids-iter
...
parametrized: ids: support generator/iterator
2019-11-21 00:37:25 +01:00
Daniel Hahler
6b75a7733b
Merge pull request #6247 from blueyed/collecterror-fulltrace
...
Respect --fulltrace with collection errors
2019-11-21 00:27:23 +01:00
Daniel Hahler
2d449e95e4
Respect --fulltrace with collection errors
2019-11-20 23:35:33 +01:00
Ran Benita
dac16cd9e5
Add type annotations to _pytest.config.argparsing and corresponding Config code
2019-11-20 22:02:27 +02:00
Daniel Hahler
2c941b5d13
parametrized: ids: support generator/iterator
...
Fixes https://github.com/pytest-dev/pytest/issues/759
- Adjust test_parametrized_ids_invalid_type, create list to convert tuples
Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552922498
- Changelog for int to str conversion
Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552932952
2019-11-20 19:02:17 +01:00
Daniel Hahler
c0b1a39192
minor: move internal _pformat_dispatch function
2019-11-20 17:57:14 +01:00
Ran Benita
51f9cd0e02
argparsing: remove "map_long_option" Action attribute support
...
This feature was added in commit
007a77c2ba
, but was never used in pytest
itself. A GitHub code search doesn't find any users either (only pytest
repo copies). It seems safe to clean up.
2019-11-20 17:09:24 +02:00
Daniel Hahler
2228ccbfb4
pytester: reset log output in _match_lines ( #70 )
...
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.
(cherry picked from commit aade7ed0045ba32557ef8565cbab28a2c91053a7)
Ref: https://github.com/pytest-dev/pytest/pull/5914#issuecomment-549182242
2019-11-20 05:24:18 +01:00
Bruno Oliveira
5b3867fd65
Release 5.3.0 ( #6233 )
...
Release 5.3.0
2019-11-19 18:49:14 -03:00
Daniel Hahler
1d368e0ed4
Merge pull request #6231 from blueyed/param-spell
...
Improve check for misspelling of parametrize
2019-11-19 17:57:28 +01:00
Anthony Sottile
faea273c93
Revert "A warning is now issued when assertions are made for `None`"
2019-11-19 08:24:08 -08:00
Bruno Oliveira
21622d0df4
Merge remote-tracking branch 'upstream/master' into release-5.3.0
2019-11-19 12:42:11 -03:00
Daniel Hahler
4ad61cbcf6
Improve check for misspelling of parametrize
...
- there is no need to do this with `--strict-markers`
- it can be done when looking up marks, instead of for every generated
test
2019-11-19 16:05:52 +01:00
Daniel Hahler
d1e2d12b3f
python: remove unused pytest_make_parametrize_id hookimpl ( #6228 )
2019-11-19 02:55:24 +01:00
Daniel Hahler
4804d4bc98
python: remove unused pytest_make_parametrize_id hookimpl
...
Added in 79927428d
initially, but never used.
2019-11-19 02:27:53 +01:00
Daniel Hahler
b820b7e384
Merge pull request #6224 from blueyed/visit_Assert-minor-cleanup
...
minor: visit_Assert: move setting of `negation` out of branches
2019-11-19 01:11:53 +01:00
Anthony Sottile
eeeb19626b
Merge pull request #6202 from linw1995/fix_getmodpath
...
Fix incorrect result of getmodpath method.
2019-11-18 15:14:52 -08:00
Daniel Hahler
f38f2d402e
minor: visit_Assert: move setting of `negation` out of branches
2019-11-18 23:21:00 +01:00
Bruno Oliveira
89eeefbbaf
Merge pull request #6192 from nicoddemus/remove-reportlog-6180
...
Remove report_log in favor of pytest-reportlog
2019-11-18 17:58:37 -03:00
Daniel Hahler
2ad2fbc9a2
Metafunc: remove hack for DefinitionMock
...
Done initially in 99015bfc8
.
2019-11-18 18:19:34 +01:00
Daniel Hahler
64d8910516
Metafunc: remove unused _ids ( #6220 )
2019-11-18 18:00:29 +01:00
Daniel Hahler
91dec8e2bf
Factor out _validate_parametrize_spelling
...
This makes it easier to read `pytest_generate_tests`.
2019-11-18 16:36:12 +01:00
Daniel Hahler
f3a10245d0
Metafunc: remove unused _ids
...
Forgotten in 40b85d7ee
.
2019-11-18 16:21:13 +01:00
Daniel Hahler
426a4cdca9
_idval: remove trailing newline from exception
2019-11-18 01:10:00 +01:00
JoshKarpel
9e759010d9
resolve #2049
2019-11-17 16:45:42 -06:00
Anthony Sottile
a2d48332fc
Merge pull request #6201 from asottile/mm
...
Merge master into features
2019-11-17 11:30:51 -08:00
Ran Benita
fa578d7329
Merge pull request #6205 from bluetech/type-annotations-8
...
Add type annotations to _pytest.compat and _pytest._code.code
2019-11-17 09:45:32 +02:00
Ran Benita
eaa34a9df0
Add type annotations to _pytest._code.code
2019-11-16 22:29:57 +02:00
Daniel Hahler
54a954514b
re-run black
2019-11-16 18:55:32 +01:00
Daniel Hahler
b1a597ab02
Remove (now) unnecessary fmt: off
2019-11-16 18:51:02 +01:00
Daniel Hahler
786d839db1
cacheprovider: set: use json.dumps + write
...
``json.dump`` is slower since it iterates over chunks [1].
For 100 ``cache.set`` calls this saved ~0.5s (2.5s => 2s), using a dict
with 1500 entries, and an encoded size of 500kb.
Python 3.7.4.
1: https://github.com/blueyed/cpython/blob/1c2e81ed00/Lib/json/__init__.py#L177-L180
2019-11-16 17:40:56 +01:00
Ran Benita
562d4811d5
Add type annotations to _pytest.compat
2019-11-16 17:22:11 +02:00
Ran Benita
a649f157de
Make Source explicitly implement __iter__()
...
Source was previously iterable because it implements `__getitem__()`,
which is apparently a thing from before `__iter__()` was introduced.
To reduce mypy's and my own confusion, implement `__iter__()` directly.
2019-11-16 17:22:10 +02:00
Ran Benita
307add025b
Simplify a FormattedExcinfo test
...
The previous test was better in that it used fakes to test all of the
real code paths. The problem with that is that it makes it impossible to
simplify the code with `isinstance` checks. So let's just simulate the
issue directly with a monkeypatch.
2019-11-16 17:22:09 +02:00
Ran Benita
e3ac44df36
Inline the FuncargnamesCompatAttr compat helper
...
It doesn't help much IMO, just adds indirection and makes it harder to
type.
2019-11-16 17:22:09 +02:00
Ran Benita
04d68fbc9e
Remove checks for Python2-only fields im_func and func_code
2019-11-16 17:22:07 +02:00
Ran Benita
f760356578
A few linting fixes
...
Add some Python 3.8 type: ignores; all are already fixed in the next
mypy release, so can be removed once we upgrade.
Also move some flake8 ignores which seem to have changed places.
2019-11-16 17:22:06 +02:00
林玮
329f56ecec
Fix incorrect result of getmodpath method.
2019-11-16 15:28:04 +08:00
Anthony Sottile
cc78444c30
Merge remote-tracking branch 'origin/master' into mm
2019-11-15 15:26:57 -08:00
Daniel Hahler
c49c61fdaf
Import Path from _pytest.pathlib for py35 ( #6193 )
2019-11-15 23:17:43 +01:00
Daniel Hahler
5979837c60
Import Path from _pytest.pathlib for py35
...
This is important for `isinstance` checks etc.
2019-11-15 22:19:53 +01:00
Anthony Sottile
176c7771fb
Revert "fix bug with nonskipped first test in package ( #5831 )"
...
This reverts commit 85288b5321
, reversing
changes made to 5f9db8a017
.
2019-11-15 08:29:52 -08:00
Bruno Oliveira
d2ea9e2db5
Remove report_log in favor of pytest-reportlog
...
Fix #6180
2019-11-14 19:47:26 -03:00
Bruno Oliveira
99f487864c
Issue a warning to prepare change of 'junit_family' default val… ( #6186 )
...
Issue a warning to prepare change of 'junit_family' default value
2019-11-14 18:11:10 -03:00
Daniel Hahler
2fc7d04fc3
Merge pull request #6187 from blueyed/minor
...
Minor fixes
2019-11-14 00:45:54 +01:00
Bruno Oliveira
6f2c0fd2e8
Show a better message when 'request' is used in parametrize
...
Fix #6183
2019-11-13 19:57:10 -03:00
Bruno Oliveira
2a67637acc
Issue a warning to prepare change of 'junit_family' default value
...
Fix #6179
2019-11-13 19:55:13 -03:00
Daniel Hahler
772dfc4f9d
terminal: fix/remove wrong typing for currentfspath
...
Can be -2, or py.path.local (not typed).
2019-11-13 23:24:24 +01:00
Daniel Hahler
55bc084dcc
doc: s/_pytest.config.Parser/_pytest.config.argparsing.Parser/
2019-11-13 23:22:25 +01:00
Daniel Hahler
b3bb604683
fix typo in _issue_warning_captured doc
2019-11-13 23:22:25 +01:00
Daniel Hahler
f91bf48a40
Merge pull request #6176 from blueyed/assertoutcome
...
pytester: Hookrecorder: improve assertoutcome
2019-11-13 19:27:18 +01:00
Daniel Hahler
b06f33f474
terminal: report ``session.shouldfail`` reason (``-x``)
...
Via https://github.com/blueyed/pytest/pull/108 .
2019-11-13 16:18:41 +01:00
Daniel Hahler
6ddf7c3d42
pytester: Hookrecorder: improve assertoutcome
...
Before:
def assertoutcome(self, passed: int = 0, skipped: int = 0, failed: int = 0) -> None:
realpassed, realskipped, realfailed = self.listoutcomes()
assert passed == len(realpassed)
> assert skipped == len(realskipped)
E assert 1 == 0
E + where 0 = len([])
After:
> reprec = testdir.inline_run(testpath, "-s")
E AssertionError: ([], [], [<TestReport 'nodeid' when='call' outcome='failed'>])
E assert {'failed': 1, 'passed': 0, 'skipped': 0} == {'failed': 0, 'passed': 0, 'skipped': 1}
2019-11-13 13:48:20 +01:00
Daniel Hahler
e2022a6d48
pytester: assert_outcomes: use/set __tracebackhide__ ( #6172 )
2019-11-12 23:07:58 +01:00
Bruno Oliveira
59369651db
Bring back explicit tear down
...
Otherwise 'normal' failures won't call teardown explicitly
2019-11-12 14:03:40 -03:00
Bruno Oliveira
f7b1de70c0
No need to call tearDown on expected failures
...
- Isolate logic for getting expected exceptions
- Use original method name, as users see it when entering the debugger
2019-11-12 12:50:55 -03:00
Daniel Hahler
86e9ae39f0
pytester: assert_outcomes: use/set __tracebackhide__
2019-11-12 15:28:36 +01:00
Daniel Hahler
dad4985be1
A bit more typing around Node ( #6167 )
2019-11-12 14:46:05 +01:00
Ran Benita
b352e34938
Merge pull request #6149 from bluetech/cached-property
...
Add a @cached_property implementation
2019-11-10 22:11:04 +02:00
Daniel Hahler
3ef8aa8173
A bit more typing around Node
2019-11-10 19:06:27 +01:00
Daniel Hahler
abcedd6095
_compare_eq_iterable: use AlwaysDispatchingPrettyPrinter ( #6151 )
2019-11-10 14:08:25 +01:00
Ran Benita
42a46ea786
Add a @cached_property implementation
...
This is a useful utility to abstract the caching property idiom.
It is in compat.py since eventually it will be replaced by
functools.cached_property.
Fixes #6131 .
2019-11-10 10:21:55 +02:00
Daniel Hahler
04f27d4eb4
unittest: do not use TestCase.debug() with `--pdb`
...
Fixes https://github.com/pytest-dev/pytest/issues/5991
Fixes https://github.com/pytest-dev/pytest/issues/3823
Ref: https://github.com/pytest-dev/pytest-django/issues/772
Ref: https://github.com/pytest-dev/pytest/pull/1890
Ref: https://github.com/pytest-dev/pytest-django/pull/782
- inject wrapped testMethod
- adjust test_trial_error
- add test for `--trace` with unittests
2019-11-10 00:21:51 +01:00
Daniel Hahler
710e3c40e0
typing around terminal ( #6157 )
2019-11-10 00:19:11 +01:00
Daniel Hahler
0bbc032db0
[WIP] typing around terminal
2019-11-09 23:53:37 +01:00
Daniel Hahler
28edbaace4
showversion: no need for `py.path.local`
2019-11-09 21:45:35 +01:00
Bruno Oliveira
245e1f10e5
Merge pull request #6152 from grlee77/module_name_in_id
...
use __name__ attribute in the parametrize id for modules as well
2019-11-08 14:16:34 -03:00
Ran Benita
84b2c81db4
Drop the "alias" helper used in MarkDecorator
...
It is a little too obscure IMO, but the reason I want to drop it is that
type checking has no hope of understanding such dynamic constructs.
The warning argument wasn't used.
2019-11-08 11:22:46 +02:00
Ran Benita
984d90a811
Drop redundant custom MarkDecorator __eq__ implementation
...
This is already covered by attrs.
Also, the custom implementation returns False when the types don't
match, but it's better to return `NotImplemented`. attrs does this.
2019-11-08 11:14:31 +02:00
Gregory Lee
c22ce1a12c
parametrize: allow __name__ id for modules or other objects as well
2019-11-08 01:39:29 -05:00
Daniel Hahler
cc503c1821
_compare_eq_iterable: use AlwaysDispatchingPrettyPrinter
...
This fixes/removes the previous hack of re-trying with minimum width,
which fails short when it splits strings.
This inherits from `pprint.PrettyPrinter` to override `_format` in a
minimal way to always dispatch, regardless of the given width.
Code ref: 5c0c325453/Lib/pprint.py (L170-L178)
2019-11-08 04:07:09 +01:00
Bruno Oliveira
6ad95716da
add --co option to collect-only ( #6116 )
...
add --co option to collect-only
2019-11-07 19:03:32 -03:00
Bruno Oliveira
3b243404e6
Explicitly implement pytest_assertrepr_compare in assertion plu… ( #6140 )
...
Explicitly implement pytest_assertrepr_compare in assertion plugin
2019-11-07 18:45:26 -03:00
Daniel Hahler
09709bba06
Use atomicrewrites only on Windows ( #6148 )
2019-11-07 22:13:26 +01:00
Bruno Oliveira
7ed33996f1
on_rm_rf_error: ignore os.open (no warning) ( #6074 )
...
on_rm_rf_error: ignore os.open (no warning)
2019-11-07 18:06:05 -03:00
Bruno Oliveira
0cf2002a1f
Explicitly implement pytest_assertrepr_compare in assertion plugin
...
Previously it was an alias, which makes it unnecessary hard to find
all implementations (either by IDE or using a simple search).
2019-11-07 18:00:27 -03:00
NNRepos
4946cc8282
Add --co option to collect-only
...
Fix #5845
2019-11-07 17:50:27 -03:00
Daniel Hahler
45c4a8fb3d
Use atomicrewrites only on Windows
...
Fixes https://github.com/pytest-dev/pytest/issues/6147
2019-11-07 20:57:45 +01:00
Ran Benita
e670ff76cb
Merge pull request #6141 from bluetech/type-annotations-7
...
Add type annotations to _pytest.{warning_types,_code.source,pytester}
2019-11-07 17:11:01 +02:00
Daniel Hahler
f11237b066
_perform_collect: remove comment about untested code ( #6144 )
2019-11-07 13:18:08 +01:00
Ran Benita
265a9eb6a2
Add type annotations to some of _pytest.pytester
2019-11-07 14:13:47 +02:00
Ran Benita
58f2849bf6
Add type annotations to _pytest._code.source
...
At least most of it.
2019-11-07 14:13:47 +02:00
Ran Benita
b2537b22d7
Add type annotations to _pytest.warning_types
2019-11-07 14:11:39 +02:00
Daniel Hahler
2e5cf1cc78
Fix order of format args with warning
2019-11-07 12:50:04 +01:00
Daniel Hahler
8aa0809fbc
on_rm_rf_error: ignore os.open (no warning)
...
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
2019-11-07 12:50:04 +01:00
Daniel Hahler
ab101658f0
saferepr: handle BaseExceptions ( #6047 )
2019-11-07 12:33:22 +01:00
Daniel Hahler
b268463243
Merge master into features ( #6111 )
2019-11-07 12:31:33 +01:00
Daniel Hahler
dd852ded70
_perform_collect: remove comment about untested code
...
Harden one test where it is tested.
All tests testing this:
testing/acceptance_test.py:184(TestGeneralUsage::test_not_collectable_arguments)
testing/acceptance_test.py:373(TestGeneralUsage::test_direct_addressing_notfound)
testing/acceptance_test.py:403(TestGeneralUsage::test_issue134_report_error_when_collecting_member[test_fun.py::test_a])
testing/acceptance_test.py:420(TestGeneralUsage::test_report_all_failed_collections_initargs)
testing/test_config.py:1309(test_config_blocked_default_plugins[python])
(via https://github.com/blueyed/pytest/pull/88 )
2019-11-07 12:29:36 +01:00
Daniel Hahler
c4a110b20a
Session: collect: keep/use already parsed initialpart
...
Via https://github.com/blueyed/pytest/pull/42 .
2019-11-06 22:09:24 +01:00
Daniel Hahler
eb7a4e32ad
saferepr: handle BaseExceptions
...
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.
Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Daniel Hahler
fe429d4ce8
assert: fix _compare_eq_iterable: re-format both sides ( #6137 )
2019-11-06 22:06:39 +01:00
Bruno Oliveira
85288b5321
fix bug with nonskipped first test in package ( #5831 )
...
fix bug with nonskipped first test in package
2019-11-06 16:06:46 -03: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
Daniel Hahler
4e45472405
Merge master into features
...
Conflicts:
src/_pytest/debugging.py
2019-11-06 14:22:07 +01:00
Daniel Hahler
01769b141a
Merge pull request #6100 from blueyed/fix-skip-offset
...
terminal: fix line offset with skip reports
2019-11-06 13:29:40 +01:00
Daniel Hahler
9071a2a5e0
Merge pull request #6119 from blueyed/FSCollector-fspath
...
FSCollector: keep/use given fspath
2019-11-06 13:10:27 +01:00
Daniel Hahler
ce3d431002
assert: fix _compare_eq_iterable: re-format both sides
...
Follow-up to 946434c61
(#5924 ).
Before this patch the test would look like this:
{'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1}
Omitting 1 identical items, use -vv to show
Right contains 1 more item:
{'new': 1}
Full diff:
{
'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
- 'sub1': {'long_a': 'substring '
+ 'sub1': {'long_a': 'substring that gets wrapped'}}},
? +++++++++++++++++ ++++
+ 'new': 1,
- 'that '
- 'gets '
- 'wrapped'}}},
}
2019-11-06 11:23:15 +01:00
Daniel Hahler
e7320c6b54
Merge pull request #5926 from AtakamaLLC/optional-multiline
...
Add log-auto-indent option to control multiline formatting
2019-11-06 00:35:24 +01:00