Commit Graph

1134 Commits

Author SHA1 Message Date
Bruno Oliveira acdf30a523 Fix all() unroll for non-generators/non-list comprehensions
Fix #5358
2019-06-02 12:12:14 -03:00
Anthony Sottile cafb13c95f Fix `pytest.mark.parametrize` when the argvalue is an iterator 2019-06-01 15:09:17 -07:00
Anthony Sottile fb3ae5eaa9 Merge remote-tracking branch 'origin/master' into mm 2019-05-30 20:23:38 -07:00
Bruno Oliveira c8d23c206b
logging: Improve formatting of multiline message (#5312)
logging: Improve formatting of multiline message
2019-05-30 21:42:41 -03:00
Victor Maryama 65bd1b8a93 Avoiding looking upwards for parameter argnames when generating fixtureinfo. 2019-05-30 23:42:04 +02:00
Daniel Hahler ace3a02cd4 pytester: factor out testdir._env_run_update 2019-05-30 17:39:44 +02:00
Daniel Hahler f013a5e8c1 pytester: use temporary HOME with spawn
Followup to https://github.com/pytest-dev/pytest/issues/4956.
2019-05-30 17:39:44 +02:00
Bruno Oliveira fbd8ff9502
Merge master into features (#5339)
Merge master into features
2019-05-30 12:21:51 -03:00
Bruno Oliveira 5cbc06a453 Show test module in the PytestCollectionWarning message
Related to #5330
2019-05-30 08:18:28 -03:00
Daniel Hahler da23aa3419 pytester: remove unused winpymap
Follow-up to c86d2daf8.
2019-05-30 08:09:49 +02:00
Daniel Hahler 6765aca0d1 Merge master into features 2019-05-30 06:33:04 +02:00
Daniel Hahler 61dfd0a94f pdb: move/refactor initialization of PytestPdbWrapper 2019-05-30 03:00:07 +02:00
Bruno Oliveira b10f28949d
Add the junit_log_passing_tests ini flag to skip logging output for passing tests. (#5052)
Add the junit_log_passing_tests ini flag to skip logging output for passing tests.
2019-05-29 20:56:13 -03:00
Daniel Hahler ff80464b47 last-failed: display skipped-files msg always 2019-05-29 23:32:52 +02:00
Daniel Hahler 480dd9e6d6 last_failed_paths: improve caching 2019-05-29 23:28:58 +02:00
Daniel Hahler ceb4f3f701 fixup! Fix regression with --lf and non-selected failures 2019-05-29 23:24:52 +02:00
Thomas Hisch ea3ebec117 logging: Improve formatting of multiline message 2019-05-29 23:21:14 +02:00
Daniel Hahler bf3b26b3f7 Fix regression with --lf and non-selected failures 2019-05-29 22:44:43 +02:00
Thomas Hisch 84569ca4da
Merge pull request #5311 from thisch/coloredcaplog
Use same code for setting up cli/non-cli formatter
2019-05-29 22:18:43 +02:00
Bruno Oliveira 5bc3ad8e27
minor: getbasetemp: dedent, improve assert (#5327)
minor: getbasetemp: dedent, improve assert
2019-05-28 19:59:43 -03:00
Thomas Hisch d4b85da8c7 Use same code for setting up cli/non-cli formatter
A method _create_formatter was introduced that is used for both the
log_cli_formatter and the log_formatter.

Consequences of this commit are:
* Captured logs that are output for each failing test are formatted
  using the ColoredLevelFromatter.
* The formatter used for writing to a file still uses the non-colored
  logging.Formatter class.
2019-05-28 21:30:34 +02:00
Daniel Hahler 97d8e9fbec minor: getbasetemp: dedent, improve assert 2019-05-28 18:26:10 +02:00
Daniel Hahler 220a2a1bc9 Remove _pytest.compat.NoneType 2019-05-28 18:16:18 +02:00
Daniel Hahler e032904413 Merge master into features 2019-05-28 01:46:16 +02:00
Bruno Oliveira 2b9ca34280
Unroll calls to any #5062 (#5103)
Unroll calls to any #5062
2019-05-27 20:17:44 -03:00
Anthony Sottile 13f02af97d Switch to importlib-metadata 2019-05-27 13:24:08 -07:00
Daniel Hahler f2ed796c41 pdb: import pdbcls lazily
Fixes https://github.com/pytest-dev/pytest/issues/2064.
2019-05-26 15:56:38 +02:00
Anthony Sottile b3f8fabac8
Merge pull request #5308 from blueyed/minor
Minor fixes
2019-05-25 21:58:39 -07:00
Tomer Keren 22d91a3c3a Unroll calls to all on python 2 2019-05-25 19:34:08 +03:00
Tomer Keren 322a0f0a33 Fix mention of issue #5062 in docstrings 2019-05-25 19:34:08 +03:00
Tomer Keren 58149459a5 Mark visit_all as a private method 2019-05-25 19:34:08 +03:00
Tomer Keren 437d6452c1 Expand list comprehensions as well 2019-05-25 19:34:08 +03:00
Tomer Keren e37ff3042e Check calls to all only if it's a name and not an attribute 2019-05-25 19:34:08 +03:00
Tomer Keren ecd2de25a1 Revert "Displaying pip list command's packages and versions #5062"
This reverts commit 043fdb7c4065e5eb54f3fb5776077bb8fd651ce6.
These tests were part of the PR #5155 but weren't relevant to #5602
2019-05-25 19:34:08 +03:00
danielx123 0996f3dbc5 Displaying pip list command's packages and versions #5062 2019-05-25 19:34:08 +03:00
Tomer Keren 470e686a70 Rewrite unrolled assertion with a new rewriter,correctly append the unrolled for loop 2019-05-25 19:34:08 +03:00
Tomer Keren 765f75a8f1 Replace asserts of `any` with an assert in a for 2019-05-25 19:34:08 +03:00
Daniel Hahler 10ca84ffc5
Merge pull request #5119 from blueyed/reportopts-A-order
reportopts: A: put "Pp" in front
2019-05-24 18:28:43 +02:00
Thomas Hisch bed3918cbc Revert "logging: Simple impl of multline pretty printing"
This reverts commit 31dfbb4668.
2019-05-24 09:11:03 +02:00
Thomas Hisch 31dfbb4668 logging: Simple impl of multline pretty printing 2019-05-24 09:09:09 +02:00
Bruno Oliveira b4d75ad31d
Merge pull request #5091 from blueyed/showhelp-ini-options
Improve output of ini options in --help
2019-05-23 21:10:43 -03:00
Daniel Hahler fa8a658458
Merge pull request #4908 from blueyed/pdb-pm-enter-hook
pdb: trigger pytest_enter_pdb hook with post-mortem
2019-05-24 01:50:24 +02:00
Bruno Oliveira 66f20b6f5e
Fix invalid Python file encoding "utf8" (#5252)
Fix invalid Python file encoding "utf8"
2019-05-23 20:24:23 -03:00
Daniel Hahler 6c56070df1
Merge pull request #5278 from blueyed/disable-python-plugin
Allow disabling of python plugin
2019-05-23 15:52:19 +02:00
Daniel Hahler f9f41e69a8 reportopts: A: put "Pp" in front 2019-05-23 09:40:16 +02:00
Daniel Hahler b2ce6f3200 Improve output of ini options in --help
Do not cut long help texts, but wrap them the same way as argparse wraps
the other help items.
2019-05-23 09:33:07 +02:00
Daniel Hahler e0b584d048 CaptureFixture: do not crash in _suspend when not started
This happened in test_pdb_with_caplog_on_pdb_invocation.
2019-05-23 09:09:53 +02:00
Daniel Hahler a0ff5deabf pdb: trigger pytest_enter_pdb hook with post-mortem
This is required for pytest-pdb to be called with `--pdb`.

TODO:

- [ ] test
- [ ] pass mode to hook, e.g. "post_mortem" in this case?
2019-05-23 09:09:53 +02:00
Akiomi Kamakura a304dbb519 Fix `disable_test_id_escaping_and_forfeit_all_rights_to_community_support` option when using a list of test IDs 2019-05-21 09:48:22 +09:00
Daniel Hahler d19df5efa2 importorskip: display/include ImportError
This can provide useful information, e.g.

> could not import 'pyrepl.readline': curses library not found
2019-05-20 14:13:33 +02:00
Tim Hoffmann b27e40cbf1 Fix documentation of pytest.raises(match=...) 2019-05-19 16:01:48 +02:00
Daniel Hahler 93fd9debe3 Allow disabling of python plugin
Fixes https://github.com/pytest-dev/pytest/issues/5277.
2019-05-17 18:17:14 +02:00
Bruno Oliveira e253029ad0 Handle lone surrogate unicode character not being representable in Jython
No tests for this because we don't test with Jython currently.

Fix #5256
2019-05-16 17:59:31 -03:00
Anthony Sottile dc75b6af47 Use fix-encoding-pragma pre-commit hook 2019-05-14 15:56:31 -07:00
Bruno Oliveira 7573747cda Normalize all source encoding declarations 2019-05-14 19:42:44 -03:00
Anthony Sottile 4318698bae Remove 'b' from sys.stdout.mode 2019-05-14 15:00:59 -07:00
Bruno Oliveira 465b2d998a
Further "unknown marks warning" improvements (#5178)
Further "unknown marks warning" improvements
2019-05-11 13:28:10 -03:00
Bruno Oliveira 73bbff2b74 Introduce record_testsuite_property fixture
This exposes the functionality introduced in fa6acdc as a session-scoped fixture.

Plugins that want to remain compatible with the `xunit2`
standard should use this fixture instead of `record_property`.

Fix #5202
2019-05-10 19:44:27 -03:00
Bruno Oliveira 685ca96c71 Change ``--strict`` to ``--strict-markers``, preserving the old one
Fix #5023
2019-05-09 19:36:38 -03:00
Bruno Oliveira ccf6c3cb46 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2019-05-09 19:22:40 -03:00
Daniel Hahler 0b8b006db4 minor: improve formatting 2019-05-09 15:36:49 +02:00
Daniel Hahler 73b74c74c9 pdb: only use outcomes.exit via do_quit
Fixes https://github.com/pytest-dev/pytest/issues/5235.
2019-05-09 14:55:55 +02:00
Daniel Hahler 5eeb5ee960
Merge pull request #5013 from blueyed/short-summary-message
Display message from reprcrash in short test summary
2019-05-08 22:01:04 +02:00
Pulkit Goyal 7e08e09473 logging: improve default logging format (issue5214)
We improve the following things in the logging format:

  * Show module name instead of just the filename
  * show level of logging as the first thing
  * show lineno attached to module:file details

Thanks to @blueyed who suggested this on the github issue.

It's my first contribution and I have added myself to AUTHORS.

I also added to a changelog file.
2019-05-08 21:37:59 +03:00
Bruno Oliveira c04767f946
Use msg.rstrip() as suggested in review 2019-05-07 15:20:00 -03:00
Bruno Oliveira 6d040370ed Show fixture scopes with ``--fixtures``, except for "function" scope
Fix #5220
2019-05-07 14:32:20 -03:00
Anthony Sottile d1a48ad68f Use exec directly 2019-05-06 23:07:39 -07:00
Bruno Oliveira d3686361ba Fix linting 2019-05-07 00:52:40 +00:00
Peter Schutt 8605ed2a15
Update python_api.py 2019-05-07 10:10:25 +10:00
Peter Schutt 8b34d981fc
Clarify docs for pytest.raises `match`.
For #5208.

Document explicit behavior of `match` and brief note on how to handle matching a string that may contain special re chars.
2019-05-07 09:56:13 +10:00
Bruno Oliveira 784e1e3b7e Add links to pytest.raises `message` workaround
Related to #3974
2019-05-06 12:35:27 -03:00
Bruno Oliveira 4a2fdce62b
Emit a warning for record_property when used with xunit2 (#5204)
Emit a warning for record_property when used with xunit2
2019-05-05 21:33:31 -03:00
Bruno Oliveira 32a5e80a6d Add encoding: header and fix rep mock in test_line_with_reprcrash on py27 2019-05-05 09:33:37 -03:00
Bruno Oliveira 8f23e19bcb Emit a warning for record_property when used with xunit2
"property" elements cannot be children of "testsuite" according to the schema, so it is incompatible with xunit2

Related to #5202
2019-05-05 09:01:13 -03:00
Bruno Oliveira 9f66102869 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2019-05-04 10:47:57 -03:00
Daniel Hahler 865e84d206
Merge pull request #5109 from blueyed/summary_passes-green
summary_passes: use bold green for report headers
2019-05-04 00:46:23 +02:00
DamianSkrzypczak 1bd7d287a7 doc: fix hooks 'path' parameter doc type
by changing it from str to py.path.local
(#5171)
2019-05-02 20:51:11 +02:00
Allan Lewis f050203f5d
Improve help for --runxfail flag
The help for the '--runxfail' flag is somewhat misleading. The default
behaviour is to run tests marked as 'xfail' but to ignore the results. This
flag alters that behaviour by running these tests as if they weren't marked
'xfail', i.e. their results are not ignored.
2019-05-01 10:04:32 +01:00
Bruno Oliveira 3f5622c577
Use config_invocation_dir for startdirs (#5151)
Use config_invocation_dir for startdirs
2019-04-29 18:14:51 -03:00
Bruno Oliveira 1fb3f63f35
debugging: rename internal wrapper for pdb.Pdb (#5186)
debugging: rename internal wrapper for pdb.Pdb
2019-04-29 18:03:32 -03:00
Bruno Oliveira fc2ad1dbed
Warning subclasses (#5179)
Warning subclasses
2019-04-29 17:57:49 -03:00
Bruno Oliveira fb6dad60a0
terminal: use pytest_collection_finish for reporting (#5113)
terminal: use pytest_collection_finish for reporting
2019-04-29 08:00:48 -03:00
Daniel Hahler 02053bf556 debugging: rename internal wrapper for pdb.Pdb
This is useful/clearer in case of errors / tracebacks - i.e. you see
clearly that it is coming from pytest.
2019-04-29 05:46:21 +02:00
Daniel Hahler ff5317a7f3 terminal: use pytest_collection_finish for reporting 2019-04-29 05:20:04 +02:00
Bruno Oliveira 08734bdd18 --lf now skips colletion of files without failed tests
Fix #5172
2019-04-28 20:23:46 -03:00
Bruno Oliveira 9742f11d37 Removed unused warning message 2019-04-28 11:06:47 -03:00
Bruno Oliveira 53cd7fd2ea Introduce new warning subclasses
Fix #5177
2019-04-28 10:38:25 -03:00
Bruno Oliveira 8532e991a5 Publish UnknownMarkWarning as part of the public API and docs 2019-04-28 10:16:07 -03:00
Daniel Hahler 65133018f3 Terminal plugin is not semi-essential anymore
Thanks to https://github.com/pytest-dev/pytest/pull/5138.
2019-04-27 03:39:00 +02:00
Daniel Hahler 308b733b9d Revert "Merge pull request #4854 from blueyed/pdb-skip"
This reverts commit e88aa957ae, reversing
changes made to 1410d3dc9a.

I do not think it warrants an option anymore, and there is a way to
achieve this via `--pdbcls` if needed.
2019-04-27 02:25:38 +02:00
Daniel Hahler 7f519f8ab7 Merge master into features 2019-04-27 00:43:00 +02:00
Daniel Hahler 0bf363472e Use config_invocation_dir for startdirs
`Session.startdir` and `TerminalReporter.startdir` appear to be
redundant given `Config.invocation_dir`.
Keep them for backward compatibility reasons, but use
`config.invocation_dir` for them.
2019-04-22 02:05:59 +02:00
Nikolay Kondratyev bc00d0f7db Fix handle repr error with showlocals and verbose output 2019-04-19 18:54:21 +03:00
Daniel Hahler e3e57a755b
Merge pull request #5083 from blueyed/capture-_suspended
capture: store _state
2019-04-19 17:32:54 +02:00
Daniel Hahler 698c4e75fd capture: track current state in _state attributes
This is meant for debugging, and making assertions later.
2019-04-19 00:35:15 +02:00
Daniel Hahler 649d23c8a8 pytest_sessionfinish: preset exitstatus with UsageErrors
Previously it would be 0.  Setting it to the expected outcome
(EXIT_USAGEERROR) here already helps `pytest_sessionfinish` hooks.
2019-04-18 23:18:59 +02:00
Daniel Hahler 1460ad6027
Merge pull request #5111 from blueyed/deselect_by_keyword-skip
deselect_by_keyword: skip without expression
2019-04-17 23:20:02 +02:00
Daniel Hahler 78cd1a07d0
Merge pull request #5140 from blueyed/rewrite-name
assertion rewriting: use actual helper name
2019-04-17 23:19:38 +02:00
Ilya Konstantinov d67d68f6d3 Eliminate core dependency on 'terminal' plugin 2019-04-17 11:19:19 -07:00
Daniel Hahler df1d1105b0 Merge remote-tracking branch 'origin/features' into short-summary-message
Conflicts:
	src/_pytest/skipping.py
2019-04-17 15:30:19 +02:00
Daniel Hahler 2b11b2c093
Merge pull request #5126 from blueyed/report-get_verbose_word
terminal/reports: use get_verbose_word method
2019-04-17 14:43:54 +02:00
Daniel Hahler adb8edbae1 assertion rewriting: use actual helper name
This makes it easier / possible to grep.
2019-04-17 14:41:34 +02:00
Anthony Sottile 3cff5e252d
Merge pull request #5117 from blueyed/cov-terminal
Minor coverage improvements for terminal plugin
2019-04-15 14:30:18 -07:00
Daniel Hahler 7412df0920 fixup! terminal: summary_errors: replace if with assert 2019-04-15 22:53:31 +02:00
Bruno Oliveira df68808d29
Merge pull request #5116 from blueyed/cov-pytester
Minor coverage improvements for pytester
2019-04-15 14:49:28 -03:00
Bruno Oliveira b64d9402ca
Merge pull request #5108 from blueyed/summary
terminal summary: display passes after warnings
2019-04-15 14:49:01 -03:00
Bruno Oliveira 24bd51bda0
Merge pull request #5131 from blueyed/_getfailureheadline
_getfailureheadline: get head_line property only once
2019-04-15 12:23:41 -03:00
Daniel Hahler 9374114370 terminal/reports: add/use _get_verbose_word method 2019-04-15 17:06:18 +02:00
Daniel Hahler eb13530560 _getfailureheadline: get head_line property only once 2019-04-15 17:04:51 +02:00
Daniel Hahler 5530d3e15d
Merge pull request #5120 from blueyed/minor
A collection of minor code tweaks
2019-04-15 16:32:20 +02:00
Daniel Hahler ea79eb5c3f terminal summary: display passes after warnings
This displays passes (with output, `-rP`) before the short summary, and
before any other output from other plugins also.
2019-04-15 16:31:42 +02:00
Bruno Oliveira c8b904a406
Merge pull request #5124 from blueyed/terminal-summary_failures
terminal: revisit summary_failures
2019-04-15 11:26:52 -03:00
Bruno Oliveira d45fa7b212
Merge pull request #5123 from blueyed/clsname
TestReport: use class name in repr
2019-04-15 11:25:42 -03:00
Daniel Hahler 45ba736c81
Merge pull request #5128 from blueyed/mark-is
Fix error message with unregistered markers
2019-04-15 16:23:54 +02:00
Daniel Hahler cc005af47e Fix error message with unregistered markers 2019-04-15 10:15:37 +02:00
Daniel Hahler 20c624efcf terminal: revisit summary_failures
- get the list of reports for teardown sections only once
- do not check option in loop
2019-04-15 06:47:51 +02:00
Daniel Hahler b2be6c1a30 TestReport: use class name in repr 2019-04-15 05:47:45 +02:00
Daniel Hahler c43a9c83ee doc: pytest_deselected: not only via keywords 2019-04-14 23:53:06 +02:00
Daniel Hahler e804e419bc remove unnecessary newline 2019-04-14 23:53:06 +02:00
Daniel Hahler 992e7f7771 rename variable 2019-04-14 23:53:06 +02:00
Daniel Hahler bd1a2e6435 fix typo 2019-04-14 23:53:06 +02:00
Daniel Hahler 1d137fd2fe minor: LFPlugin: de-indent code by returning if not active 2019-04-14 23:53:06 +02:00
Daniel Hahler 6f0a5789fb Merge master into features 2019-04-14 23:22:21 +02:00
Daniel Hahler cc78a533ae terminal: summary_errors: replace if with assert 2019-04-14 23:17:27 +02:00
Daniel Hahler fd0b3e2e8b getreportopt: remove needless if 2019-04-14 23:17:27 +02:00
Daniel Hahler f3dbe5a308 pytester: listoutcomes: assert instead of implicit if 2019-04-14 23:00:38 +02:00
Daniel Hahler 1da8ce65a6 pytester: raise_on_kwargs: ignore branch coverage 2019-04-14 23:00:38 +02:00
Daniel Hahler 6a73714b00 deselect_by_keyword: skip without expression
There is no need to iterate over all items always, if `-k` is not
specified.
2019-04-14 19:01:33 +02:00
Daniel Hahler 6371243c10 summary_passes: use bold green for report headers 2019-04-14 15:21:11 +02:00
Daniel Hahler 8fd5a658eb monkeypatch.syspath_prepend: invalidate import cache
This was done with testdir only, and uses the fixed monkeypatch method
there now.
2019-04-13 16:15:44 +02:00
Anthony Sottile 43e7401c91 Produce a warning when unknown arguments are passed to pytest.param() 2019-04-12 13:00:39 -07:00
Anthony Sottile da2e092163 pre-commit autoupdate 2019-04-12 04:52:47 -07:00
Bruno Oliveira 19035f4b55
Merge pull request #5068 from blueyed/reportchars
Add support for reportchars=A (`-rA`)
2019-04-12 08:13:22 -03:00
Bruno Oliveira 14d3d9187f Remove partial unicode characters from summary messages in Python 2 2019-04-11 19:01:21 -03:00
Samuel Searles-Bryant a37d1df089 Show XFail reason as part of JUnitXML message field
Fixes #4907
2019-04-11 22:26:05 +01:00
Daniel Hahler 8b2fcf517c Merge master 2019-04-11 13:28:36 +02:00
Daniel Hahler b3759372ad
Merge pull request #5082 from blueyed/pytester-raise_on_kwargs
pytester: improve/fix kwargs validation
2019-04-11 00:46:18 +02:00
Bruno Oliveira f5d2b199e2
Merge pull request #5069 from blueyed/cleanup-summary-to-terminal
cleanup: move terminal summary code to terminal plugin
2019-04-10 19:32:01 -03:00
Daniel Hahler 5d9d12a6be pytester: improve/fix kwargs validation 2019-04-10 21:57:45 +02:00
Daniel Hahler 10fa66e5b5
Merge pull request #5059 from blueyed/pytester-popen-run-stdin
pytester: allow passing in stdin to run/popen
2019-04-10 20:32:22 +02:00
Bruno Oliveira 5e26304d81
Merge pull request #5075 from blueyed/console_output_style
terminal: console_output_style: document "count" with help
2019-04-09 20:54:12 -03:00
Bruno Oliveira d0860a339b
Merge pull request #5076 from blueyed/_show_progress_info
terminal: store console_output_style in _show_progress_info
2019-04-09 20:37:50 -03:00
Daniel Hahler ec46864922 run: pass through stdin, just close then 2019-04-10 00:02:38 +02:00
Daniel Hahler c36a90531a Move CLOSE_STDIN to class 2019-04-10 00:01:15 +02:00
Daniel Hahler a70e5f119e terminal: store console_output_style in _show_progress_info
Avoids ini lookups.
2019-04-08 04:34:26 +02:00
Daniel Hahler b6b7185b7b terminal: console_output_style: document "count" with help 2019-04-08 04:32:53 +02:00
Daniel Hahler ff5e98c654 Change noqa comment to pragma 2019-04-08 03:48:42 +02:00
Daniel Hahler 2662c400ba dedent 2019-04-07 20:04:31 +02:00
Daniel Hahler d8d835c1f5 minor: use functools.partial 2019-04-07 19:49:18 +02:00
Daniel Hahler 06029d11d3 Refactor into TerminalReporter.short_test_summary 2019-04-07 19:49:18 +02:00