Commit Graph

3559 Commits

Author SHA1 Message Date
Anthony Sottile cc78444c30 Merge remote-tracking branch 'origin/master' into mm 2019-11-15 15:26:57 -08:00
Daniel Hahler c49c61fdaf
Import Path from _pytest.pathlib for py35 (#6193) 2019-11-15 23:17:43 +01:00
Daniel Hahler 1abb08d52f tests: use sys.dont_write_bytecode
Setting PYTHONDONTWRITEBYTECODE in the environment does not change it
for the current process.
2019-11-15 23:13:08 +01:00
Daniel Hahler 5979837c60 Import Path from _pytest.pathlib for py35
This is important for `isinstance` checks etc.
2019-11-15 22:19:53 +01:00
Anthony Sottile 4e0f99260d Add regression tests for __init__.py breakage 2019-11-15 13:19:31 -08:00
Anthony Sottile 176c7771fb Revert "fix bug with nonskipped first test in package (#5831)"
This reverts commit 85288b5321, reversing
changes made to 5f9db8a017.
2019-11-15 08:29:52 -08:00
Bruno Oliveira d2ea9e2db5 Remove report_log in favor of pytest-reportlog
Fix #6180
2019-11-14 19:47:26 -03:00
Bruno Oliveira 6f2c0fd2e8 Show a better message when 'request' is used in parametrize
Fix #6183
2019-11-13 19:57:10 -03:00
Bruno Oliveira 2a67637acc Issue a warning to prepare change of 'junit_family' default value
Fix #6179
2019-11-13 19:55:13 -03:00
Daniel Hahler f91bf48a40
Merge pull request #6176 from blueyed/assertoutcome
pytester: Hookrecorder: improve assertoutcome
2019-11-13 19:27:18 +01:00
Daniel Hahler a6e10cc2e3
Merge pull request #6181 from blueyed/maxfail-terminal-upstream
terminal: report ``session.shouldfail`` reason (``-x``)
2019-11-13 19:27:01 +01:00
Daniel Hahler b06f33f474 terminal: report ``session.shouldfail`` reason (``-x``)
Via https://github.com/blueyed/pytest/pull/108.
2019-11-13 16:18:41 +01:00
Daniel Hahler 6ddf7c3d42 pytester: Hookrecorder: improve assertoutcome
Before:

        def assertoutcome(self, passed: int = 0, skipped: int = 0, failed: int = 0) -> None:
            realpassed, realskipped, realfailed = self.listoutcomes()
            assert passed == len(realpassed)
    >       assert skipped == len(realskipped)
    E       assert 1 == 0
    E        +  where 0 = len([])

After:

    >       reprec = testdir.inline_run(testpath, "-s")
    E       AssertionError: ([], [], [<TestReport 'nodeid' when='call' outcome='failed'>])
    E       assert {'failed': 1, 'passed': 0, 'skipped': 0} == {'failed': 0, 'passed': 0, 'skipped': 1}
2019-11-13 13:48:20 +01:00
Daniel Hahler fc1c015c6b tests: remove test_nested_marks (xfail)
It currently fails with a TypeError, and was not updated since 2013 -
therefore it can be assumed that it is not important to support it.

```
____________________ ERROR collecting test_nested_marks.py _____________________
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:235: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
…/Vcs/pytest/src/_pytest/python.py:404: in _genfunctions
    self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))
…/Vcs/pluggy/src/pluggy/hooks.py:324: in call_extra
    return self(**kwargs)
…/Vcs/pluggy/src/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
…/Vcs/pluggy/src/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
…/Vcs/pluggy/src/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
…/Vcs/pluggy/src/pluggy/manager.py:87: in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
…/Vcs/pytest/src/_pytest/python.py:130: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
…/Vcs/pytest/src/_pytest/python.py:965: in parametrize
    function_definition=self.definition,
…/Vcs/pytest/src/_pytest/mark/structures.py:111: in _for_parametrize
    if len(param.values) != len(argnames):
E   TypeError: object of type 'MarkDecorator' has no len()
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
```
2019-11-12 14:44:03 +01:00
Ran Benita b352e34938
Merge pull request #6149 from bluetech/cached-property
Add a @cached_property implementation
2019-11-10 22:11:04 +02:00
Daniel Hahler abcedd6095
_compare_eq_iterable: use AlwaysDispatchingPrettyPrinter (#6151) 2019-11-10 14:08:25 +01:00
Ran Benita 42a46ea786 Add a @cached_property implementation
This is a useful utility to abstract the caching property idiom.

It is in compat.py since eventually it will be replaced by
functools.cached_property.

Fixes #6131.
2019-11-10 10:21:55 +02:00
Bruno Oliveira 245e1f10e5
Merge pull request #6152 from grlee77/module_name_in_id
use __name__ attribute in the parametrize id for modules as well
2019-11-08 14:16:34 -03:00
Ran Benita 84b2c81db4 Drop the "alias" helper used in MarkDecorator
It is a little too obscure IMO, but the reason I want to drop it is that
type checking has no hope of understanding such dynamic constructs.

The warning argument wasn't used.
2019-11-08 11:22:46 +02:00
Gregory Lee db82432ec8 add minimal test case 2019-11-08 01:39:29 -05:00
Daniel Hahler cc503c1821 _compare_eq_iterable: use AlwaysDispatchingPrettyPrinter
This fixes/removes the previous hack of re-trying with minimum width,
which fails short when it splits strings.

This inherits from `pprint.PrettyPrinter` to override `_format` in a
minimal way to always dispatch, regardless of the given width.

Code ref: 5c0c325453/Lib/pprint.py (L170-L178)
2019-11-08 04:07:09 +01:00
Bruno Oliveira 6ad95716da
add --co option to collect-only (#6116)
add --co option to collect-only
2019-11-07 19:03:32 -03:00
Daniel Hahler 09709bba06
Use atomicrewrites only on Windows (#6148) 2019-11-07 22:13:26 +01:00
Bruno Oliveira 7ed33996f1
on_rm_rf_error: ignore os.open (no warning) (#6074)
on_rm_rf_error: ignore os.open (no warning)
2019-11-07 18:06:05 -03:00
NNRepos 4946cc8282 Add --co option to collect-only
Fix #5845
2019-11-07 17:50:27 -03:00
Daniel Hahler 45c4a8fb3d Use atomicrewrites only on Windows
Fixes https://github.com/pytest-dev/pytest/issues/6147
2019-11-07 20:57:45 +01:00
Daniel Hahler 19b2f4bb8a
tests: use ids (#6145) 2019-11-07 14:43:46 +01:00
Daniel Hahler f11237b066
_perform_collect: remove comment about untested code (#6144) 2019-11-07 13:18:08 +01:00
Daniel Hahler 14eaa05b60
Merge pull request #6143 from blueyed/test_source
test_source: do not instantiate Source objects during collection
2019-11-07 13:16:34 +01:00
Daniel Hahler 2e5cf1cc78 Fix order of format args with warning 2019-11-07 12:50:04 +01:00
Daniel Hahler 8aa0809fbc on_rm_rf_error: ignore os.open (no warning)
Ref: https://github.com/pytest-dev/pytest/pull/6044/files#r339321752
2019-11-07 12:50:04 +01:00
Daniel Hahler ab101658f0
saferepr: handle BaseExceptions (#6047) 2019-11-07 12:33:22 +01:00
Daniel Hahler b268463243
Merge master into features (#6111) 2019-11-07 12:31:33 +01:00
Daniel Hahler dd852ded70 _perform_collect: remove comment about untested code
Harden one test where it is tested.

All tests testing this:

    testing/acceptance_test.py:184(TestGeneralUsage::test_not_collectable_arguments)
    testing/acceptance_test.py:373(TestGeneralUsage::test_direct_addressing_notfound)
    testing/acceptance_test.py:403(TestGeneralUsage::test_issue134_report_error_when_collecting_member[test_fun.py::test_a])
    testing/acceptance_test.py:420(TestGeneralUsage::test_report_all_failed_collections_initargs)
    testing/test_config.py:1309(test_config_blocked_default_plugins[python])

(via https://github.com/blueyed/pytest/pull/88)
2019-11-07 12:29:36 +01:00
Daniel Hahler dd6cf7c172 test_exc_chain_repr_without_traceback: use ids 2019-11-07 12:25:46 +01:00
Daniel Hahler 5c00226847 test_iterable_full_diff: use test ids 2019-11-07 12:24:01 +01:00
Daniel Hahler e8a3d1adf2 Fix test_trace_with_parametrize_handles_shared_fixtureinfo for colors 2019-11-07 11:48:51 +01:00
Daniel Hahler cb21a8db1d test_source: do not instantiate Source objects during collection 2019-11-07 11:44:26 +01:00
Daniel Hahler fee7c7b032 py38: do not call None() directly
Works around:

    _____ ERROR collecting testing/io/test_saferepr.py _____
    src/_pytest/python.py:502: in _importtestmodule
        mod = self.fspath.pyimport(ensuresyspath=importmode)
    .venv38/lib/python3.8/site-packages/py/_path/local.py:701: in pyimport
        __import__(modname)
    <frozen importlib._bootstrap>:991: in _find_and_load
        ???
    <frozen importlib._bootstrap>:975: in _find_and_load_unlocked
        ???
    <frozen importlib._bootstrap>:671: in _load_unlocked
        ???
    src/_pytest/assertion/rewrite.py:136: in exec_module
        source_stat, co = _rewrite_test(fn, self.config)
    src/_pytest/assertion/rewrite.py:288: in _rewrite_test
        co = compile(tree, fn, "exec", dont_inherit=True)
    E     File "…/Vcs/pytest/testing/io/test_saferepr.py", line 45
    E       None()
    E       ^
    E   SyntaxError: 'NoneType' object is not callable; perhaps you missed a comma?
2019-11-06 22:08:10 +01:00
Daniel Hahler eb7a4e32ad saferepr: handle BaseExceptions
This causes INTERNALERRORs with pytest-django, which uses
`pytest.fail` (derived from `BaseException`) to prevent DB access, when
pytest then tries to e.g. display the `repr()` for a Django `QuerySet`
etc.

Ref: https://github.com/pytest-dev/pytest-django/pull/776
2019-11-06 22:08:10 +01:00
Daniel Hahler 5be3a9b5ce
tests: speed up test_faulthandler.test_timeout (#6075) 2019-11-06 22:07:28 +01:00
Daniel Hahler fe429d4ce8
assert: fix _compare_eq_iterable: re-format both sides (#6137) 2019-11-06 22:06:39 +01:00
Bruno Oliveira 85288b5321
fix bug with nonskipped first test in package (#5831)
fix bug with nonskipped first test in package
2019-11-06 16:06:46 -03:00
Bruno Oliveira 74f4ec5986
Making it possible to access the pluginmanager in the pytest_ad… (#6106)
Making it possible to access the pluginmanager in the pytest_addoptio…
2019-11-06 15:18:59 -03:00
Daniel Hahler 8dcee39ce9
Merge pull request #6103 from blueyed/lsof_check
tests: lsof_check: include exc with skip message
2019-11-06 18:44:19 +01:00
Daniel Hahler 4e45472405 Merge master into features
Conflicts:
	src/_pytest/debugging.py
2019-11-06 14:22:07 +01:00
Daniel Hahler 92b436c938
Merge pull request #6136 from blueyed/fix-rm_rf-tests
Fix rm_rf tests
2019-11-06 14:19:47 +01:00
Daniel Hahler 01769b141a
Merge pull request #6100 from blueyed/fix-skip-offset
terminal: fix line offset with skip reports
2019-11-06 13:29:40 +01:00
Daniel Hahler 0485b07ff0
Merge pull request #6071 from blueyed/tests-doctest-mock
Tests: approx: mock doctest runner's pdb usage
2019-11-06 13:27:50 +01:00
Daniel Hahler eb4b3ce1c8
Merge pull request #6084 from blueyed/merge-rm
tests: merge/remove test_dontreadfrominput_buffer_python3
2019-11-06 13:24:47 +01:00
Daniel Hahler ce3d431002 assert: fix _compare_eq_iterable: re-format both sides
Follow-up to 946434c61 (#5924).

Before this patch the test would look like this:

    {'env': {'sub...s wrapped'}}}} == {'env': {'sub...}}}, 'new': 1}
    Omitting 1 identical items, use -vv to show
    Right contains 1 more item:
    {'new': 1}
    Full diff:
      {
       'env': {'sub': {'long_a': 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
    -                  'sub1': {'long_a': 'substring '
    +                  'sub1': {'long_a': 'substring that gets wrapped'}}},
    ?                                                +++++++++++++++++ ++++
    +  'new': 1,
    -                                     'that '
    -                                     'gets '
    -                                     'wrapped'}}},
      }
2019-11-06 11:23:15 +01:00
Daniel Hahler e7320c6b54
Merge pull request #5926 from AtakamaLLC/optional-multiline
Add log-auto-indent option to control multiline formatting
2019-11-06 00:35:24 +01:00
Daniel Hahler 00f67494e5
Merge pull request #6107 from MarcoGorelli/color-percentage-indicator
Color percentage indicator
2019-11-06 00:28:45 +01:00
Daniel Hahler d8096925fa Fix for Python 3.5 not handling LocalPath 2019-11-06 00:22:46 +01:00
Daniel Hahler 9309ae299a Use try/finally to ensure chmod is run, filter warning 2019-11-05 22:28:32 +01:00
Tibor Arpas 262ed567d0 tests: clean up chmod-related tests to fix rm_rf warnings
Fixed https://github.com/pytest-dev/pytest/issues/5974#issuecomment-549822509.
2019-11-05 22:10:27 +01:00
Daniel Hahler 0794289689
Merge pull request #6129 from blueyed/typing
Typing around Node.location, reportinfo, repr_excinfo etc
2019-11-05 18:29:29 +01:00
Daniel Hahler cab29dc861
Merge pull request #6124 from blueyed/test_group_warnings_by_message-ignore-own-warning
test_group_warnings_by_message: ignore own PytestExperimentalApiWarning
2019-11-05 16:24:10 +01:00
Daniel Hahler 741f0fedd1 typing around Node.location, reportinfo, repr_excinfo etc 2019-11-05 16:22:58 +01:00
MarcoGorelli 0d79061432 Color percentage indicator according to color of final line
indicate current outcome/status with color of percentage indicator

Fix type annotation, refactor _write_progress_information_filling_space

Keep code in _get_main_color as similar as possible to how it was before

Write test

Make black-compliant

Fix error in newly introduced test_collecterror

Make tests more readable by using constants and f-strings

Remove accidentally added monkeypatch

Make Python 3.5-compatible, add changelog entry

Add newline at the end of changelog file
2019-11-04 19:57:07 +00:00
Daniel Hahler 9f800b2a77 test_terminal: reduce number of tests (single --fulltrace param)
Remove the `--fulltrace` arg from the `Option` fixture used in several
tests, but not checked for.  Only use it with `test_keyboard_interrupt`.

(removes 8 tests, coverage not affected)
2019-11-03 21:23:18 +01:00
Daniel Hahler 68dbc24dcb test_group_warnings_by_message: ignore own PytestExperimentalApiWarning 2019-11-03 21:14:24 +01:00
MarcoGorelli 9303de877a Fix error in newly introduced test_collecterror
Via https://github.com/pytest-dev/pytest/pull/6107.

(cherry picked from commit 1b9fbbfa195aa20c48574265935dc5e66b96ec16)
2019-11-03 18:16:46 +01:00
Daniel Hahler 3fb969897a
Merge pull request #6059 from blueyed/collect-error-short-summary
terminal: report collection errors as "ERROR" in short summary
2019-11-02 15:34:12 +01:00
Daniel Hahler 6df4d07a57
Merge pull request #6067 from blueyed/harden-test
tests: harden test_disabled_capture_fixture
2019-11-02 15:33:55 +01:00
Florian Bruhin 35800a2f73
Merge pull request #6112 from gaucheph/fix-small-typo
typos
2019-11-01 11:18:06 +01:00
Patrick Harmon abc890079f typos 2019-10-31 23:19:35 -05:00
David Szotten 285524c6cd Fix --trace for parametrized tests
Without this, the second time it tries to stop in a parametrized
function it raises instead:

`ValueError: --trace can't be used with a fixture named func!`

Implementation idea, test (and changelog tweaks) thanks to blueyed

Co-Authored-By: Ronny Pfannschmidt <opensource@ronnypfannschmidt.de>
Co-Authored-By: Daniel Hahler <git@thequod.de>
2019-10-31 21:41:33 +00:00
Joshua Storck 7a96d94fd4 Making it possible to access the pluginmanager in the pytest_addoption hook 2019-10-30 14:18:13 -04:00
Bruno Oliveira b99661b9d7 Introduce --report-log option
Fix #4488
2019-10-30 09:43:33 -03:00
Daniel Hahler 8c21416798 lsof_check: include exc with skip message 2019-10-29 15:25:15 +01:00
Daniel Hahler 6d2cabae57 terminal: fix line offset with skip reports
The original fix in https://github.com/pytest-dev/pytest/pull/2548 was
wrong, and was likely meant to fix the use with decorators instead,
which this does now (while reverting 869eed9898).
2019-10-29 13:11:02 +01:00
Daniel Hahler cdc53da19c
Merge pull request #5990 from MarcoGorelli/plurality-matching
Plurality matching
2019-10-28 17:03:15 +01:00
Daniel Hahler e7898dedf4
Merge pull request #6093 from blueyed/fix-flaky
tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
2019-10-28 16:17:46 +01:00
Daniel Hahler 60ceec6eb1 tests: fix testing/test_capture.py::test_typeerror_encodedfile_write
Failed for me due to different indent (?) - not reproducible:

    >   ???
    E   Failed: nomatch: 'E           TypeError: write() argument must be str, not bytes'
    …
    E       and: '>   def mode(self):'
    E       and: 'E   TypeError: write() argument must be str, not bytes'
    …
    E   remains unmatched: 'E           TypeError: write() argument must be str, not bytes'
2019-10-28 14:37:26 +01:00
Daniel Hahler a4554e666a tests: speed up test_faulthandler.test_timeout 2019-10-28 13:44:06 +01:00
Daniel Hahler d6e324a5e6 tests: conftest: handle tests using runpytest_subprocess as "slowest" 2019-10-28 13:43:42 +01:00
Daniel Hahler a5bd19e3b4 tests: lazily import doctest in approx tests 2019-10-28 12:55:16 +01:00
Daniel Hahler 32412532ef tests: mock doctest.DocTestRunner to not use real pdb
It is not used there anyway, and might cause false positives.
2019-10-28 12:55:16 +01:00
Daniel Hahler 820b747e7a tests: merge/remove test_dontreadfrominput_buffer_python3 2019-10-27 19:32:06 +01:00
MarcoGorelli d863c30c74 Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00:00
Daniel Hahler 886a3ad609 pytester: typing 2019-10-27 12:32:14 +01:00
Daniel Hahler 81c3bc76bc tests: harden test_disabled_capture_fixture 2019-10-27 03:02:24 +01:00
Daniel Hahler 7f1af84f47 Merge master into features
Conflicts:
	src/_pytest/logging.py
2019-10-27 02:06:36 +01:00
Bruno Oliveira cefe6bfec3
Replace a few outdated references to py.test with pytest (#6063)
Replace a few outdated references to py.test with pytest
2019-10-26 12:59:22 -03:00
Bruno Oliveira 6f20b4b014 Introduce compat.fspath 2019-10-26 10:37:44 -03:00
Ran Benita 0b8c35516f Replace py.io.TextIO with io.StringIO
In Python3, py.io.TextIO is just an alias to io.StringIO. Remove the
indirection.
2019-10-26 16:33:57 +03:00
Ran Benita 96de232791 Replace a few outdated references to py.test with pytest 2019-10-26 16:28:17 +03:00
Bruno Oliveira f93f284356 Support sys.pycache_prefix on py38
Fix #4730
2019-10-26 10:17:21 -03:00
Kale Kundert b9df9a4761
Merge pull request #6058 from AnjoMan/6057-tolerance-on-complex-approx
6057 tolerance on complex approx
2019-10-25 15:31:47 -04:00
Michael Krebs 1f5b454355 Add log-auto-indent option to control multiline formatting 2019-10-25 11:31:33 -04:00
Daniel Hahler 82753bec50 terminal: report collection errors as "ERROR" in short summary 2019-10-25 07:03:32 +02:00
AnjoMan 34a02121ad Drop python 2 unicode tests for approx repr 2019-10-24 23:44:13 -04:00
AnjoMan ed9fda84d3 Add tolerance to complex numbers 2019-10-24 23:44:13 -04:00
Bruno Oliveira fb0e8b99d1 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
- 	src/_pytest/cacheprovider.py
2019-10-24 21:13:43 -03:00
Bruno Oliveira d1bc2601e4
pytester: align prefixes (#6026)
pytester: align prefixes
2019-10-24 18:50:29 -03:00
Daniel Hahler 8ef4287bf0 pytester: align prefixes
This is important for using another match_nickname, e.g. "re.match".

TODO:

- [ ] changelog
- [ ] test
2019-10-24 23:20:12 +02:00
Daniel Hahler 45fc0d9cd8
Merge pull request #6040 from blueyed/test_meta-slow
tests: mark test_meta as slow
2019-10-24 22:53:04 +02:00
Bruno Oliveira 432e5550e5
assertrepr_compare: use safeformat with -vv (#5936)
assertrepr_compare: use safeformat with -vv
2019-10-23 19:51:40 -03:00
Ran Benita 7a2d2d8f07
Merge pull request #5847 from bluetech/type-annotations-4
2/X Fix check_untyped_defs = True mypy errors
2019-10-23 22:52:23 +03:00
Daniel Hahler 6242777818
Merge pull request #6041 from blueyed/pytester-splitlines
pytester: runpytest_inprocess: use splitlines()
2019-10-23 21:42:21 +02:00
Bruno Oliveira 20ee883b5f
Show the mnemonic of pytest.ExitCode in RunResult's repr (#6043)
Show the mnemonic of pytest.ExitCode in RunResult's repr
2019-10-23 10:46:58 -03:00
Bruno Oliveira 7beb520555 Show the mnemonic of pytest.ExitCode in RunResult's repr
Fix #4901
2019-10-23 09:16:02 -03:00
Bruno Oliveira ba4b8c869c Review rm_rf handling of FileNotFoundErrors 2019-10-23 08:30:52 -03:00
Ran Benita 1787bffda0 Fix check_untyped_defs errors in capture 2019-10-23 14:20:15 +03:00
Ran Benita 1984c10427 Fix check_untyped_defs errors in doctest
In order to make the LiteralOutputChecker lazy initialization more
amenable to type checking, I changed it to match the scheme already used
in this file to lazy-initialize PytestDoctestRunner.
2019-10-23 14:20:14 +03:00
Daniel Hahler db9e248b2e
Merge pull request #6039 from blueyed/test_doctest_id
doctest: unset RUNNER_CLASS in pytest_unconfigure
2019-10-23 11:38:59 +02:00
Daniel Hahler 2f589a9769 pytester: runpytest_inprocess: use splitlines()
This avoids having a trailing empty lines always.
2019-10-23 04:34:29 +02:00
Daniel Hahler b079dc2dbe Fix test_doctest_set_trace_quit on features 2019-10-23 04:13:37 +02:00
Daniel Hahler 4af89bba9d
Merge pull request #5061 from blueyed/summary_stats-multi-color
Multiple colors with terminal summary_stats
2019-10-23 03:21:39 +02:00
Daniel Hahler 5e7b2ae704 doctest: pytest_unconfigure: reset RUNNER_CLASS
This is important when used with ``pytester``'s ``runpytest_inprocess``.

Since 07f20ccab `pytest testing/acceptance_test.py -k test_doctest_id`
would fail, since the second run would not consider the exception to be
an instance of `doctest.DocTestFailure` anymore, since the module was
re-imported, and use another failure message then in the short test
summary info (and in the report itself):

> FAILED test_doctest_id.txt::test_doctest_id.txt - doctest.DocTestFailure: <Do...

while it should be:

> FAILED test_doctest_id.txt::test_doctest_id.txt
2019-10-23 03:09:41 +02:00
Daniel Hahler 82e9013e73
Merge pull request #6004 from blueyed/fix-nf
cache: NFPlugin: keep known nodeids
2019-10-23 01:04:48 +02:00
Bruno Oliveira f4734213e5 Merge remote-tracking branch 'upstream/features' into blueyed/pdb-doctest-bdbquit 2019-10-22 19:43:35 -03:00
Daniel Hahler 0dd68ba0b6 tests: mark test_meta as slow
This moves it to the end of tests during collection.  Takes ~7s for me.
2019-10-22 23:44:52 +02:00
Daniel Hahler 554dba391c Multiple colors with terminal summary_stats
Ref: https://github.com/pytest-dev/pytest/issues/5060
2019-10-21 04:35:45 +02:00
Daniil Galiev 9275012ef7 fix bug with nonskipped first test in package 2019-10-21 00:11:24 +02:00
Daniel Hahler 803cc1f294 Merge master into features 2019-10-21 00:08:03 +02:00
Daniel Hahler d91ff0af8a assertrepr_compare: use safeformat with -vv 2019-10-20 20:51:03 +02:00
Daniel Hahler 0123b29ed7 tests: remove unnecessary test, clarify
Follow-up to https://github.com/pytest-dev/pytest/pull/6009.
2019-10-20 20:40:13 +02:00
Bruno Oliveira 16efa1bfef
Merge pull request #6009 from yoavcaspi/fix_keyboardInterrupt_on_setup_show
setuponly: remove printing out/err from capman
2019-10-20 14:00:06 -03:00
Daniel Hahler fbb7f663be
Merge pull request #6005 from blueyed/harden-trial
tests: harden/fix test_trial_error
2019-10-20 17:35:15 +02:00
Yoav Caspi 5624e366c1 add more indications to the result of the tests 2019-10-20 09:54:23 +03:00
Anthony Sottile 3a402811de Ensure .pytest_cache file has a newline at the end 2019-10-19 14:42:06 -07:00
Bruno Oliveira b5579d2cf2
Make InvocationParams.args a tuple (#6008)
Make InvocationParams.args a tuple
2019-10-19 17:36:42 -03:00
Bruno Oliveira d12cdd3127 Make InvocationParams.args a tuple
This avoids mutating the original list to reflect on InvocationParams,
which is supposed to be an immutable snapshot of the state of pytest.main()
at the moment of invocation (see pytest-dev/pytest-xdist#478).
2019-10-19 16:42:58 -03:00
Yoav Caspi e05b33ed16 setuponly: remove printing out/err from capman 2019-10-19 22:33:19 +03:00
Daniel Hahler 15f9568694 Improve/revisit CallInfo.__repr__ 2019-10-19 19:07:11 +02:00
Daniel Hahler 5b88612e5b tests: harden/fix test_trial_error 2019-10-19 09:03:26 +02:00
Daniel Hahler 3173a26388 cache: NFPlugin: keep known nodeids
Caveat: does not forget about old nodeids

Fixes https://github.com/pytest-dev/pytest/issues/5206
2019-10-19 04:53:01 +02:00
Daniel Hahler 0976e2f50d Merge master into features 2019-10-18 17:51:42 +02:00
Daniel Hahler 7ef44913a1 tests: debugging: disable pdb++ within inner tests
Ref: https://github.com/pytest-dev/pytest/pull/5306#issuecomment-495690643
2019-10-18 17:08:39 +02:00
Daniel Hahler 90dfee5da5 tests: keep numpy being optional
Ref: https://github.com/pytest-dev/pytest/pull/5950#discussion_r335254774
2019-10-16 23:50:23 +02:00
Bruno Oliveira 914a9465ab
tests: move tests for setuponly/setupplan (#5961)
tests: move tests for setuponly/setupplan
2019-10-15 19:49:26 -03:00
Daniel Hahler c2ae0e0dc6 tests: move tests for setuponly/setupplan
Forgotten in 032ce8baf.
2019-10-15 00:41:05 +02:00
Daniel Hahler 361f0e6ba7 minor: test_failure_function: use vars 2019-10-14 22:45:25 +02:00
Victor Maryama 63e3d89647 Fixed linting. 2019-10-12 15:08:47 +02:00
Victor Maryama 1f639e2c22 Casting fixture parameter to list at the beginning of parameter parsing. 2019-10-12 14:33:43 +02:00
Daniel Hahler fb90259460 test_assertion: improve mock_config 2019-10-11 04:19:07 +02:00
Daniel Hahler 2a2fe7d3db Improve ExceptionInfo.__repr__ 2019-10-09 19:27:46 +02:00
Daniel Hahler 21c038f304 Merge master into features 2019-10-08 18:57:15 +02:00
Daniel Hahler 946434c610 Improve full diff output for lists
Massage text input for difflib when comparing pformat output of
different line lengths.

Also do not strip ndiff output on the left, which currently already
removes indenting for lines with no differences.

Before:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E     - ['version', 'version_info', 'sys.version', 'sys.version_info']
    E     + ['version',
    E     +  'version_info',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info']

After:

    E   AssertionError: assert ['version', '...version_info'] == ['version', '...version', ...]
    E     Right contains 3 more items, first extra item: ' '
    E     Full diff:
    E       [
    E        'version',
    E        'version_info',
    E        'sys.version',
    E        'sys.version_info',
    E     +  ' ',
    E     +  'sys.version',
    E     +  'sys.version_info',
    E       ]
2019-10-08 15:27:51 +02:00
Anthony Sottile 3fada8c8ee
Merge pull request #5925 from asottile/fix_resource_warning_again_5088
Fix spurious ResourceWarning stderr in testsuite again
2019-10-07 16:26:38 -07:00
Anthony Sottile 19eb0590f1 Fix spurious ResourceWarning stderr in testsuite again 2019-10-06 19:11:33 -07:00
Bruno Oliveira 5186635387
Introduce no_fnmatch_line/no_re_match_line in pytester (#5914)
Introduce no_fnmatch_line/no_re_match_line in pytester
2019-10-06 20:27:20 -03:00
Anthony Sottile eaa05531ed Add test to ensure _pytest is warning-clean on import 2019-10-06 14:11:08 -07:00
Bruno Oliveira 47c2091ecd Use new no-match functions to replace previous idiom 2019-10-06 18:05:24 -03:00
Bruno Oliveira 0c18e24433 Introduce no_fnmatch_line/no_re_match_line in pytester
The current idiom is to use:

  assert re.match(pat, result.stdout.str())

Or

  assert line in result.stdout.str()

But this does not really give good results when it fails.

Those new functions produce similar output to ther other match lines functions.
2019-10-06 18:05:24 -03:00
Daniel Hahler 07f20ccab6 Allow for "pdb" module to be rewritten 2019-10-06 23:02:24 +02:00
Anthony Sottile c58b0fb4ac Use ATTRS_EQ_FIELD for attrs 19.2 compat 2019-10-05 18:16:35 -07:00
Hynek Schlawack a79acf279a Fix warnings with attrs 19.2 and fix object assertions
attrs 19.2 deprecated cmp in favor of the dataclass-ish eq/order duo.

This causes deprecation warnings that in turn break some of the cool new deep
object comparisons. Since we at attrs expected this to be a problem, it shipped
with helpers to write backward and forward compatible code.

This PR uses that and avoids changed to minimal versions.
2019-10-01 20:47:59 +02:00