Commit Graph

3145 Commits

Author SHA1 Message Date
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 e4eec3416a Note that tests from xdist reference the correct xdist issues 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 6eff3069da
Merge pull request #4851 from blueyed/addopts-vv
ci: PYTEST_ADDOPTS=-vv
2019-03-25 23:41:33 +01:00
Daniel Hahler 58a14b6b99
Merge pull request #4986 from blueyed/fnmatch_lines-list
tests: fnmatch_lines: use list
2019-03-25 23:31:04 +01: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
Daniel Hahler de44293d59 CollectError.repr_failure: honor explicit tbstyle option 2019-03-24 11:24:19 +01:00
Daniel Hahler 5efe6ab93c test_log_cli_auto_enable: get stdout once 2019-03-24 11:22:07 +01:00
Daniel Hahler ce59f42ce1 revisit test_root_logger_affected 2019-03-24 11:21:13 +01:00
Daniel Hahler 7da7b9610c minor: whitespace 2019-03-24 11:20:24 +01:00
Daniel Hahler 0ea1889265 test_as_errors: use subprocess with `-W`
Ref: https://github.com/pytest-dev/pytest/pull/4981
2019-03-24 11:17:55 +01:00
Daniel Hahler 6352cf2374 test_implicit_bad_repr1: harden/cleanup 2019-03-24 11:15:40 +01:00
Daniel Hahler 3127ec737b Fix pytest's own tests with `-W error::ResourceWarning` 2019-03-24 11:05:00 +01:00
Daniel Hahler d0f3f26fff test_collect_capturing: cover captured stderr 2019-03-23 23:17:07 +01:00
Daniel Hahler 08f3b02dfc tests: fnmatch_lines: use list
For strings fnmatch_lines converts it into a Source objects, splitted on
newlines.  This is not necessary here, and it is more consistent to use
lists here in the first place.
2019-03-23 11:36:18 +01:00
Daniel Hahler 2d690b83bf ExceptionInfo.from_current: assert current exception 2019-03-23 00:29:36 +01:00
Daniel Hahler afa985c135 Revisit coverage in some tests 2019-03-22 17:26:16 +01:00
Daniel Hahler fd64fa1863 Revisit test_importplugin_error_message
Should be more helpful in case of errors than before:

    >       assert re.match(expected_message, str(excinfo.value))
    E       _pytest.warning_types.PytestWarning: asserting the value None, please use "assert is None"

    https://travis-ci.org/pytest-dev/pytest/jobs/509970576#L208
2019-03-22 17:02:26 +01:00
Daniel Hahler 05d55b86df tests: minor sys.path cleanup 2019-03-22 16:20:55 +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 7a6bcc3639 Add reference to test_cmdline_python_namespace_package 2019-03-22 13:23:44 +01:00
Daniel Hahler ade773390a minor: rename inner test 2019-03-22 13:23:44 +01:00
Daniel Hahler 2e7d6a6202 Fix test_assertrewrite in verbose mode
Fixes https://github.com/pytest-dev/pytest/issues/4879.
2019-03-22 13:00:35 +01: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 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 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 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
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
Takafumi Arakaki fa3cca51e1 Test pytest.skip in doctest 2019-03-15 11:06:57 +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
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 bdac9d3dd0 tests: improve test_pdb_interaction_doctest
- ignore pdbrc (might be done in general, but this was the only affected
  test)
- fail faster in case of unexpected failure
2019-03-14 19:16:34 +01:00
Daniel Hahler 37158f5303 tests: fix test_pdb_interaction_continue_recursive with pdbpp 2019-03-14 19:16:34 +01:00
Bruno Oliveira bd70f5c148 Add test for mtime issue in #4903 2019-03-14 10:16:08 -03:00
Miro Hrončok d32ab6029f Fix pytest tests invocation with custom PYTHONPATH
Fixes https://github.com/pytest-dev/pytest/issues/4913

Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2019-03-12 17:31:42 +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
Daniel Hahler 8481e438bd ci: revisit coverage reporting
This brings coverage back that got missing with 9dcd6f2.

Continuation of #4839 / #4846.
2019-03-05 13:34:46 +01:00
Daniel Hahler 83558a0ba3 tests: make test_crash_on_closing_tmpfile_py27 more reliable
It fails reliable for me now without the fix from 9517c3a2a.

Ref: #2370
2019-03-04 15:04:55 +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
Daniel Hahler c334adc78f
Apply suggestions from code review
Co-Authored-By: nicoddemus <nicoddemus@gmail.com>
2019-03-03 11:20:00 -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 d97473e551 Add test and CHANGELOG for #1895 2019-03-02 09:39:30 -03:00
Bruno Oliveira 525639eaa0 Rename fixtures testing file to be consistent with the module name 2019-03-02 09:37:30 -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 4290cacb86
Merge pull request #4864 from blueyed/isort-cfg
Add config for isort
2019-03-01 18:44:56 +01: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 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
Daniel Hahler ccab469a0c Fix test_argcomplete: use python -m pytest
Previously it was not run with a) xdist ("-c"), and b) "python -m
pytest" ("…/pytest.py", not executable).
2019-02-27 16:52:46 +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
Bruno Oliveira a68f4fd2b9 Fix test failures after pluggy 1.8 release
pluggy now calls iter_entry_points with different arguments, and tests
which mocked that call need to be updated accordingly.
2019-02-22 18:58:54 -03:00
Bruno Oliveira 5b35241470
Merge pull request #4812 from mitzkia/logging_from_runtest_logreport
Logging: Make pytest_runtest_logreport() hook available for logging
2019-02-22 18:47:06 -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 9cb504ca9a Add same environments to Azure as have in AppVeyor, except py37-freeze
py37-freeze will be tackled in https://github.com/pytest-dev/pytest/issues/4807
2019-02-18 17:23:39 -03:00
Bruno Oliveira f0a9f9042f
Merge pull request #4805 from nicoddemus/release-4.3.0
Release 4.3.0
2019-02-18 17:18:50 -03:00
Anthony Sottile 5505826db9 Fix python3.8 / pypy failures 2019-02-16 11:23:23 -08: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
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
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
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
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
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 ed01dc6567
Merge pull request #4652 from blueyed/RunResult-repr
Add __repr__ for RunResult
2019-02-09 01:26:24 +01: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 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 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 4c7ddb8d9b Fix `parametrize(... ids=<function>)` when the function returns non-strings. 2019-02-07 12:25:59 -08: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
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
Anthony Sottile 315374008b Remove workaround for docstrings for py38+ 2019-02-05 12:48:18 -08: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
Bruno Oliveira 02962fabda Merge remote-tracking branch 'upstream/features' into merge-master-into-features 2019-01-30 09:37:46 -02:00
Bruno Oliveira 1dc16ad77b
Merge pull request #4690 from nicoddemus/deprecated-python-summary
Show deprecation message when running under Python 2.7 and 3.4
2019-01-30 09:07:59 -02:00
Bruno Oliveira ade5f2c8c5 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2019-01-29 19:36:56 -02:00
Bruno Oliveira 3e0e819158
Merge pull request #4280 from blueyed/trace-quit
pdb: improve quitting from debugger
2019-01-29 19:14:20 -02:00
Bruno Oliveira eb92e57509 Show deprecation message when running under Python 2.7 and 3.4
Fix #4627
2019-01-29 19:02:41 -02:00
Bruno Oliveira 1c5009c3fb Handle unittest.SkipTest exception with non-ascii characters
Fix #4669
2019-01-28 12:50:04 -02:00
Arel Cordero fd4289dae0 Adding `does_not_raise` to documentation only 2019-01-27 16:42:10 +00:00
Arel Cordero 977adf1354 Improving sphinx docs based on feedback 2019-01-27 16:41:23 +00:00
Arel Cordero afe9fd5ffd Adds `does_not_raise` context manager
Addressing issues #4324 and #1830
2019-01-27 16:40:35 +00:00
Ronny Pfannschmidt 5567c772cd quick&dirty fix fixture tests that rely on tmppath fixture structure 2019-01-27 14:19:23 +01:00
Ronny Pfannschmidt f7d7555521 fix #4680 - ensure tmpdir and tmp_path are the same 2019-01-27 13:05:34 +01:00
Bruno Oliveira 9905a73ae0
Merge pull request #4511 from jhunkeler/junit-strict
Toggle JUnit behavior with INI option
2019-01-24 20:54:32 -02:00
Bruno Oliveira 51dd738b1a
Merge pull request #4673 from kown7/count-tests
Count tests
2019-01-24 20:46:29 -02:00
Bruno Oliveira 7ddfc04793
Merge pull request #4665 from nicoddemus/group-warnings-by-message
Group warnings by message instead of by test id
2019-01-24 20:00:27 -02:00
wim glenn 8cf097635e
Fixed one weird test that creates a class instead of using mocks.. ¯\_(ツ)_/¯ 2019-01-24 12:59:36 -06:00
wim glenn 0f546c4670
pytest_terminal_summary uses result from pytest_report_teststatus hook, rather than hardcoded strings
Less hacky way to make XPASS yellow markup. Make sure collect reports still have a "when" attribute.

xfail changed to XFAIL in the test report, for consistency with other outcomes which are all CAPS
2019-01-24 10:17:29 -06:00
Kristoffer Nordstroem 6d38868950 fix tests by adding additional output to expected responses 2019-01-24 00:08:43 +01:00
Bruno Oliveira daf39112e7
Merge pull request #4091 from nicoddemus/setup-methods-as-fixtures-3094
Use fixtures to invoke xunit-style fixtures
2019-01-23 19:23:31 -02:00
Bruno Oliveira 9543d1901f Group warnings by message instead of by test id 2019-01-22 19:42:22 -02:00
Thomas Hisch a2954578aa Remove stdlib test 2019-01-22 20:25:51 +01:00
Anthony Sottile 92a2c1a9c4 remove and ban py.io.BytesIO, py.process, py.path.local.sysfind 2019-01-21 19:51:16 -08:00
Anthony Sottile 095ce2ca7f Fix linting errors and py references in saferepr.py 2019-01-20 16:36:14 -08:00
Anthony Sottile dbb6c18c44 copy saferepr from pylib verbatim
Copied from b9da2ed6178cd37d4ed6b41f9fa8234dce96973f
2019-01-20 16:30:31 -08:00
Anthony Sottile ec5e279f93 Remove and ban use of py.builtin 2019-01-20 11:59:48 -08:00
Daniel Hahler e69b1255d7 Improve quitting from pdb
Regarding tests: it merges ``test_pdb_interaction``,
``test_pdb_print_captured_stdout``, and
``test_pdb_print_captured_stderr`` into
``test_pdb_print_captured_stdout_and_stderr`` (clarity and performance,
especially since pexpect tests are slow).
2019-01-20 00:34:16 +01:00
Bruno Oliveira 57bf9d6740
Merge pull request #4654 from AuHau/fix/#4653-Fix_tmp_path_symlink_resolution
Fixes #4653 - tmp_path provides real path
2019-01-19 09:41:47 -02:00
Ronny Pfannschmidt f28b834426 fix #4649 - also transfer markers to keywordmapping
as it turns out it is distinct from nodekeywords and behaves completely different
2019-01-18 23:18:51 +01:00
Adam Uhlir 04bd147d46
Fixes #4653 - tmp_path provides real path 2019-01-18 12:54:00 -08:00
Bruno Oliveira 1a04e8903a
Merge pull request #4537 from chdsbd/master
Bugfix: monkeypatch.delattr handles class descriptors
2019-01-16 08:09:59 -02:00
Joseph Hunkeler 4ecf29380a
Adds xunit2 version of test_record_attribute 2019-01-14 22:58:41 -05:00
Joseph Hunkeler af2ee1e80a
Emit JUnit compatible XML
* Remove non-standard testcase elements: 'file' and 'line'
* Replace testcase element 'skips' with 'skipped'
* Time resolution uses the standard format: 0.000
* Tests use corrected XML output with proper attributes
2019-01-14 22:58:40 -05:00
Daniel Hahler 1a358df998 Merge master into features 2019-01-14 17:15:39 +01:00
Anthony Sottile 5bb0be1e24
Merge pull request #4615 from asottile/some_dead_code
Remove some dead code
2019-01-14 07:35:21 -08:00
Anthony Sottile 16546b7342 Remove some dead code
- I wrote a thing: https://github.com/asottile/dead
- wanted to try it out, there's lots of false positives and I didn't look
  through all the things it pointed out but here's some
2019-01-13 20:41:30 -08:00
Bruno Oliveira 3efb26ae7f
Merge pull request #4632 from AnjoMan/dont-rewrite-objects-with-failing-getattr
Assertion rewrite breaks for objects that reimplement `__getattr__`
2019-01-11 14:07:22 -02:00
Anton Lodder acb3e8e8a7 Test rewriting assertion when __name__ fails
Pytest rewrites assertions so that the items on each
side of a comoparison will have easier-to-read names
in case of an assertion error.

Before doing this, it checks to make sure the object
doesn't have a __name__ attribute; however, it uses
`hasattr` so if the objects __getattr__ is broken then
the test failure message will be the stack trace
for this failure instead of a rewritten assertion.
2019-01-10 20:45:15 -05:00
Bruno Oliveira 5f16ff3acc
Merge pull request #4212 from RonnyPfannschmidt/doctest-testmod-has-call
Doctest: hack in handling mock style objects
2019-01-10 19:13:45 -02:00
Bruno Oliveira 71a745270a
Merge pull request #4607 from oscarbenjamin/long_output
Show full repr with assert a==b and -vv
2019-01-10 12:30:46 -02:00
Bruno Oliveira 0f918b1a9d xunit-style functions and methods are invoked by autouse fixtures
Fix #3094, Fix #517
2019-01-10 12:10:04 -02:00
Ronny Pfannschmidt a6988aa0b9 fix doctest module when a mock object is around
fixes #3456
2019-01-10 12:50:22 +01:00
Bruno Oliveira e4a21b11d5 Change test_warningschecker_twice to a unittest 2019-01-09 18:58:51 -02:00
Victor Maryama 948a5d5ac6 Added test for Issue 4617 2019-01-09 12:31:26 +01:00
Oscar Benjamin 85055a9efe Show full repr with assert a==b and -vv 2019-01-08 01:25:05 +00:00
Pedro Algarvio be7eb22e88
Add test case for `importorskip` custom reason 2019-01-04 19:06:23 +00:00
Jeffrey Rackauckas 1eef53b6fe Update --collect-only to display test descriptions when ran in verbose mode. 2018-12-29 22:46:46 -08:00
Ronny Pfannschmidt 9f9f6ee48b remove most of markertransfer
keywords are still a big issue
2018-12-21 14:02:38 +01:00
Bruno Oliveira c378cb4793 Remove support for applying marks to values in parametrize
Fix #3082
2018-12-20 16:16:13 -02:00
Ronny Pfannschmidt d888d5c933
Merge pull request #4565 from nicoddemus/flaky-test
Use mocking to make test_junit_duration_report deterministic
2018-12-20 08:52:34 +01:00
Bruno Oliveira a93f41233a Raise an error if pytest_plugins is defined in a non-top-level conftest.py file
Fix #4548
2018-12-19 18:09:47 -02:00
Bruno Oliveira 9138419379 Remove support for '[pytest]' section in setup.cfg file
Fix #3086
2018-12-19 17:43:17 -02:00
Bruno Oliveira 197fd69ddc Use mocking to make test_junit_duration_report deterministic
Fix #4563
2018-12-19 17:13:12 -02:00
Bruno Oliveira 0115766df3 Calling fixtures directly is now an error instead of a warning
Fix #4545
2018-12-19 09:26:29 -02:00
Bruno Oliveira 8563364d8b
Merge pull request #4542 from nicoddemus/remove-legacy-warn
Remove config.warn, Node.warn and pytest_logwarning
2018-12-18 19:11:36 -02:00
Ronny Pfannschmidt e63c7a13ff
Merge pull request #4327 from ndevenish/approx
Let approx() work on more generic sequences
2018-12-17 15:21:12 +01:00
Bruno Oliveira b7e8171cf8
Merge branch 'features' into remove-legacy-warn 2018-12-17 10:37:31 -02:00
Bruno Oliveira 75e93e5168
Merge pull request #4556 from nicoddemus/idfunc-failure
Errors in parametrize id functions now propagate the error instead of issuing a warning
2018-12-17 10:36:15 -02:00
Bruno Oliveira c6d27d8224
Merge pull request #4555 from nicoddemus/remove-record-xml-pytest-main-str
Remove record_xml_property and support for strings in pytest.main()
2018-12-17 10:08:51 -02:00
Bruno Oliveira 84390acccc
Merge pull request #4553 from nicoddemus/junit-durations
Rename "junit_time" to "junit_duration_report" option
2018-12-17 10:08:20 -02:00
Bruno Oliveira 1499778d5e Errors in parametrize id functions now propagate the error instead of issuing a warning
Fix #2169
2018-12-14 21:07:54 -02:00
Bruno Oliveira a7e401656e Remove support to pass strings to pytest.main()
Fix #3085
2018-12-14 15:45:47 -02:00
Daniel Hahler 8e287c5c77 Merge master into features 2018-12-14 16:44:43 +01:00
Bruno Oliveira 231863b133 Rename "junit_time" to "junit_duration_report" option
Just realized while reading the changelog that "junit_time" is not a very good
name, so I decided to open this PR renaming it to "junit_duration_report" which
I believe conveys the meaning of the option better
2018-12-14 12:56:26 -02:00
Bruno Oliveira fd48cd57f9 Remove config.warn, Node.warn; pytest_logwarning issues a warning when implemented
Fix #3078
2018-12-14 12:50:18 -02:00
Bruno Oliveira 1e80a9cb34 Remove pytest_funcarg__ prefix support for defining fixtures
Fix #4543
2018-12-13 21:41:38 -02:00
Bruno Oliveira 26d202a7bd
Merge pull request #4529 from aparamon/jxmlunit-call-time
Add --junittime=call option
2018-12-13 13:51:06 -02:00
Bruno Oliveira b390c66dc4
Merge pull request #4292 from blueyed/exit-outcome
Derive outcomes.exit.Exit from SystemExit instead of KeyboardInterrupt
2018-12-13 13:43:39 -02:00
Bruno Oliveira f96e1b6f3e
Merge pull request #4532 from nicoddemus/failure-summary
Change -ra to show errors and failures last, instead of first
2018-12-13 10:30:28 -02:00
Bruno Oliveira 5b83417afc Deprecate the 'message' parameter of pytest.raises
Fix #3974
2018-12-12 22:26:30 -02:00
Anthony Sottile a254ad0436 Raise `TypeError` for `with raises(..., match=<non-None falsey value>)`. 2018-12-12 14:59:22 -08:00
Christopher Dignam f8d31d2400 Bugfix: monkeypatch.delattr handles class descriptors
Correct monkeypatch.delattr to match the correct behavior of
monkeypatch.setattr when changing class descriptors
2018-12-12 15:20:24 -05:00
Daniel Hahler 6af674a3ac
Merge pull request #4520 from blueyed/PYTEST_DISABLE_PLUGIN_AUTOLOAD-del
tests: fix tests that require PYTEST_DISABLE_PLUGIN_AUTOLOAD to be unset
2018-12-12 18:40:46 +01:00
Bruno Oliveira e3d30f8ebf Remove deprecated PyCollector.makeitem
Fix #4535
2018-12-12 14:15:52 -02:00
Andrey Paramonov 5d79baf3f8 Fix flaky test attempt 2 2018-12-12 15:33:29 +03:00
Andrey Paramonov 316cca204f Switch to ini config parameter 2018-12-12 13:19:39 +03:00
Andrey Paramonov 0bccfc44a7 Fix flaky test 2018-12-12 12:14:14 +03:00
Bruno Oliveira 9839ceffe0 Change -ra to show errors and failures last, instead of first
Often in large test suites (like pytest's), the -ra summary is very useful
to obtain a list of failures so we can execute each test at once to fix them.

Problem is the default shows errors and failures first, which leads to a lot
of scrolling to get to them.
2018-12-11 20:36:57 -02:00
Andrey Paramonov cfbd387a5d Add --junittime=call option 2018-12-11 19:29:31 +03:00
Daniel Hahler bb363c8ff2
Merge pull request #4528 from blueyed/parser-prog
argparsing: Parser: allow to forward prog to argparse
2018-12-11 13:33:40 +01:00
Daniel Hahler ebe0a88226
Merge pull request #4522 from blueyed/p-no-space
Handle missing space with -p
2018-12-11 13:33:18 +01:00
Daniel Hahler 3445eae737 argparsing: Parser: allow to forward prog to argparse
Ref: https://github.com/pytest-dev/pytest-xdist/pull/388.
2018-12-11 06:22:35 +01:00
Daniel Hahler 8152b6837e
Merge pull request #4419 from blueyed/set_trace-kwargs
pdb: support kwargs with `pdb.set_trace`
2018-12-11 04:28:24 +01:00
Daniel Hahler 0e4e8e00a9
Merge pull request #4504 from feuillemorte/4278_add_cachedir_tag
#4278 Added a CACHEDIR.TAG file to the cache directory
2018-12-11 04:27:35 +01:00
Daniel Hahler 7b1cb885c7 Handle missing space with -p
This still does not use an actual argument parser, which only gets
instantiated below, and it does not appear to make sense instantiating
it just for this pre-parsing it seems.

`-p` without the required value is being handled before already though,
so it could potentially be passed down from somewhere already?!

Fixes https://github.com/pytest-dev/pytest/issues/3532.
2018-12-11 04:27:03 +01:00
Daniel Hahler fc4aa27cae Derive outcomes.exit.Exception from SystemExit instead of KeyboardInterrupt
This is required for properly getting out of pdb, where
KeyboardInterrupt is caught in py36 at least.

Ref: https://github.com/pytest-dev/pytest/issues/1865#issuecomment-242599949
2018-12-11 04:22:33 +01:00
Daniel Hahler 539d3dc34d Merge branch 'fix-test_raises_exception_looks_iterable' into merge-master 2018-12-10 06:30:36 +01:00
Daniel Hahler 5ecbb02ace tests: fix test_raises_exception_looks_iterable
Started to fail on py37-xdist between
https://travis-ci.org/pytest-dev/pytest/jobs/465498973 and
https://travis-ci.org/pytest-dev/pytest/jobs/465792343, but could not
find a diff in versions (from the tox header), and both commits failed
locally.
2018-12-10 06:26:32 +01:00
Daniel Hahler 0db5ccb0dd Merge master into features 2018-12-10 05:42:07 +01:00
Daniel Hahler f3babf13ea Ensure that PYTEST_ADDOPTS are valid by themselves
Fixes https://github.com/pytest-dev/pytest/issues/4265.
2018-12-09 21:57:10 +01:00
Daniel Hahler 64ee1ee81b tests: fix tests that require PYTEST_DISABLE_PLUGIN_AUTOLOAD to be unset
Fix pytest's own tests with PYTEST_DISABLE_PLUGIN_AUTOLOAD=1.
2018-12-09 12:06:18 +01:00
Daniel Hahler 5ebacc49c6 Harden tests, fix doc/msg 2018-12-05 19:22:44 +01:00
Tomer Keren e1e4b226c6 👌 Address code review
Edited the changelog for extra clarity, and to fire off auto-formatting

Oddly enough, keeping `filename='{filename!r}'` caused an error while
collecting tests, but getting rid of the single ticks fixed it
Hopefully closes #3191
2018-12-05 10:52:12 +02:00
Tomer Keren e0c2ab1901 Fix tests not to assert a function that already asserts
Maybe there should be a warning about that too?
2018-12-05 10:41:30 +02:00
Tomer Keren 9fc9b2926f Fix tests and add aditional cases
As requested by review.

👌 Address code review for tests
2018-12-05 10:41:30 +02:00
Tomer Keren 1654b77ca0 [#3191] Set up tests to confirm warnings 2018-12-05 10:41:18 +02:00
feuillemorte d237197de3 #4278 Added a CACHEDIR.TAG file to the cache directory 2018-12-04 13:49:08 +01:00
Anthony Sottile b88c3f8f82 Deprecate pytest.config 2018-12-03 09:01:42 -08:00
Pedro Algarvio 6da8befc74
Black suggestions 2018-12-03 12:58:22 +00:00
Pedro Algarvio 14024c7fc1
Test case for #4500 bug and respective fix #4487 2018-12-03 12:17:14 +00:00
Pedro Algarvio 517b8bc69e
Stop using the deprecated `\.warn()` log handler method 2018-12-03 11:52:33 +00:00
Bruno Oliveira a131f0acf6
Merge pull request #4490 from nicoddemus/remove-cached-setup-add-call
Remove cached_setup and Metafunc.addcall
2018-12-01 18:44:51 -02:00
Bruno Oliveira 40b85d7ee8 Remove Metafunc.addcall
Fix #3083
2018-12-01 16:41:59 -02:00
Bruno Oliveira 090f7ff449 Remove request.cached_setup
Fix #4489
2018-12-01 15:59:44 -02:00
Bruno Oliveira b05061dcd2 Change deprecation type of --result-log to PytestDeprecationWarning
It was decided to deprecate this on a later date (see discussion in #4447)
2018-12-01 14:29:50 -02:00
Ronny Pfannschmidt 847eacea19 refactor CallInfo constructor magic into named constructor 2018-11-30 13:21:54 +01:00
Ronny Pfannschmidt 7eb28f9eb7 remove yield tests and compat properties 2018-11-30 10:40:13 +01:00
Anthony Sottile 1bba0a9714 Deprecate `raises(..., 'code(as_a_string)')` / `warns(..., 'code(as_a_string)') 2018-11-29 09:34:51 -08:00
Anthony Sottile e9b2475e29 Display actual test ids in `--collect-only` 2018-11-25 09:33:18 -08:00
Daniel Hahler 5bee396e4b Merge master into merge-master-into-features 2018-11-24 13:47:10 +01:00
Bruno Oliveira 9e522c97fa Try to fix/improve reporting of test_request_garbage
* Run it in a subprocess to reduce possible intereference from the outer pytest
* Print the leaked objects to see if they provide any hints
2018-11-24 08:29:39 -02:00
Anthony Sottile 860bc50772
Merge pull request #4451 from asottile/report_correct_filename_raises_exec
Fix `raises(..., "code(string)")` frame filename.
2018-11-23 17:29:09 -08:00
Bruno Oliveira 33b877cc01 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-11-23 23:27:41 -02:00
Anthony Sottile 0d5298475d Fix `raises(..., "code(string)")` frame filename. 2018-11-23 15:01:35 -08:00
Daniel Hahler be3b8fc9c1 Fix warnings summary header appearing twice
Ref: https://github.com/pytest-dev/pytest/pull/4450#discussion_r236017645
Ref: https://github.com/pytest-dev/pytest/pull/4399
2018-11-23 22:47:58 +01:00
Daniel Hahler 0cf45ee18a Display "short test summary info" after (main) warnings again
Fixes https://github.com/pytest-dev/pytest/issues/3952.
2018-11-23 20:06:09 +01:00
Bruno Oliveira 63f90a2bcd
Merge pull request #4438 from RonnyPfannschmidt/fix-4386-raises-partial-object
fix #4386 - restructure construction and partial state of ExceptionInfo
2018-11-23 12:41:14 -02:00
Bruno Oliveira 0b73d6d4f5
Merge pull request #4444 from RonnyPfannschmidt/fix-4386-2
fix #4386 - handle uninitialized exceptioninfo in repr/str
2018-11-23 12:40:41 -02:00
Bruno Oliveira e4ae33d592
Merge pull request #4394 from blueyed/cache-ensure-files
cacheprovider: do not write README/.gitignore to existing dir
2018-11-23 09:07:49 -02:00
Bruno Oliveira c5c728c8bc Fix test/improve tests a bit in py27 2018-11-22 21:38:33 -02:00
Bruno Oliveira f987b368e8
Merge pull request #3776 from alysivji/attrs-n-dataclasses
Detailed assert failure introspection for attrs and dataclasses objects
2018-11-22 21:25:35 -02:00
Bruno Oliveira 9ae8429a21 Use a more specific exception type in test_raises_repr_inflight
As requested during review
2018-11-22 20:24:46 -02:00
Ronny Pfannschmidt 88bf01a31e fix #4386 - restructure construction and partial state of ExceptionInfo 2018-11-22 21:20:32 +01:00
Ronny Pfannschmidt abaf496fe8
Merge pull request #4440 from nicoddemus/config-warning-stacklevel
Adjust stacklevel of "config" warnings
2018-11-22 21:02:52 +01:00
Ronny Pfannschmidt b71bd9b300 fix #4386 - handle uninitialized exceptioninfo in repr/str 2018-11-22 20:52:15 +01:00
Ronny Pfannschmidt 94d032a6de
Merge pull request #4436 from asottile/print_function
Fix formatting of print() calls
2018-11-22 20:17:19 +01:00
Bruno Oliveira aa765cf8c2 Adjust stacklevel of "config" warnings
Related to #4439
2018-11-22 14:44:01 -02:00
Ronny Pfannschmidt 5f1d692072 use Path.resolve in test to sort out osx temporary folder being a symlink 2018-11-22 16:10:12 +01:00
Anthony Sottile b3700f61ba Fix formatting of print() calls 2018-11-22 00:15:14 -08:00
Ronny Pfannschmidt fc61bdd907 fix 4425: resolve --basetemp to absolute paths 2018-11-20 16:14:50 +01:00
Anthony Sottile 95c6d591f7 Properly escape \r \n \t bytes 2018-11-19 11:03:52 -08:00
Anthony Sottile 9ca0ab6e2b Ensure printable manually-specified param(id=...) 2018-11-19 11:03:52 -08:00
Anthony Sottile 8395b9e25d Require id=... to be a string
This was documented before, but never enforced.  Passing non-strings could
have strange side-effects and enforcing a string simplifies other
implementation.
2018-11-19 11:03:52 -08:00
Anthony Sottile 3d92d5a659 Make sure parametrize ids are printable 2018-11-19 11:03:52 -08:00
Anthony Sottile 50e3783f07
Merge pull request #4421 from RonnyPfannschmidt/remove-pytest-namespace
remove pytest namespace hook
2018-11-19 09:35:33 -08:00
Ronny Pfannschmidt ba17363d75 remove pytest namespace hook 2018-11-19 14:04:41 +01:00
Daniel Hahler 92a2884b09 pdb: support kwargs with `pdb.set_trace`
This handles `header` similar to Python 3.7 does it, and forwards any
other keyword arguments to the Pdb constructor.

This allows for `__import__("pdb").set_trace(skip=["foo.*"])`.

Fixes https://github.com/pytest-dev/pytest/issues/4416.
2018-11-19 13:04:14 +01:00
Nicholas Devenish 4eddf634e7 Rename and split out the testing, and reword the changelog. 2018-11-18 20:01:11 +00:00
Nicholas Devenish 1a8d9bf254 Let approx() work on more generic sequences
approx() was updated in 9f3122fe to work better with numpy arrays,
however at the same time the requirements were tightened from
requiring an Iterable to requiring a Sequence - the former being
tested only on interface, while the latter requires subclassing or
registration with the abc.

Since the ApproxSequence only used __iter__ and __len__ this commit
reduces the requirement to only what's used, and allows unregistered
Sequence-like containers to be used.

Since numpy arrays qualify for the new criteria, reorder the checks so
that generic sequences are checked for after numpy arrays.
2018-11-18 20:01:11 +00:00
Anthony Sottile 10cdae8e38
Merge pull request #4414 from asottile/starred_with_side_effect
Fix assertion rewriting involving Starred + side-effects
2018-11-17 16:17:24 -08:00
Daniel Hahler 5fab0ca312
Merge pull request #4403 from RonnyPfannschmidt/fix-4400
Fix #4400 - rearrange the handling of yield test warnings/errors
2018-11-18 00:57:44 +01:00
Anthony Sottile 690a63b921 Fix assertion rewriting involving Starred + side-effects 2018-11-17 10:42:51 -08:00
Daniel Hahler a252e81ced Fix collection of testpaths with `--pyargs`
Fixes https://github.com/pytest-dev/pytest/issues/4405.
2018-11-17 13:28:10 +01:00