Commit Graph

3223 Commits

Author SHA1 Message Date
Anthony Sottile c63320cc31 codecs.open / io.open 2019-06-03 12:08:02 -03:00
Anthony Sottile 4df529e5b9 Clean up __future__ and coding: in tests 2019-06-03 12:08:02 -03:00
Anthony Sottile a91fe1fedd pre-commit run pyupgrade --all-files 2019-06-03 12:08:02 -03:00
Anthony Sottile 3f1ec520fc pre-commit run reorder-python-imports --all-files 2019-06-03 12:08:01 -03:00
Anthony Sottile 5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03:00
Thomas Hisch ef053193b5 logging: Extend LEVELNAME_FMT_REGEX 2019-06-03 05:53:19 +02:00
Bruno Oliveira 4d49ba6529 Drop Python 2.7 and 3.4 support
* Update setup.py requires and classifiers
* Drop Python 2.7 and 3.4 from CI
* Update docs dropping 2.7 and 3.4 support
* Fix mock imports and remove tests related to pypi's mock module
* Add py27 and 34 support docs to the sidebar
* Remove usage of six from tmpdir
* Remove six.PY* code blocks
* Remove sys.version_info related code
* Cleanup compat
* Remove obsolete safe_str
* Remove obsolete __unicode__ methods
* Remove compat.PY35 and compat.PY36: not really needed anymore
* Remove unused UNICODE_TYPES
* Remove Jython specific code
* Remove some Python 2 references from docs

Related to #5275
2019-06-02 14:39:11 -03:00
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
Daniel Hahler 737a1bf947
Merge pull request #5341 from blueyed/auto-slow
tests: conftest: auto-add slow marker
2019-05-30 17:01:43 +02:00
Bruno Oliveira 5cbc06a453 Show test module in the PytestCollectionWarning message
Related to #5330
2019-05-30 08:18:28 -03:00
Daniel Hahler 28bf3816e7 tests: conftest: auto-add slow marker 2019-05-30 06:55:38 +02:00
Daniel Hahler 6765aca0d1 Merge master into features 2019-05-30 06:33:04 +02:00
Daniel Hahler fb12d2a612 test_enter_leave_pdb_hooks_are_called: remove child.sendeof() 2019-05-30 03:09:36 +02:00
Daniel Hahler 8e51563384 tests: pdb: flush also on MacOS, but read() before
Ref: https://github.com/pytest-dev/pytest/issues/2022
2019-05-30 03:09:36 +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
Bruno Oliveira b0f090890c
Merge master into features (#5332)
Merge master into features
2019-05-29 20:39:27 -03:00
Daniel Hahler ff80464b47 last-failed: display skipped-files msg always 2019-05-29 23:32:52 +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
Daniel Hahler af21e6b45c Merge master into features
(dropping the temporary pinning of pluggy (2e2e895b4))
2019-05-29 22:15:25 +02:00
Daniel Hahler 61b76c7f5f tests: conftest: fix collection of slow/slowest items 2019-05-29 21:35:05 +02: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 0025e4408f conftest: add uses_pexpect mark 2019-05-28 18:41:01 +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 852fb6a4ae Change basic test case to be consistent with existing assertion rewriting
The code
```
x = 0
assert x == 1
```
will give the failure message 0 == 1, so it shouldn't be different as
part of an unroll
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 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 c607697400 Fixed test case 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
danielx123 a0dbf2ab99 Adding test cases for unrolling an iterable #5062 2019-05-25 19:34:08 +03:00
Tomer Keren 6b5152ae13 Sanity tests for loop unrolling 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
Daniel Hahler ec6d0fa4d7
Merge pull request #5268 from blueyed/harden-test
tests: harden test_nonascii_text
2019-05-24 01:51:35 +02: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
Bruno Oliveira 6ba5e3c071
tests: fix test_trace_after_runpytest (#5245)
tests: fix test_trace_after_runpytest
2019-05-23 19:58:33 -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 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 8a498700da Add tests for #5286 2019-05-22 03:56:52 +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
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
Daniel Hahler ff428bfee1 tests: harden test_nonascii_text 2019-05-17 18:06:32 +02: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
Daniel Hahler c081c01eb1 minor: s/no covers/no cover/ 2019-05-14 06:51:49 +02:00
Daniel Hahler f8e1d58e8f minor: settrace != set_trace 2019-05-14 06:51:30 +02:00
Raul Tambre 18024467ff
Fix invalid Python file encoding "utf8"
Since Python 3 it must be "utf-8", which is the official name.
This is backwards compatible with Python 2.
2019-05-12 19:14:06 +03:00
Daniel Hahler dda21935a7 tests: fix test_trace_after_runpytest
It was not really testing what it was supposed to test (e.g. the inner
test was not run in the first place).
2019-05-12 09:33:34 +02: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 0594dba5ce Remove unused markers and enable --strict-markers 2019-05-09 19:36:39 -03:00
Bruno Oliveira f1183c2422 Remove the 'issue' marker from test suite
It doesn't seem to add much value (why would one execute tests
based on that marker?), plus using the docstring for that
encourages one to write a more descriptive message about the test
2019-05-09 19:36:38 -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 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 6d040370ed Show fixture scopes with ``--fixtures``, except for "function" scope
Fix #5220
2019-05-07 14:32:20 -03:00
Bruno Oliveira 1d466d0aa7
Use exec directly (#5224)
Use exec directly
2019-05-07 10:02:12 -03:00
Bruno Oliveira ef4dec0bcf
Skip test_source_mtime_long_long on 32bit and lower platforms (#5045)
Skip test_source_mtime_long_long on 32bit and lower platforms
2019-05-07 09:42:18 -03:00
Anthony Sottile d1a48ad68f Use exec directly 2019-05-06 23:07:39 -07: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 0e8a8f94f6 Add encoding header to test_terminal.py 2019-05-05 09:14:07 -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 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 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 53cd7fd2ea Introduce new warning subclasses
Fix #5177
2019-04-28 10:38:25 -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
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 79d5fc3a0b
Merge pull request #5144 from blueyed/sessionfinish-exitstatus
pytest_sessionfinish: preset exitstatus with UsageErrors
2019-04-19 17:30:01 +02:00
Daniel Hahler f75f7c1925 conftest: use a hookwrapper with sorting faster tests first 2019-04-19 01:23:34 +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
Ilya Konstantinov d67d68f6d3 Eliminate core dependency on 'terminal' plugin 2019-04-17 11:19:19 -07:00
Daniel Hahler c3178a176d move test 2019-04-17 15:30:34 +02: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
Bruno Oliveira b64d9402ca
Merge pull request #5108 from blueyed/summary
terminal summary: display passes after warnings
2019-04-15 14:49:01 -03: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 852ca7ad59
Merge pull request #5114 from blueyed/fixtest
test_pytest_exit_returncode: ignore ResourceWarnings
2019-04-15 11:25:16 -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 f1f1862b19 Update testing/test_runner.py 2019-04-14 23:26:56 +02:00
Daniel Hahler 6f0a5789fb Merge master into features 2019-04-14 23:22:21 +02:00
Daniel Hahler 1dd5f088fa test_pytest_exit_returncode: ignore ResourceWarnings
Fixes https://github.com/pytest-dev/pytest/issues/5088.
2019-04-14 21:55:15 +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
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 148f2fc72c Fix test_error_during_readouterr: syspathinsert is unused 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
Daniel Hahler fcbfdef11b
Merge pull request #5071 from blueyed/prefer-fast
Add a conftest to prefer faster tests
2019-04-10 01:22:24 +02:00
Daniel Hahler b84f826fc8 test_run_stdin: add sleep 2019-04-10 00:03:49 +02:00
Daniel Hahler 4fb7a91a5e pdb: add test for --trace with --pdbcls
Ensures that https://github.com/pytest-dev/pytest/issues/4111 is fixed,
which happened in 92a2884b as a byproduct.
2019-04-08 03:49:03 +02:00
Daniel Hahler 06029d11d3 Refactor into TerminalReporter.short_test_summary 2019-04-07 19:49:18 +02:00
Daniel Hahler 4c0ba6017d Add a conftest to prefer faster tests
This uses pytest_collection_modifyitems for pytest's own tests to order
them, preferring faster ones via quick'n'dirty heuristics only for now.
2019-04-07 19:11:17 +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 50edab8004 Add tests for reportchars=a
Ref: https://github.com/pytest-dev/pytest/issues/5066
2019-04-07 18:05:33 +02:00
Daniel Hahler b4b9f788af Support reportchars=A (really all, including passed) 2019-04-07 18:05:33 +02:00
Daniel Hahler 2b1ae8a66d __tracebackhide__ for check 2019-04-06 15:00:23 +02:00
Daniel Hahler 2ebb69b50a py2 fixes 2019-04-06 15:00:12 +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
Daniel Hahler f599172add test with 😄 in message 2019-04-05 16:08:11 +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 8011ff5bda Add _sys_snapshot fixture and use it with more tests 2019-04-05 11:55:23 +02:00
Daniel Hahler 899e74aa14 tests: harden test_immediate_initialiation_and_incremental_are_the_same 2019-04-05 11:55:23 +02:00
Daniel Hahler 66f743c45a Fix test_conftest when run via pytest-randomly 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
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
Ondřej Súkup 77526f412c
Skip test_source_mtime_long_long on 32bit and lower platforms 2019-04-04 13:14:46 +02: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 cc90bcce4c wrap_session: restore old behavior for initstate=1 2019-04-03 05:09:21 +02:00