Commit Graph

1134 Commits

Author SHA1 Message Date
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
Daniel Hahler 714f2113bb
Merge pull request #4929 from blueyed/fix-_factorytraceback-offset
Fix line offsets with `ScopeMismatch` errors
2019-03-20 01:30:58 +01:00
Daniel Hahler a50b92ea67 pytester: set HOME only with inline_run/popen
Ref: https://github.com/pytest-dev/pytest/issues/4955
2019-03-20 01:15:51 +01:00
Daniel Hahler da81c1e49a
Merge pull request #4950 from blueyed/capture
Revisit capturing module: repr, doc fixes, minor
2019-03-20 01:12:22 +01:00
Bruno Oliveira 23ab43233e
Merge pull request #4920 from nicoddemus/subtests-pytest-1367
Internal refactorings required for *external* pytest-subtests plugin
2019-03-19 18:57:11 -03:00
Bruno Oliveira 1a119a22d1 Internal refactorings in order to support the new pytest-subtests plugin
Related to #1367
2019-03-19 18:20:41 -03:00
Daniel Hahler 7395501d1d Easier read with _colorama_workaround/_readline_workaround 2019-03-19 01:17:21 +01:00
Daniel Hahler 920bffbfbb Revisit _pytest.capture: repr, doc fixes, minor 2019-03-19 01:17:21 +01:00
Daniel Hahler 751c061d9a Merge master into features 2019-03-19 01:07:10 +01:00
Daniel Hahler a624b84097
Merge pull request #4941 from blueyed/testdir-home
pytester: testdir: set $HOME to tmpdir
2019-03-18 23:02:15 +01:00
Daniel Hahler c75dd10671 pytester: testdir: set $HOME to tmpdir
This avoids loading user configuration, which might interfere with test
results, e.g. a `~/.pdbrc.py` with pdb++.

Also sets USERPROFILE, which will be required with Python 3.8 [1].

1: https://bugs.python.org/issue36264
2019-03-18 20:55:39 +01:00
henrykironde 1e3d5a0412 Add example for k flag
Includes an example of multiple expressions
2019-03-17 22:33:16 -04:00
Daniel Hahler 98981276a0 capture: fix FDCapture.__repr__ without targetfd_save 2019-03-18 02:33:03 +01:00
Daniel Hahler 15fe8c6e90 Handle `-p plug` after `-p no:plug`.
This can be used to override a blocked plugin (e.g. in "addopts") from the
command line etc.
2019-03-16 15:58:00 +01:00
Daniel Hahler 5e27ea5528 pytester: LineMatcher: assert Sequence when matching in order
This can be helpful when passing a set accidentally.
2019-03-15 23:07:08 +01:00
Bruno Oliveira 33d4c96aa2
Merge pull request #4830 from nicoddemus/warn-on-coroutine
Emit a warning when a coroutine test function is encountered
2019-03-15 09:51:34 -03:00
Daniel Hahler 95701566f3
Update src/_pytest/outcomes.py
Co-Authored-By: tkf <takafumi.a@gmail.com>
2019-03-15 12:21:48 +09:00
Daniel Hahler 57be1d60dd
Apply suggestions from code review
Co-Authored-By: tkf <takafumi.a@gmail.com>
2019-03-15 11:29:16 +09:00
Takafumi Arakaki 62f96eea6b Include documentation 2019-03-15 11:14:50 +09:00
Daniel Hahler d441fa66fe Fix line offsets with `ScopeMismatch` errors
Fixes https://github.com/pytest-dev/pytest/issues/4928.
2019-03-15 02:47:33 +01:00
Takafumi Arakaki 43aee15ba3 Make pytest.skip work in doctest 2019-03-15 10:20:46 +09:00
Daniel Hahler 7afe17740f Merge master into features 2019-03-15 00:52:12 +01:00
Bruno Oliveira 40072b9511 Emit a warning when a async def function is not handled by a plugin
Fix #2224
2019-03-14 20:22:23 -03:00
Daniel Hahler 520af9d767 pdb: post_mortem: use super()
This is good practice in general, and I've seen it cause problems (MRO)
with pdb++.
2019-03-14 22:29:57 +01:00
Daniel Hahler 4d21dc4f2d Optimize TracebackEntry.ishidden
The expected behavior is that there is no "__tracebackhide__" attribute,
so use `getattr` instead of multiple try/except.
2019-03-14 01:02:46 +01:00
Bruno Oliveira 44cb51010c Improve CHANGELOG and code comment 2019-03-13 18:52:30 -03:00
Bruno Oliveira b7ae7a654b Remove callspec related block of code
It seems this is no longer required now that we don't support
yield tests anymore. The param attribute was added here:

91b6f2bda8/_pytest/python.py (L888-L891)
2019-03-12 20:10:59 -03:00
Bruno Oliveira 148e6a30c8 Improve coverage 2019-03-12 20:10:59 -03:00
Bruno Oliveira 47bd1688ed Remove dead-code related to yield tests
Just noticed some code that no longer is needed when we removed yield-tests
2019-03-12 20:10:59 -03:00
Bernhard M. Wiedemann 489c61a22d Allow tests to pass after 2038
without this change, the python-apache-libcloud tests failed
in the year 2039 with

     fp.write(struct.pack("<ll", mtime, size))
 E   error: 'l' format requires -2147483648 <= number <= 2147483647
2019-03-10 05:22:21 +01:00
Stephan Hoyer dc7ae41f33
Fix broken error message in pytester 2019-03-08 09:22:00 -08:00
Daniel Hahler de5aa3847e
Apply suggestions from code review
Co-Authored-By: nicoddemus <nicoddemus@gmail.com>
2019-03-07 12:53:47 -03:00
Bruno Oliveira 0f4905a259 Simplify 'obj' property definition in PyobjMixin
This uses modern property definition syntax, declaring both getter
and setter as obj() functions
2019-03-07 08:15:04 -03:00
Daniel Hahler c86d2daf81 pytester: remove unused anypython fixture
This became unused after ab9f6a75 (in 2009).
2019-03-06 17:42:21 +01:00
Daniel Hahler 236bada755
Merge pull request #4768 from horta/avoid-pkg_resources
Avoid pkg_resources import at the top-level.
2019-03-05 23:02:02 +01:00
Daniel Hahler 76687030f0 Merge branch 'master' into merge-master-into-features
Conflicts:
	appveyor.yml
	setup.py
2019-03-05 19:07:36 +01:00
Bruno Oliveira 23ea04f910
Merge pull request #4860 from nicoddemus/getfixturevalue-cleanup-1895
getfixturevalue does not correctly declare dependency with the calling fixture
2019-03-03 15:56:45 -03:00
Bruno Oliveira 0deb7b1696 Do not show "inifile:" string if there's no configuration file 2019-03-02 11:45:08 -03:00
Bruno Oliveira 53b8aa065c Show testpaths option in the header if it has been used for collection
Fix #4875
2019-03-02 11:35:32 -03:00
Bruno Oliveira 6a2d122a50 Remove code debugging leftovers 2019-03-02 09:56:15 -03:00
Bruno Oliveira 7dceabfcb2 Ensure fixtures obtained with getfixturevalue() are finalized in the correct order
Fix #1895
2019-03-02 09:36:16 -03:00
Daniel Hahler e1f97e41e3
Merge pull request #4872 from blueyed/_ensure_supporting_files
cacheprovider: _ensure_supporting_files: remove unused branches
2019-03-02 02:35:07 +01:00
Daniel Hahler 2d2f6cd4fd cacheprovider: _ensure_supporting_files: remove unused branches
It is only called with empty/new dirs since 0385c273.
2019-03-01 22:51:45 +01:00
Daniel Hahler 4290cacb86
Merge pull request #4864 from blueyed/isort-cfg
Add config for isort
2019-03-01 18:44:56 +01:00
Daniel Hahler db5cc35b44 pytester: unset PYTEST_ADDOPTS 2019-03-01 18:43:17 +01:00
Bruno Oliveira 84555c89de
Merge pull request #4855 from blueyed/pdbcls-attr
--pdbcls: improve validation, and allow for "mod:attr.class"
2019-03-01 12:20:29 -03:00
Daniel Hahler f7a3e001f7 pdb: allow for --pdbclass=mod:attr.class 2019-03-01 15:20:04 +01:00
Daniel Hahler 0d31e852b1 Run isort 2019-03-01 14:24:18 +01:00
Daniel Hahler 9cb71af9e5 _pytest.assertion.rewrite: move _format_explanation import 2019-03-01 14:13:28 +01:00
Daniel Hahler a51dc0c7ce Validate type with writing to captured output like without
Fixes https://github.com/pytest-dev/pytest/issues/4861.
2019-03-01 14:03:51 +01:00
Daniel Hahler a868a9ac13 pdb: validate --pdbcls option 2019-02-28 18:11:58 +01:00
Bruno Oliveira a0207274f4 -p option now can be used to early-load plugins by entry-point name
Fixes #4718
2019-02-24 13:20:17 -03:00
Andras Mitzki b26b731498 Logging: Make pytest_runtest_logreport() available for logging
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
2019-02-22 05:14:44 +01:00
Bruno Oliveira 0395996756 Merge remote-tracking branch 'upstream/master' into release-4.3.0 2019-02-16 14:06:51 +00:00
Bruno Oliveira 986dd84375
LoggingPlugin: Support to customize log_file from hook (#4752)
LoggingPlugin: Support to customize log_file from hook
2019-02-16 12:01:21 -02:00
Anthony Sottile 68dc433bf5
Merge pull request #4802 from gyermolenko/fix_code_block_in_Node_docstring
Fix code-block in Node docstring
2019-02-15 20:09:32 -05:00
Daniel Hahler 6fb7269979 terminal: write_fspath_result: work around py bug 2019-02-15 17:47:00 +01:00
Andras Mitzki e3824d23bc LoggingPlugin: Expose setting log_file_handler
- This patch allows to set log_file (path) from hook

Signed-off-by: Thomas Hisch
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
2019-02-15 16:05:10 +01:00
Grygorii Iermolenko 80ad448590 Fix code-block in Node docstring 2019-02-15 16:12:10 +02:00
Daniel Hahler 0b1f813c38
Merge pull request #4784 from blueyed/fix-4782
collect: python: fix `AssertionError` with broken symlinks
2019-02-14 15:10:14 +01:00
R. Alex Matevish 40cec637d7 Update kwarg for attr.ib to use 'converter' as 'convert' is due to be deprecated 2019-02-14 00:03:41 -08:00
Daniel Hahler 407d4a0cf0 collect: python: fix `AssertionError` with broken symlinks
Fixes https://github.com/pytest-dev/pytest/issues/4782.
2019-02-14 00:18:14 +01:00
Daniel Hahler 7b91952645 Merge master into features
Conflicts:
	tox.ini
2019-02-13 17:58:16 +01:00
Anthony Sottile f672b7e39e
Merge pull request #4773 from nicoddemus/remove-py27-py34-deprecation-warning
Remove py27 py34 deprecation warning
2019-02-12 21:42:07 -05:00
Anthony Sottile f0e6bf7604
Merge pull request #4775 from asottile/stdlib
Replace flatten() with chain.from_iterable
2019-02-12 21:37:05 -05:00
Bruno Oliveira e20e376881
Merge pull request #4347 from blueyed/pdb-recursive-capture
pdbpp: fix capturing with recursive debugging
2019-02-12 16:53:14 -02:00
Anthony Sottile f9c1329dab Replace flatten() with chain.from_iterable
flatten is an alias in more-itertools anyway
2019-02-12 06:30:00 -08:00
Bruno Oliveira b41632e9a8 Revert "Show deprecation message when running under Python 2.7 and 3.4"
This reverts commit eb92e57509.
2019-02-12 10:39:25 -02:00
Danilo Horta 821b6ef2a6 Avoid pkg_resources import at the top-level. 2019-02-11 23:26:35 +00:00
Bruno Oliveira 67dd10de26
Merge pull request #4763 from blueyed/lsof
--lsof: suppress stderr
2019-02-11 13:18:40 -02:00
Daniel Hahler f13935da53 Display --help/--version with ArgumentErrors 2019-02-11 15:49:48 +01:00
Daniel Hahler 61b9246afe Fix/improve handling of pkg init and test file via args
Ref: https://github.com/pytest-dev/pytest/issues/4344#issuecomment-441095934
2019-02-11 15:04:24 +01:00
Daniel Hahler 9feb4941f4 pdb: fix capturing with recursive debugging and pdb++
While I think that pdb++ should be fixed in this regard (by using
`pdb.Pdb`, and not `self.__class__` maybe), this ensures that custom
debuggers like this are working.
2019-02-11 14:52:20 +01:00
Daniel Hahler 237f690f8b --lsof: suppress stderr
This can spam a lot of warnings (per invocation), e.g.:

> lsof: WARNING: can't stat() nsfs file system /run/docker/netns/default
        Output information may be incomplete.

Or from Travis/MacOS:

> lsof: WARNING: can't stat() vmhgfs file system /Volumes/VMware Shared Folders
>       Output information may be incomplete.
>       assuming "dev=31000003" from mount table
2019-02-11 14:08:44 +01:00
Daniel Hahler ed01dc6567
Merge pull request #4652 from blueyed/RunResult-repr
Add __repr__ for RunResult
2019-02-09 01:26:24 +01:00
Bruno Oliveira 3a366f451a
Merge pull request #4741 from thisch/refactor_terminalreporter
Remove terminal_reporter workaround from logging.py
2019-02-08 21:47:53 -02:00
Daniel Hahler fc8800c71f
Merge pull request #4722 from fetzerch/ignore_wildcards
Add ability to use globs when using --ignore
2019-02-09 00:11:04 +01:00
Daniel Hahler 9bcbf552d6 Add __repr__ for RunResult 2019-02-08 23:41:20 +01:00
Bruno Oliveira 32c6d4f603
Merge pull request #4738 from pstradomski/master
Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source.
2019-02-08 19:57:14 -02:00
Daniel Hahler b4b2f58eab
Merge pull request #4747 from blueyed/visit-filter
pytest.main: collect: factor out _visit_filter
2019-02-08 22:19:38 +01:00
Daniel Hahler 9c03196e79 Merge master into features 2019-02-08 22:02:29 +01:00
Daniel Hahler 64e8185ff7 Merge master into features 2019-02-08 20:09:09 +01:00
Daniel Hahler 7bb504b807 pytest.main: collect: factor out _visit_filter 2019-02-08 19:28:12 +01:00
Daniel Hahler 913a2da6e5 Fix handling of collect_ignore from parent conftest
`_collectfile` should be called on files only.

Fixes https://github.com/pytest-dev/pytest/issues/4592.
2019-02-08 18:46:43 +01:00
Anthony Sottile ea732464aa
Merge pull request #4740 from asottile/bugfix_4739
Fix `parametrize(... ids=<function>)` when the function returns non-strings
2019-02-07 21:47:33 -08:00
Thomas Hisch ddbea29c12 Remove terminal_reporter workaround from logging.py
The workaround was removed from the logging module by creating python
properties for verbosity related settings in the terminalreporter.

Closes: #4733
2019-02-07 22:52:07 +01:00
Anthony Sottile 4c7ddb8d9b Fix `parametrize(... ids=<function>)` when the function returns non-strings. 2019-02-07 12:25:59 -08:00
Thomas Hisch a1fcd6e445
Merge pull request #4734 from thisch/refactor_clilogging
Refactor _setup_cli_logging code
2019-02-07 20:15:41 +01:00
Thomas Hisch 7b8fd0cc12 Refactor _setup_cli_logging code
Change the indentation in _setup_cli_logging by moving the
self._log_cli_enabled check outside of the _setup_cli_logging method.
2019-02-07 19:39:12 +01:00
Paweł Stradomski 391dc549c0
Add comment on why realpath is needed 2019-02-07 12:56:13 +01:00
Paweł Stradomski 59e6fb94b5 Fix "ValueError: Plugin already registered" exceptions when running in build directories that symlink to actual source. 2019-02-07 02:05:22 +01:00
Zac Hatfield-Dodds 3384ffc6eb
Merge pull request #4725 from nicoddemus/collection-finish
Call pytest_report_collectionfinish hook when --collect-only is passed
2019-02-06 12:38:12 -10:00
Bruno Oliveira e276bd3332 pytest.warns emits a warning on unknown keyword arguments 2019-02-06 19:52:13 -02:00
Ronny Pfannschmidt 429485e621
Merge pull request #4720 from thisch/removesetupclilogging
Only call _setup_cli_logging in __init__
2019-02-06 20:05:41 +01:00
Christian Fetzer 2dc2a19db5 Add ability to exclude files matching glob patterns in conftest.py
This adds the `collect_ignore_glob` option for `conftest.py` to allow
Unix-style wildcards for excluding files.
2019-02-06 16:49:43 +01:00
Bruno Oliveira 54af0f4c65 Call pytest_report_collectionfinish hook when --collect-only is passed
Fix #2895
2019-02-06 12:58:23 -02:00
Christian Fetzer fc5d4654e5 Add ability to exclude files matching glob patterns with --ignore-glob
This adds the `--ignore-glob` option to allow Unix-style wildcards so
that `--ignore-glob=integration*` excludes all tests that reside in
files starting with `integration`.

Fixes: #3711
2019-02-06 11:29:30 +01:00
Bruno Oliveira 19c93d16d1 Do not raise UsageError when "pytest_plugins" is a module
Fix #3899
2019-02-06 08:24:22 -02:00
Thomas Hisch 0ce8b910ca Only call _setup_cli_logging in __init__
Supersedes #4719
2019-02-06 07:03:40 +01:00
Anthony Sottile 2264db7f4a
Merge pull request #4682 from arel/parameterize-conditional-raises-document-only
Document parametrizing conditional raises
2019-02-02 13:15:26 -08:00
Bruno Oliveira c3d7340542 Fix setUpClass being called in subclasses that were skipped
Fix #4700
2019-01-31 20:24:11 -02:00