Bruno Oliveira
e3643751bc
Merge pull request #7144 from nicoddemus/async-testcase-7110
2020-05-01 16:44:10 -03:00
Bruno Oliveira
fd2f172258
Let unittest frameworks deal with async functions
...
Instead of trying to handle unittest-async functions in pytest_pyfunc_call,
let the unittest framework handle them instead.
This lets us remove the hack in pytest_pyfunc_call, with the upside that
we should support any unittest-async based framework.
Also included 'asynctest' as test dependency for py37-twisted, and renamed
'twisted' to 'unittestextras' to better reflect that we install 'twisted' and
'asynctest' now.
This also fixes the problem of cleanUp functions not being properly called
for async functions.
Fix #7110
Fix #6924
2020-05-01 15:10:28 -03:00
Bruno Oliveira
7f5978c34c
Allow File.from_parent to forward custom parameters to the constructor
2020-05-01 11:00:52 -03:00
Ran Benita
a718ad6363
Stop using Python's eval() for -m and -k
...
Previously, the expressions given to the `-m` and `-k` options were
evaluated with `eval`. This causes a few issues:
- Python keywords cannot be used.
- Constants like numbers, None, True, False are not handled correctly.
- Various syntax like numeric operators and `X if Y else Z` is supported
unintentionally.
- `eval()` is somewhat dangerous for arbitrary input.
- Can fail in many ways so requires `except Exception`.
The format we want to support is quite simple, so change to a custom
parser. This fixes the issues above, and gives us full control of the
format, so can be documented comprehensively and even be extended in the
future if we wish.
2020-05-01 12:59:06 +03:00
Ran Benita
e40bf1d1da
Add a changelog for TerminalWriter changes
2020-04-30 16:44:03 +03:00
Ran Benita
907e29a47b
fixtures: deprecate pytest._fillfuncargs function
...
This function is exposed and kept alive for the oejskit plugin which is
abandoned and no longer works with recent plugins, so let's prepare to
completely remove it.
2020-04-24 18:54:46 +03:00
Katarzyna Król
7789b51acb
Issue 4677 - always relative path in skip report ( #6953 )
2020-04-17 08:28:36 +03:00
Simon K
de6c28ed1f
Improve error handling around yieldctx fixtures which do not yield a value ( #7083 )
2020-04-15 12:17:13 +03:00
Simon K
6fd30134d3
Update changelog/4583.bugfix.rst
...
Co-Authored-By: Ran Benita <ran@unusedvar.com>
2020-04-13 14:29:59 +01:00
symonk
87edc09dea
Gracefully handle eval() failure(s) for marker expressions
2020-04-13 13:25:06 +01:00
Ronny Pfannschmidt
19c243f0fa
Merge pull request #6285 from earonesty/patch-1
...
Add _pytest.fixtures.FixtureLookupError to top level import
2020-04-10 07:58:58 +02:00
Ronny Pfannschmidt
c5d636a1b2
Merge pull request #6992 from pytest-dev/revert-6767-tmpdir-cleanup-upstream
...
Revert "tmpdir: clean up indirection via config for factories"
2020-04-10 07:49:52 +02:00
Ronny Pfannschmidt
1eb2b45db5
Revert "tmpdir: clean up indirection via config for factories ( #6767 )"
...
This reverts commit 8a1633c3b4
.
+ add changelog
2020-04-10 07:18:54 +02:00
Daniel Hahler
20f6331afd
Fix TerminalRepr instances to be hashable ( #6988 )
...
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 .
2020-04-03 00:56:53 +02:00
Ronny Pfannschmidt
2d9dac95ec
Merge pull request #6927 from RonnyPfannschmidt/fix-6924-run-async-stdlib-unittests
...
running stdlib asyncio unittests again
2020-03-30 22:34:17 +02:00
Ronny Pfannschmidt
451aef65ac
prepare tests and disable warnings for asyncio unittest cases
...
shoehorn unittest async results into python test result interpretation
changelog
2020-03-30 21:55:12 +02:00
Ronny Pfannschmidt
f1d51ba1f5
deprecate the pytest.collect module
...
changelog
minimal unittest for collect module deprecations
\!fixup - changelog typo
2020-03-30 21:53:07 +02:00
Ronny Pfannschmidt
eab2831671
fix #6951 : allow to write TerminalReporter.writer
2020-03-30 21:31:53 +02:00
smarie
95fadd5740
Improved time counter used to compute test durations. ( #6939 )
...
Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
Co-authored-by: Ran Benita <ran@unusedvar.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-03-29 15:20:09 +03:00
Daniel Hahler
1fda861190
Fix crash when printing while capsysbinary is active
...
Previously, writing to sys.stdout/stderr in text-mode (e.g.
`print('foo')`) while a `capsysbinary` fixture is active, would crash
with:
/usr/lib/python3.7/contextlib.py:119: in __exit__
next(self.gen)
E TypeError: write() argument must be str, not bytes
This is due to some confusion in the types. The relevant functions are
`snap()` and `writeorg()`. The function `snap()` returns what was
captured, and the return type should be `bytes` for the binary captures
and `str` for the regular ones. The `snap()` return value is eventually
passed to `writeorg()` to be written to the original file, so it's input
type should correspond to `snap()`. But this was incorrect for
`SysCaptureBinary`, which handled it like `str`.
To fix this, be explicit in the `snap()` and `writeorg()`
implementations, also of the other Capture types.
We can't add type annotations yet, because the current inheritance
scheme breaks Liskov Substitution and mypy would complain. To be
refactored later.
Fixes: https://github.com/pytest-dev/pytest/issues/6871
Co-authored-by: Ran Benita (some modifications & commit message)
2020-03-16 18:21:33 +02:00
Bruno Oliveira
010e711971
Merge pull request #6914 from nicoddemus/revert-6330
...
Revert "[parametrize] enforce explicit argnames declaration (#6330 )"
2020-03-13 10:49:48 -03:00
Bruno Oliveira
2eedf9c2aa
Merge pull request #6910 from nicoddemus/resultlog-logreport
...
Handle unknown stats in pytest_report_teststatus hook
2020-03-13 09:30:04 -03:00
Ran Benita
6e70fecbe4
Merge pull request #6903 from bluetech/assume-dup
...
Assume os.dup is always available
2020-03-13 11:01:44 +02:00
Bruno Oliveira
0c58ed2cc0
Handle unknown stats in pytest_report_teststatus hook
...
Noticed that the pytest_report_teststatus of reportlog was not properly
handling unknown statuses while taking a look at:
https://github.com/pytest-dev/pytest-rerunfailures/issues/103
2020-03-12 20:52:22 -03:00
Ran Benita
6954b3b0dc
Assume os.dup is always available
...
The commit which added the checks for os.dup a15afb5e48
suggests it was done for Jython. But pytest doesn't support Jython
anymore (Jython is Python 2 only).
Furthermore, it looks like the faulthandler plugin (bundled in pytest
and enabled by default) uses os.dup() unprotected and there have not
been any complaints.
So seems better to just remove these checks, and only add if someone
with a legitimate use case complains.
2020-03-12 16:47:15 +02:00
pytest bot
c9fd1bdbd6
Preparing release version 5.4.0
2020-03-12 14:14:35 +00: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
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
Bruno Oliveira
a03e076e89
Update changelog/6285.feature.rst
...
Co-Authored-By: Ran Benita <ran234@gmail.com>
2020-03-03 09:59:38 -03:00
earonesty
0f00495548
Create 6285.feature.rst
2020-03-03 09:59:38 -03: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
ff7b5dbbde
Merge pull request #6784 from nicoddemus/deprecate-terminal-writer
...
Deprecate TerminalReporter.writer
2020-02-28 21:07:02 -03:00
Daniel Hahler
4b53bbc0a9
docs: use doc/en/_build/html for html output ( #6842 )
...
This will use the same directory as `make -C doc/en` then, and reflects
the default location that Sphinx uses.
2020-02-29 00:47:30 +01: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
Daniel Hahler
ac3a42bafd
doctest: strip newlines with unexpected exceptions ( #6801 )
2020-02-24 15:18:08 +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
kpinc
eeebcd77dd
doc: add list of fixtures to start of fixture chapter ( #6696 )
...
- Add list of fixtures to start of fixture chapter
- Add "fixture" cross ref type
2020-02-22 14:56:19 +01:00
Daniel Hahler
2277817176
Fix grammar in changelog/6737.breaking.rst
2020-02-22 13:15:17 +01:00
Bruno Oliveira
435ad221f9
Deprecate TerminalReporter.writer
...
Fix #6779
2020-02-20 21:04:49 -03:00
Daniel Hahler
1b30514783
LFPlugin: use sub-plugins to deselect during collection ( #6448 )
...
Fixes https://github.com/pytest-dev/pytest/issues/5301 .
Refactor/steps:
- use var
- harden test_lastfailed_usecase
- harden test_failedfirst_order
- revisit last_failed_paths
- harden test_lastfailed_with_known_failures_not_being_selected
2020-02-19 21:33:03 +01:00
Daniel Hahler
f95c7f5803
doctest: handle any OutcomeException ( #6669 )
...
Fixes using `pytest.xfail()` and `pytest.importorskip()` in doctests.
Ref: https://github.com/pytest-dev/pytest/issues/310
2020-02-19 13:16:37 +01:00
Daniel Hahler
369284752e
terminal: refactor, no yellow ("boring") for non-last item ( #6409 )
2020-02-15 19:00:24 +01:00
Daniel Hahler
e872532d0c
Merge branch 'master' into term-color
...
Conflicts:
src/_pytest/terminal.py
testing/test_debugging.py
testing/test_terminal.py
2020-02-15 18:46:29 +01:00
kpinc
9785ee438d
doc: expand first sentence on fixtures into a paragraph ( #6742 )
2020-02-15 18:35:36 +01:00
Ran Benita
d839686c7b
Don't delete FixtureDef.cached_result, set it to None instead
...
Previously `cached_result` was either set or deleted. Type annotations
cannot handle this, so use `None` for the non-set state instead.
2020-02-14 14:18:58 +02:00
Bruno Oliveira
e6ea9edffe
Merge pull request #6673 from sscherfke/features
...
Reverse / fix meaning of "+/-" in error diffs
2020-02-12 15:05:38 -03:00
Ran Benita
c9f9664336
Merge branch 'features' into master
...
The features branch is no more. Development of features is now also done
on master.
See https://github.com/pytest-dev/pytest/pull/6571 .
2020-02-12 13:50:02 +02:00
Bruno Oliveira
4209ad6fca
Use code highlighting if pygments is installed ( #6658 )
...
* Use code highlighting if pygments is installed
* Use colorama constants instead of bare ascii codes
Could not find the exact equivalent of 'hl-reset' code using colorama
constants though.
* Refactor ASCII color handling into a fixture
* Revert back to using explicit color codes
* In Python 3.5 skip rest of tests that require ordered markup in colored output
2020-02-12 08:32:37 -03:00
Bruno Oliveira
3ea74310d7
Fix crash when faulthandler starts initialized ( #6598 )
...
Use suggestion in review and use a subplugin so hooks will only be active
if we enable faulthandler ourselves.
Fix #6575
Co-authored-by: Daniel Hahler <git@thequod.de>
2020-02-12 11:06:20 +01: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
Stefan Scherfke
d59adc61f9
Reverse / fix meaning of "+/-" in error diffs
...
The convention is "assert result is expected". Pytest's error diffs now
reflect this. "-" means that sth. expected is missing in the result and
"+" means that there are unexpected extras in the result.
Fixes : #3333
2020-02-10 21:12:37 +01:00
Daniel Hahler
a8fc056aad
Handle `Exit` exception in `pytest_sessionfinish` ( #6660 )
2020-02-07 00:40:10 +01:00
Vladyslav Rachek
9e262038c8
[parametrize] enforce explicit argnames declaration ( #6330 )
...
Every argname used in `parametrize` either must
be declared explicitly in the python test function, or via
`indirect` list
Fix #5712
2020-02-06 20:20:25 -03:00
Daniel Hahler
39d9f7cff5
pytester: LineMatcher: typing, docs, consecutive line matching ( #6653 )
2020-02-04 22:47:18 +01:00
Daniel Hahler
aa0328782f
assertion: save/restore hooks on item ( #6646 )
2020-02-04 02:56:23 +01:00
Daniel Hahler
75714ee707
pluginmanager.consider_preparse: add exclude_only kwarg ( #6443 )
...
Plugins specified with ``-p`` are now loaded after internal plugins, which
results in their hooks being called *before* the internal ones.
This makes the ``-p`` behavior consistent with ``PYTEST_PLUGINS``.
* fix/adjust test_disable_plugin_autoload
* adjust test_plugin_loading_order
2020-02-03 14:10:54 +01:00
Daniel Hahler
99d162e44a
Handle `Exit` exception in `pytest_sessionfinish`
...
Similar to a7268aa
(https://github.com/pytest-dev/pytest/pull/6258 ).
2020-02-02 23:13:23 +01:00
Daniel Hahler
5256542ea4
pytester.LineMatcher: add support for matching lines consecutively
2020-02-01 23:48:58 +01:00
Bruno Oliveira
70739296e1
Remove deprecated 'pytest_itemstart' hook
...
This hook has been deprecated/removed for more than 10 years
in a2fe6714f8
.
2020-01-30 21:03:29 -03: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
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
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
Daniel Hahler
30922ee694
Merge master into features
2020-01-28 01:40:14 +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
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
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
cdd6f86e43
bug-fix fixes
2020-01-23 20:34:21 +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
Bruno Oliveira
6a26ac4125
Preparing release version 5.3.4
2020-01-20 13:53:31 -03:00
Bruno Oliveira
0dc82e8501
Add CHANGELOG entry for #6496
2020-01-20 13:32:27 -03:00
Bruno Oliveira
56dc301c50
Preparing release version 5.3.3
2020-01-16 18:55:41 -05: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
83813bf515
Merge master into features
...
Conflicts:
.github/workflows/main.yml
2020-01-16 19:45:52 +01:00
Bruno Oliveira
9298f7e4a9
Improve CHANGELOG and docs for junit_logging
2020-01-16 07:47:00 -03: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
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
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
5b295ec68e
Merge remote-tracking branch 'upstream/features' into gftea/features
2020-01-09 18:41:47 -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
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
1c0242dec1
Fix `RunResult.parseoutcomes` (follow-up to #6353 )
2019-12-30 17:08:52 +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