Commit Graph

1134 Commits

Author SHA1 Message Date
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
Daniel Hahler c70ecd49ca cleanup: move terminal summary code to terminal plugin
Fixes https://github.com/pytest-dev/pytest/issues/5067.
2019-04-07 18:22:04 +02:00
Daniel Hahler b4b9f788af Support reportchars=A (really all, including passed) 2019-04-07 18:05:33 +02:00
Daniel Hahler a7e49e6c07 reportchars: fix/improve help message 2019-04-07 18:05:33 +02:00
Daniel Hahler 4fca86e2af testdir.popen: use kwargs with defaults for stdout/stderr 2019-04-06 12:13:48 +02:00
Daniel Hahler 9ad00714ba pytester: allow passing in stdin to run/popen 2019-04-06 12:13:28 +02:00
Daniel Hahler 377888140f Merge master into features
Conflicts:
	testing/test_pdb.py
2019-04-05 17:50:32 +02:00
Daniel Hahler df377b589f use wcwidth 2019-04-05 17:43:11 +02:00
Bruno Oliveira 87ce586d29
Merge pull request #5055 from blueyed/showhelp-lazy-fullwidth
showhelp: move tw.fullwidth out of the loop
2019-04-05 12:11:47 -03:00
Daniel Hahler e20b39d928 showhelp: move tw.fullwidth out of the loop 2019-04-05 15:14:02 +02:00
Bruno Oliveira 4f33f46a02
Merge pull request #5026 from blueyed/compare-len-diff
Display number of different items with sequence/dict comparisons
2019-04-05 08:53:48 -03:00
Daniel Hahler 159704421e change separator to hyphen 2019-04-05 12:21:24 +02:00
Daniel Hahler 0f965e57a2 changelog, fix branch coverage 2019-04-05 12:12:29 +02:00
Daniel Hahler 8011ff5bda Add _sys_snapshot fixture and use it with more tests 2019-04-05 11:55:23 +02:00
Jeffrey Rackauckas da3f836ee3 Added the junit_log_passing_tests ini flag. 2019-04-04 20:26:48 -07:00
Daniel Hahler 37ecca3ba9 factor out _get_line_with_reprcrash_message 2019-04-04 22:13:28 +02:00
Daniel Hahler 3d0ecd03ed Display message from reprcrash in short test summary
This is useful to see common patterns easily, but also for single
failures already.
2019-04-04 18:49:13 +02:00
Daniel Hahler eb5b2e0db5 Support glob argument with ``--cache-show`` 2019-04-04 18:10:39 +02:00
Daniel Hahler 47d92a0d96 Add tests and improve messages 2019-04-04 17:53:39 +02:00
Daniel Hahler 7f1bf44aa8 _compare_eq_dict: display number of different items 2019-04-04 17:16:21 +02:00
Daniel Hahler 5fec793bc7 _compare_eq_sequence: display number of extra items 2019-04-04 17:16:21 +02:00
Bruno Oliveira e04936fc29
Merge pull request #5042 from blueyed/merge-regen-master-into-features
Merge master into features (with regen)
2019-04-04 10:44:30 -03:00
Daniel Hahler 0d4636b056
Merge pull request #5034 from blueyed/run-last-failure-report
run-last-failure: improve reporting
2019-04-04 00:40:40 +02:00
Daniel Hahler a65edf6711
Merge pull request #5028 from blueyed/fix-wrap_session-exit-code
wrap_session: restore old behavior for initstate=1
2019-04-04 00:39:38 +02:00
Daniel Hahler 757ada2fd2 pdb: try to import --pdbcls in pytest_configure only
Fixes https://github.com/pytest-dev/pytest/issues/5039.
2019-04-03 22:35:18 +02:00
Daniel Hahler e88aa957ae
Merge pull request #4854 from blueyed/pdb-skip
pdb: add option to skip `pdb.set_trace()`
2019-04-03 22:25:38 +02:00
Daniel Hahler 8907fedc79 Merge master into features (with regen branch) 2019-04-03 22:11:00 +02:00
Daniel Hahler 1f5a61e4ef run-last-failure: improve reporting 2019-04-03 16:27:12 +02:00
Daniel Hahler d91527599a pytester: use monkeypatch with Testdir 2019-04-03 15:02:53 +02:00
Daniel Hahler 7538aa7bb9 minor: check_interactive_exception: use Skipped 2019-04-03 11:45:45 +02:00
Daniel Hahler 9434541090 doc: mention that pytest.fixture's param is in request.param 2019-04-03 11:45:45 +02:00
Daniel Hahler cc90bcce4c wrap_session: restore old behavior for initstate=1 2019-04-03 05:09:21 +02:00
Bruno Oliveira 15ea5cef46
Merge pull request #4943 from blueyed/remove-silence_logging_at_shutdown
capture: do not set logging.raiseExceptions = False
2019-04-02 22:46:15 -03:00
Daniel Hahler 32a8d503a2
Merge pull request #5005 from blueyed/essential_plugins
Split out list of essential plugins
2019-04-03 02:45:19 +02:00
Daniel Hahler 8c734dfc2f Split out list of essential plugins
Fixes https://github.com/pytest-dev/pytest/issues/4976.
2019-04-02 14:39:56 +02:00
Daniel Hahler 08ded2927a capture: do not set logging.raiseExceptions = False
Ref: https://github.com/pytest-dev/pytest/issues/4942
2019-04-02 13:20:39 +02:00
Zac Hatfield-Dodds cab4069f42 Clarify mark.__getattr__ 2019-04-02 12:31:42 +11:00
Zac Hatfield-Dodds 4f6c67658c Use mark-specific warning type
So that we can ignore it in self-tests.
2019-04-01 12:38:33 +11:00
Zac Hatfield-Dodds 9121138a1b Emit warning for unknown marks 2019-04-01 10:40:18 +11:00
Zac-HD ba1fc02a9b Register mark used by pytester 2019-03-31 14:22:30 +11:00
Zac-HD 38d687f7c7 Fix typos in comments 2019-03-31 14:22:30 +11:00
Bruno Oliveira 278b289f37
Merge pull request #4968 from blueyed/pdb-do_debug-quit
pdb: do not raise outcomes.Exit with quit in debug
2019-03-29 16:22:02 -03:00
Daniel Hahler e7ade066b6
Merge pull request #5011 from blueyed/merge-master-into-features
Merge master into features
2019-03-29 18:35:13 +01:00
Daniel Hahler adebfd0a84 pdb: add option to skip `pdb.set_trace()` 2019-03-29 11:13:38 +01:00
Daniel Hahler 4e931b258d Merge master into features 2019-03-29 11:05:46 +01:00
Daniel Hahler 4011021823 pdb: do not raise outcomes.Exit with quit in debug 2019-03-29 11:02:34 +01:00
Daniel Hahler bfda2a0050 setup.cfg: use existing [tool:pytest] (ignoring [pytest]) 2019-03-29 10:59:27 +01:00
Bruno Oliveira 6b5cddc48a
Merge pull request #4951 from blueyed/fix-pdb-capfix
pdb: handle capturing with fixtures only
2019-03-28 20:34:28 -03:00
Gary Tyler 403f556928 Update docs for 'pytest_cmdline_parse' hook to note availability liminations 2019-03-28 19:25:55 -04:00
Bruno Oliveira d8ef86aadf
Merge pull request #4993 from blueyed/stepwise-report
stepwise: report status via pytest_report_collectionfinish
2019-03-28 20:24:18 -03:00
Bruno Oliveira a9fe1e159a
Merge pull request #4965 from nicoddemus/serialization-hooks
Serialization hooks
2019-03-28 20:22:19 -03:00
Bruno Oliveira 65c8e8a09e Rename hooks: to/from_serializable 2019-03-28 13:41:56 -03:00
Daniel Hahler 63a01bdb33 Factor out pytestPDB._is_capturing 2019-03-28 11:49:01 +01:00
Daniel Hahler 951213ee09 Use new suspend/resume in global_and_fixture_disabled 2019-03-28 11:49:01 +01:00
Daniel Hahler 40718efacc Fix/revisit do_continue with regard to conditions 2019-03-28 11:49:01 +01:00
Daniel Hahler d406786a8d pdb: handle capturing with fixtures only 2019-03-28 11:49:01 +01:00
Daniel Hahler d17ea7a9c0 tests: ensure cleanup with configs via get_config()
Also done in test_pluginmanager, although no resource warnings are
there at least.

Fixes https://github.com/pytest-dev/pytest/issues/4355.
2019-03-28 00:14:13 +01:00
Daniel Hahler c92021fc4f
Merge pull request #5003 from blueyed/off
Fix off-by-one error with lineno in mark collection error
2019-03-28 00:09:53 +01:00
Daniel Hahler 50a5cebba8
Merge pull request #5002 from blueyed/report
skipping: factor out _get_pos, pass only config to _get_report_str
2019-03-27 23:07:11 +01:00
Daniel Hahler 76c70cbf4c Fix off-by-one error with lineno in mark collection error 2019-03-27 17:44:52 +01:00
Jeong YunWon 8b0b7156d9 Fix glitches of original patch of disable-test-id-escaping 2019-03-28 00:07:28 +09:00
ApaDoctor cf6e2ceafd add ini option to disable string escape for parametrization 2019-03-28 00:07:28 +09:00
Bruno Oliveira 241b7433cd
Merge pull request #4978 from blueyed/exit-from-from_assertrepr_compare
Do not swallow outcomes.Exit in assertrepr_compare
2019-03-26 18:39:13 -03:00
Bruno Oliveira 057c97812b
Merge pull request #4975 from blueyed/verbose-fixes
Fix usages of "verbose" option
2019-03-26 18:38:39 -03:00
Bruno Oliveira 02188e399d
Merge pull request #4987 from blueyed/collect-tbstyle-repr_failure
CollectError.repr_failure: honor explicit tbstyle option
2019-03-26 18:37:49 -03:00
Daniel Hahler 538efef1ba logging: close log_file_handler
While it should be closed in logging's shutdown [1], the following would
still issue a ResourceWarning:

```
import logging

log_file_handler = logging.FileHandler("temp.log", mode="w", encoding="UTF-8")

root_logger = logging.getLogger()
root_logger.addHandler(log_file_handler)
root_logger.removeHandler(log_file_handler)
root_logger.error("error")

del log_file_handler
```

It looks like the weakref might get lost for some reason.

See https://github.com/pytest-dev/pytest/pull/4981/commits/92ffe42b45 / #4981
for more information.

1: c1419578a1/Lib/logging/__init__.py (L2107-L2139)
2019-03-26 18:24:19 +01:00
Bruno Oliveira 9311d822c7 Fix assertion in pytest_report_unserialize 2019-03-26 12:47:31 -03:00
Daniel Hahler 351529cb50 skipping: factor out _get_pos, pass only config to _get_report_str 2019-03-26 16:29:16 +01:00
Daniel Hahler 94a2e3dddc stepwise: report status via pytest_report_collectionfinish 2019-03-26 13:20:33 +01:00
Daniel Hahler e1ae469504 Merge master into features 2019-03-26 10:23:21 +01:00
Daniel Hahler 0d00be4f4f Do not swallow outcomes.Exit in assertrepr_compare 2019-03-26 10:20:00 +01:00
Daniel Hahler 23146e7527 Fix usages of "verbose" option
With `-qq` `bool(config.getoption("verbose"))` is True; it needs to be
checked for `> 0`.
2019-03-26 10:11:25 +01:00
Daniel Hahler 4148663706
Merge pull request #4979 from blueyed/minor
Minor: whitespace, typo, docs
2019-03-26 10:01:13 +01:00
Bruno Oliveira 2d77018d1b Improve coverage for _report_unserialization_failure 2019-03-25 20:16:59 -03:00
Bruno Oliveira ceef0af1ae Improve coverage for to_json() with paths in reports 2019-03-25 20:16:59 -03:00
Bruno Oliveira f2e0c740d3 Code review suggestions 2019-03-25 20:16:59 -03:00
Bruno Oliveira d856f4e51f Make sure TestReports are not collected as test classes 2019-03-25 20:16:59 -03:00
Bruno Oliveira 7b9a414524 Add pytest_report_serialize and pytest_report_unserialize hooks
These hooks will be used by pytest-xdist and pytest-subtests to
serialize and customize reports.
2019-03-25 20:16:59 -03:00
Bruno Oliveira 0c63f99016 Add experimental _to_json and _from_json to TestReport and CollectReport
This methods were moved from xdist (ca03269).

Our intention is to keep this code closer to the core, given that it
might break easily due to refactorings.

Having it in the core might also allow to improve the code by moving
some responsibility to the "code" objects (ReprEntry, etc) which
are often found in the reports.

Finally pytest-xdist and pytest-subtests can use those functions
instead of coding it themselves.
2019-03-25 20:16:59 -03:00
Daniel Hahler b53bf44139
Merge pull request #4985 from blueyed/assert-from_current
ExceptionInfo.from_current: assert current exception
2019-03-25 23:28:58 +01:00
Daniel Hahler 51f64c2920
Merge pull request #4980 from blueyed/fixup_namespace_packages
monkeypatch.syspath_prepend: call fixup_namespace_packages
2019-03-25 23:10:00 +01:00
Bruno Oliveira cea42ff9e4 Docs: modules implementing pytest_cmdline_parse can be early-loaded
Related to #4974
2019-03-25 18:43:06 -03:00
Daniel Hahler de44293d59 CollectError.repr_failure: honor explicit tbstyle option 2019-03-24 11:24:19 +01:00
Daniel Hahler d44e42ec15 doc: improve warning_record_to_str 2019-03-24 11:20:01 +01:00
Daniel Hahler aa0b657e58 Add Session.__repr__ 2019-03-24 11:02:58 +01:00
Daniel Hahler 2d690b83bf ExceptionInfo.from_current: assert current exception 2019-03-23 00:29:36 +01:00
Daniel Hahler 56dc01ffe0 minor: revisit _possibly_invalidate_import_caches 2019-03-22 17:02:26 +01:00
Daniel Hahler 5df45f5b27 Use fixup_namespace_packages also with pytester.syspathinsert 2019-03-22 17:02:26 +01:00
Daniel Hahler 475119988c monkeypatch.syspath_prepend: call fixup_namespace_packages
Without the patch the test fails as follows:

            # Prepending should call fixup_namespace_packages.
            monkeypatch.syspath_prepend("world")
    >       import ns_pkg.world
    E       ModuleNotFoundError: No module named 'ns_pkg.world'
2019-03-22 15:29:08 +01:00
Daniel Hahler 5c26ba9cb1 minor: wrap_session: s/Spurious/unexpected/ 2019-03-22 13:23:44 +01:00
Bruno Oliveira b3319a6074
Merge pull request #4944 from henrykironde/k-EXPRESSION
Add example for k flag
2019-03-21 19:33:53 -03:00
Daniel Hahler 15d608867d
Merge pull request #4966 from blueyed/fix-preparse
config: fix consider_preparse with missing argument to -p
2019-03-21 19:12:57 +01:00
Daniel Hahler ea2c6b8a88 config: fix consider_preparse with missing argument to -p
This is only required after/with 415899d4 - otherwise argparse ensures
there is an argument already.
2019-03-21 17:05:22 +01:00
Daniel Hahler 553951c443 Fix some issues related to "-p no:X" with default_plugins 2019-03-21 17:01:50 +01:00
Daniel Hahler cc6e5ec345 tests: add test_report_collect_after_half_a_second
This is meant for stable coverage with "collecting X item(s)".
2019-03-20 22:13:11 +01:00
Daniel Hahler bcdbb6b677 Revisit mkdir/_ensure_supporting_files in cacheprovider
- cacheprovider: move call to _ensure_supporting_files

  This makes it less likely to have a race here (which is not critical),
  but happened previously probably with xdist, causing flaky coverage with
  `if not readme_path.is_file():` etc checks in
  `_ensure_supporting_files`, which has been removed in the `features`
  branch already.
2019-03-20 19:00:11 +01:00
Daniel Hahler 7939e5327c
Merge pull request #4957 from blueyed/config-handle-pno-with-default-plugins
config: handle `-p no:plugin` with default plugins
2019-03-20 03:32:03 +01:00
Daniel Hahler f7171034f9 terminal: remove unnecessary check in _get_progress_information_message
All calls to _get_progress_information_message are only done for
`_show_progress_info`, which is `False` with `capture=no`.
2019-03-20 03:04:41 +01:00
Daniel Hahler c7c120fba6 terminal: handle "capture" option not being available
This is the case with `-p no:capture` now.
2019-03-20 03:01:26 +01:00
Daniel Hahler 415899d428 config: handle `-p no:plugin` with default plugins
`-p no:capture` should not load its fixtures in the first place.
2019-03-20 02:47:13 +01:00
Daniel Hahler 8dda5613ef
Merge pull request #4956 from blueyed/home2
pytester: set HOME only with inline_run/popen
2019-03-20 02:29:29 +01:00