Commit Graph

775 Commits

Author SHA1 Message Date
Simon K de6c28ed1f
Improve error handling around yieldctx fixtures which do not yield a value (#7083) 2020-04-15 12:17:13 +03:00
Ran Benita 03451c397f Simplify positional arguments compatibility code in pytest.fixture()
The dynamic scope feature added in 10bf6aac76
necessitated some wrangling of arguments in pytest.fixture(). In
particular, it deprecated positional arguments in favor of keyword-only
arguments, while keeping backward compatibility.

The way it did this avoided some code duplication but ended up being
quite hard to follow and to annotate with types.

Replace it with some straightforward code, which is not very DRY but is
simple and easy to remove when the time comes.
2020-04-02 14:52:58 +03:00
Bruno Oliveira 010e711971 Merge pull request #6914 from nicoddemus/revert-6330
Revert "[parametrize] enforce explicit argnames declaration (#6330)"
2020-03-13 10:49:48 -03:00
earonesty 7667ff51e7 Update fixtures.py 2020-03-03 09:59:38 -03:00
Daniel Hahler c8b4a1a471
Handle `match` with `pytest.raises()` (#6753)
Fixes https://github.com/pytest-dev/pytest/issues/6752.
2020-02-22 23:32:55 +01:00
Daniel Hahler 2be06ba67e
Improve doc/typing/message for `ExceptionInfo.match` (#6776) 2020-02-21 16:41:57 +01:00
Ran Benita 24dcc76495 Use a hack to make typing of pytest.fail.Exception & co work
Mypy currently is unable to handle assigning attributes on function:
https://github.com/python/mypy/issues/2087.
pytest uses this for the outcome exceptions -- `pytest.fail.Exception`,
`pytest.exit.Exception` etc, and this is the canonical name by which they
are referred.

Initially we started working around this with type: ignores, and later
by switching e.g. `pytest.fail.Exception` with the direct exception
`Failed`. But this causes a lot of churn and is not as nice. And I also
found that some code relies on it, in skipping.py:

    def pytest_configure(config):
        if config.option.runxfail:
            # yay a hack
            import pytest

            old = pytest.xfail
            config._cleanup.append(lambda: setattr(pytest, "xfail", old))

            def nop(*args, **kwargs):
                pass

            nop.Exception = xfail.Exception
            setattr(pytest, "xfail", nop)
        ...

So it seems better to support it. Use a hack to make it work. The rest
of the commit rolls back all of the workarounds we added up to now.

`pytest.raises.Exception` also exists, but it's not used much so I kept
it as-is for now.

Hopefully in the future mypy supports this and this ugliness can be
removed.
2020-02-18 23:17:27 +02:00
Ran Benita 7b8968ff80
Merge pull request #6735 from bluetech/metafunc-annotate
Type annotate Metafunc
2020-02-15 23:32:14 +02:00
Ran Benita 5945c3fe88 Type annotate Metafunc 2020-02-15 17:13:18 +02:00
Daniel Hahler 83137c89e9
tests: test_unicode_plus_minus: use unicode sign directly (#6727)
Was globbed for Python 2 before (57c448991).
2020-02-14 02:16:25 +01:00
Ran Benita d33da078a8 Move ExitCode's definition from _pytest.main to _pytest.config
ExitCode is used in several internal modules and hooks and so with type
annotations added, needs to be imported a lot.

_pytest.main, being the entry point, generally sits at the top of the
import tree.

So, it's not great to have ExitCode defined in _pytest.main, because it
will cause a lot of import cycles once type annotations are added (in
fact there is already one, which this change removes).

Move it to _pytest.config instead.

_pytest.main still imports ExitCode, so importing from there still
works, although external users should really be importing from `pytest`.
2020-02-10 23:55:06 +02:00
Vladyslav Rachek 9e262038c8
[parametrize] enforce explicit argnames declaration (#6330)
Every argname used in `parametrize` either must
be declared explicitly in the python test function, or via
`indirect` list

Fix #5712
2020-02-06 20:20:25 -03:00
Bruno Oliveira 64ab68ff0a
Fix 6341 disallow session config in fromparent (#6387)
Fix 6341 disallow session config in fromparent
2020-01-29 19:21:02 -03:00
Anthony Sottile 595d62bc3e
Merge pull request #6607 from asottile/empty_string_parametrize_nodeid
Fix node ids which contain a parametrized empty-string variable
2020-01-29 08:42:04 -08:00
Daniel Hahler 55e5817570 Merge master into features 2020-01-29 03:07:35 +01:00
Bruno Oliveira d282424589
Fix unguarded `==` comparison in fixtures. (#6541)
Fix unguarded `==` comparison in fixtures.
2020-01-28 20:54:14 -03:00
Anthony Sottile abd5fc80e8 Fix node ids which contain a parametrized empty-string variable 2020-01-28 13:27:54 -08:00
Holger Kohr 80d4dd6f0b Replace `==` with `is` for comparison of cache keys
Closes #6497
2020-01-28 18:05:53 -03:00
Daniel Hahler 1cf9e68dbc tests: cover absolute path handling in _compute_fixture_value 2020-01-28 18:53:28 +01:00
Daniel Hahler 09bdbffbde Merge master into features
Conflicts:
	src/_pytest/_code/code.py
	src/_pytest/main.py
2020-01-24 23:44:50 +01:00
Daniel Hahler 192d3adda3 tests: add test_fixture_arg_ordering
This is a regression test for part of
https://github.com/pytest-dev/pytest/issues/6492, testing one of the
fixes in https://github.com/pytest-dev/pytest/pull/6551.
2020-01-24 17:48:08 -03:00
Daniel Hahler e7444bbd5e tests: remove unnecessary `-rw` option
Warnings are enabled by default, which is tested by `test_getreportopt`.
2020-01-23 11:37:19 +01:00
Bruno Oliveira 93b74d28d2 Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
 * 	src/_pytest/_code/code.py
 * 	src/_pytest/main.py
 * 	testing/python/metafunc.py
 * 	testing/test_parseopt.py
 * 	testing/test_pytester.py
2020-01-22 11:03:45 -03:00
Ran Benita fb99b5c66e Revert "Fix type errors after adding types to the `py` dependency"
This reverts commit 930a158a6a.

Regression test from Bruno Oliveira.
2020-01-20 23:44:56 +02:00
Bruno Oliveira cdaa9c06e1
Revert "fixtures register finalizers with all fixtures before t… (#6496)
Revert "fixtures register finalizers with all fixtures before them in the stack"
2020-01-20 13:49:00 -03:00
Ran Benita 930a158a6a Fix type errors after adding types to the `py` dependency 2020-01-19 14:48:24 +02:00
Bruno Oliveira cc7f294cfe Revert "fixtures register finalizers with all fixtures before them in the stack"
This reverts commit 99180939fe.
2020-01-17 12:55:57 -03:00
Daniel Hahler 5049e25a6a tests: cleanup unused fixtures 2020-01-16 21:12:48 +01:00
Daniel Hahler 83813bf515 Merge master into features
Conflicts:
	.github/workflows/main.yml
2020-01-16 19:45:52 +01:00
Chris NeJame 99180939fe fixtures register finalizers with all fixtures before them in the stack 2020-01-15 11:00:42 -05:00
Ronny Pfannschmidt 8ba0b7bc2a fix #6341 - disallow session/config in Node.from_parent 2020-01-15 13:00:46 +01:00
Bruno Oliveira e9d9f71374 Merge remote-tracking branch 'upstream/master' into mm 2020-01-14 09:17:52 -03:00
Daniel Hahler f0c7f21312 Remove "pragma: no cover" comments 2020-01-14 09:15:36 +01:00
Ronny Pfannschmidt c99c7d0f95 deprecate direct node construction and introduce Node.from_parent 2019-11-23 21:54:11 +01:00
Daniel Hahler ed012c808a
Merge pull request #6174 from blueyed/ids-iter
parametrized: ids: support generator/iterator
2019-11-21 00:37:25 +01:00
Daniel Hahler 6b75a7733b
Merge pull request #6247 from blueyed/collecterror-fulltrace
Respect --fulltrace with collection errors
2019-11-21 00:27:23 +01:00
Daniel Hahler 2d449e95e4 Respect --fulltrace with collection errors 2019-11-20 23:35:33 +01:00
Daniel Hahler 2c941b5d13 parametrized: ids: support generator/iterator
Fixes https://github.com/pytest-dev/pytest/issues/759

- Adjust test_parametrized_ids_invalid_type, create list to convert tuples
  Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552922498

- Changelog for int to str conversion
  Ref: https://github.com/pytest-dev/pytest/issues/1857#issuecomment-552932952
2019-11-20 19:02:17 +01:00
Daniel Hahler ccb3ef3b33 testing/python/metafunc.py: import _idval once 2019-11-20 18:02:30 +01:00
Daniel Hahler 4ad61cbcf6 Improve check for misspelling of parametrize
- there is no need to do this with `--strict-markers`
- it can be done when looking up marks, instead of for every generated
  test
2019-11-19 16:05:52 +01:00
Daniel Hahler 2ad2fbc9a2 Metafunc: remove hack for DefinitionMock
Done initially in 99015bfc8.
2019-11-18 18:19:34 +01:00
Anthony Sottile a2d48332fc
Merge pull request #6201 from asottile/mm
Merge master into features
2019-11-17 11:30:51 -08:00
Daniel Hahler 54a954514b re-run black 2019-11-16 18:55:32 +01:00
Anthony Sottile cc78444c30 Merge remote-tracking branch 'origin/master' into mm 2019-11-15 15:26:57 -08:00
Bruno Oliveira 6f2c0fd2e8 Show a better message when 'request' is used in parametrize
Fix #6183
2019-11-13 19:57:10 -03: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
Daniel Hahler 4e45472405 Merge master into features
Conflicts:
	src/_pytest/debugging.py
2019-11-06 14:22:07 +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
Patrick Harmon abc890079f typos 2019-10-31 23:19:35 -05: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
MarcoGorelli d863c30c74 Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00:00
Daniel Hahler 7f1af84f47 Merge master into features
Conflicts:
	src/_pytest/logging.py
2019-10-27 02:06:36 +01:00
Ran Benita 96de232791 Replace a few outdated references to py.test with pytest 2019-10-26 16:28:17 +03: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
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
Yoav Caspi 5624e366c1 add more indications to the result of the tests 2019-10-20 09:54:23 +03:00
Yoav Caspi e05b33ed16 setuponly: remove printing out/err from capman 2019-10-19 22:33:19 +03:00
Daniel Hahler 0976e2f50d Merge master into features 2019-10-18 17:51:42 +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
Daniel Hahler c2ae0e0dc6 tests: move tests for setuponly/setupplan
Forgotten in 032ce8baf.
2019-10-15 00:41:05 +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
Bruno Oliveira 47c2091ecd Use new no-match functions to replace previous idiom 2019-10-06 18:05:24 -03:00
Bruno Oliveira 7bdfba3578 Fix --setup-only and --setup-show for custom pytest items
Fix #5884
2019-09-28 11:52:09 -03:00
Andrzej Klajnert e2382e96ed Minor cleanup in tests. 2019-09-19 11:13:22 +02:00
Bruno Oliveira df46afc96d Change fixture argument handling tests to unit-tests 2019-09-18 07:50:35 -03:00
Bruno Oliveira 6918d07560 Merge remote-tracking branch 'upstream/features' into aklajnert/1682-dynamic-scope 2019-09-18 07:44:18 -03:00
aklajnert 10bf6aac76 Implemented the dynamic scope feature. 2019-08-31 18:12:24 +02:00
Bruno Oliveira bd57307a39
Merge pull request #5768 from robholt/fixture-class-instance
Fix self reference in function scoped fixtures
2019-08-30 12:31:16 -03:00
Bruno Oliveira 955dc6d18a Merge remote-tracking branch 'upstream/master' into robholt/fixture-class-instance 2019-08-30 11:21:33 -03:00
Bruno Oliveira 3ddbc7fb2a Improve CHANGELOG and add some comments
Ref: #5768
2019-08-30 11:20:19 -03:00
Bruno Oliveira 35b3b1097f Improve CHANGELOG and make test easier to understand for #570 2019-08-30 10:54:58 -03:00
Andrzej Klajnert 487659d8b1 Fix the scope behavior with indirect fixtures. 2019-08-29 07:23:08 +02:00
Ran Benita 43eab917a1 Fix coverage 2019-08-20 15:41:32 +03:00
Ran Benita a7c235732a Pypy doesn't have sys.getrefcount(), so go back to gc 2019-08-20 11:47:22 +03:00
Ran Benita cec2183aeb Add workaround for test_raises_cyclic_reference in Python 3.5.{0,1} 2019-08-20 11:19:25 +03:00
Robert Holt 62381125e7
Fix self reference in function scoped fixtures 2019-08-19 15:57:39 -04:00
Bruno Oliveira 8ccc0177c8
Release 5.1.0 (#5748)
Release 5.1.0
2019-08-15 22:35:59 -03:00
Daniel Hahler 6ead01aacd testing/python/fixtures.py: use NotImplementedError pattern 2019-08-16 01:14:19 +02:00
Bruno Oliveira d7f082519a Merge remote-tracking branch 'upstream/master' into mm
Conflicts:
	src/_pytest/outcomes.py
2019-08-15 10:03:52 -03:00
Thomas Grainger 137255816e Fix collection of staticmethods defined with functools.partial
Related to #5701
2019-08-15 08:04:05 -03:00
Bruno Oliveira 2f065a555f Merge remote-tracking branch 'upstream/master' into release-5.1.0 2019-08-09 12:36:19 -03:00
Thomas Grainger ef0915e1db
fix grammar in test_collect_functools_partial docstr 2019-08-06 15:27:36 +01:00
Daniel Hahler b5b710b3ae Merge master into features
Several conflicts, mostly due to 2c402f4bd.

Conflicts:
	.pre-commit-config.yaml
	src/_pytest/outcomes.py
	src/_pytest/python_api.py
	tox.ini
2019-08-02 16:52:51 +02:00
Bruno Oliveira 240d314f36 copy test and changelog from #5607 by @niccodemus 2019-07-20 20:21:27 +02:00
Ran Benita faf222f8fb
Merge pull request #5593 from bluetech/type-annotations-1
Type-annotate pytest.{exit,skip,fail,xfail,importorskip,warns,raises}
2019-07-16 22:38:20 +03:00
Bruno Oliveira 65c23017c7 Update test_getfuncargnames_patching to work with modern mock 2019-07-15 12:23:59 -03:00
Bruno Oliveira 8a3f40996a Remove obsolete "importorskip('unittest.mock')" calls 2019-07-15 11:18:05 -03:00
Ran Benita 866904ab80 Revert "Let context-managers for raises and warns handle unknown keyword arguments"
This reverts commit dfe54cd82f.

The idea in the commit was to simplify the code by removing the check
and instead letting it TypeError which has the same effect.

However this type error is caught by mypy, and rather than ignoring the
error we think it's better and clearer to go back to the previous
explicit check.
2019-07-14 14:28:21 +03:00
Ronny Pfannschmidt 2c071a060e refactor resolve_arg_value_types
* more explicit type checks
* expand from list+tuple to sequence
2019-07-13 08:13:46 +02:00
Bruno Oliveira 31738155b5
Remove deprecated features (#5529)
Remove deprecated features
2019-07-09 19:04:06 -03:00
Ran Benita 89dfde9535 Add rudimentary mypy type checking
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.

This enables:

- Progressively adding type annotations and enabling more strict
  options, which will improve the codebase (IMO).

- Annotating the public API in-line, and eventually exposing it to
  library users who use type checkers (with a py.typed file).

Though, none of this is done yet.

Refs https://github.com/pytest-dev/pytest/issues/3342.
2019-07-09 12:12:07 -07:00
Anthony Sottile 39a43dbae1
Merge pull request #5575 from bluetech/mypy-initial
Add rudimentary mypy type checking
2019-07-09 08:05:14 -07:00
Ran Benita c1167ac552 Add rudimentary mypy type checking
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.

This enables:

- Progressively adding type annotations and enabling more strict
  options, which will improve the codebase (IMO).

- Annotating the public API in-line, and eventually exposing it to
  library users who use type checkers (with a py.typed file).

Though, none of this is done yet.

Refs https://github.com/pytest-dev/pytest/issues/3342.
2019-07-09 10:49:17 +03:00
Anthony Sottile caa08ebd45 Improve quoting in raises match failure message 2019-07-04 05:55:26 -07:00
Bruno Oliveira 0ed7aa2db6 Make 'request' a reserved name for fixtures 2019-06-30 13:31:39 -03:00
Bruno Oliveira c470ade0a5 Remove 'RemovedInPytest4Warning' 2019-06-30 13:31:39 -03:00
Bruno Oliveira 13f7f27fd2 Remove 'message' parameter from pytest.raises 2019-06-30 13:18:06 -03:00
Bruno Oliveira 279733a30b Remove support for 'code as string' from pytest.raises and pytest.warns 2019-06-30 11:40:24 -03:00
Bruno Oliveira be91c4d932 Remove Request.getfuncargvalue 2019-06-30 11:02:46 -03:00
Bruno Oliveira 37fb50a3ed
Features assertion pass hook (#3479)
Features assertion pass hook
2019-06-26 21:14:19 -03:00
Victor Maryama 6f851e6cbb Merge remote-tracking branch 'upstream/master' into features-assertion-pass-hook-master
# Conflicts:
#	src/_pytest/assertion/rewrite.py
2019-06-26 18:12:56 +02:00
Zac Hatfield-Dodds ed85c83154 Deprecate funcargnames alias 2019-06-26 08:53:17 +10:00
Kevin J. Foley 95714436a1 Pickup additional positional args passed to _parse_parametrize_args 2019-06-24 20:43:52 -04:00
Victor Maryama 9a89783fbb Assertion passed hook 2019-06-24 16:09:39 +02:00
Bruno Oliveira 689ce112e7
Small cleanups on _pytest.compat (#5451)
Small cleanups on _pytest.compat
2019-06-16 10:42:07 -03:00
Bruno Oliveira 177af032d2 Remove unused/unneeded code 2019-06-15 10:45:16 -03:00
Ronny Pfannschmidt 2b92fee1c3 initial conversion of exit codes to enum 2019-06-15 06:48:00 +02:00
Anthony Sottile ccd87f9e80 small mypy fixes 2019-06-06 09:13:02 -07:00
Bruno Oliveira 8f5cb461a8 Turn PytestDeprecationWarning into error
Fix #5402
2019-06-05 19:02:52 -03:00
Anthony Sottile be2be040f9 Clean up u' prefixes and py2 bytes conversions 2019-06-04 17:50:34 -07:00
Anthony Sottile 5dcf85c17e manual: remove dependence on six 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 5034399d7a pre-commit run fix-encoding-pragma --all-files 2019-06-03 12:08:01 -03: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
Victor Maryama 65bd1b8a93 Avoiding looking upwards for parameter argnames when generating fixtureinfo. 2019-05-30 23:42:04 +02:00
Bruno Oliveira 5cbc06a453 Show test module in the PytestCollectionWarning message
Related to #5330
2019-05-30 08:18:28 -03: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
Akiomi Kamakura 8a498700da Add tests for #5286 2019-05-22 03:56:52 +09: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
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 6d040370ed Show fixture scopes with ``--fixtures``, except for "function" scope
Fix #5220
2019-05-07 14:32:20 -03:00
Daniel Hahler 6f0a5789fb Merge master into features 2019-04-14 23:22:21 +02:00
Anthony Sottile da2e092163 pre-commit autoupdate 2019-04-12 04:52:47 -07:00
Zac-HD 00810b9b2a Register "issue" mark for self-tests 2019-03-31 14:22:30 +11:00
Daniel Hahler e1ae469504 Merge master into features 2019-03-26 10:23:21 +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 3127ec737b Fix pytest's own tests with `-W error::ResourceWarning` 2019-03-24 11:05:00 +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 05d55b86df tests: minor sys.path cleanup 2019-03-22 16:20:55 +01: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 c334adc78f
Apply suggestions from code review
Co-Authored-By: nicoddemus <nicoddemus@gmail.com>
2019-03-03 11:20:00 -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
Anthony Sottile 4c7ddb8d9b Fix `parametrize(... ids=<function>)` when the function returns non-strings. 2019-02-07 12:25:59 -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 ade5f2c8c5 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2019-01-29 19:36:56 -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
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
Anthony Sottile ec5e279f93 Remove and ban use of py.builtin 2019-01-20 11:59:48 -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 0f918b1a9d xunit-style functions and methods are invoked by autouse fixtures
Fix #3094, Fix #517
2019-01-10 12:10:04 -02:00
Bruno Oliveira c378cb4793 Remove support for applying marks to values in parametrize
Fix #3082
2018-12-20 16:16:13 -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
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 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 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
Daniel Hahler 8e287c5c77 Merge master into features 2018-12-14 16:44:43 +01:00
Bruno Oliveira 1e80a9cb34 Remove pytest_funcarg__ prefix support for defining fixtures
Fix #4543
2018-12-13 21:41:38 -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
Bruno Oliveira e3d30f8ebf Remove deprecated PyCollector.makeitem
Fix #4535
2018-12-12 14:15:52 -02: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
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
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
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
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 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 b71bd9b300 fix #4386 - handle uninitialized exceptioninfo in repr/str 2018-11-22 20:52:15 +01:00
Anthony Sottile b3700f61ba Fix formatting of print() calls 2018-11-22 00:15:14 -08: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 3d92d5a659 Make sure parametrize ids are printable 2018-11-19 11:03:52 -08: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
Bruno Oliveira dc20dedbc7 Change RemovedInPytest4Warnings to errors by default
To keep existing tests which emit RemovedInPytest4Warnings running, decided
to go with a command line option because:

* Is harder to integrate an ini option with tests which already use an ini file
* It also marks tests which need to be removed/updated in 4.1, when
  RemovedInPytest4Warning and related functionality are removed.

Fix #3737
2018-11-12 16:10:57 -02:00
Daniel Hahler f551cb9677 Skip Instances with --collect-only 2018-11-10 23:48:02 +01:00
Daniel Hahler e30f7094f3 python: collect: ignore exceptions with isinstance
Fixes https://github.com/pytest-dev/pytest/issues/4266.
2018-11-01 22:14:13 +01:00
Anthony Sottile 2368fbb63c Apply reorder-python-imports to all files 2018-10-25 00:01:29 -07:00
Bruno Oliveira 02ae7d8531 Improve error message when a recursive dependency between fixtures is detected
Fix #2909
2018-10-20 09:44:42 -03:00
Bruno Oliveira 9646a1cd7a Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-10-15 12:55:28 -03:00
Bruno Oliveira 4808145846 test_request_garbage is flaky when running with xdist
Example failure:

https://travis-ci.org/pytest-dev/pytest/jobs/441305926#L545
2018-10-14 15:17:08 -03:00
Bruno Oliveira 933de16fe4
Merge pull request #3988 from RonnyPfannschmidt/tmpdir-port-pathlib
Tmpdir port pathlib
2018-10-12 08:33:47 -03:00
Ronny Pfannschmidt 00716177b4 fix missed Path import 2018-10-11 07:15:09 +02:00
Bruno Oliveira 5436e42990 Use pytest.fail(..., pytrace=False) when treating user errors
This prevents an enormous and often useless stack trace from showing
to end users.

Fix #3867
Fix #2293
2018-10-10 19:16:53 -03:00
Bruno Oliveira 9a3836a0cf Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-10-09 19:34:04 -03:00
Anthony Sottile 1caf6d5907 Upgrade pre-commit hooks 2018-10-08 10:10:46 -07:00
Ronny Pfannschmidt 66609665f2
Merge pull request #4076 from nicoddemus/unittest-param-fixture-msg
Improve error message when TestCase functions use a parametrized fixture
2018-10-06 07:43:57 +02:00
Bruno Oliveira 212937eb3e Improve error message when TestCase functions use a parametrized fixture
Fix #2535
2018-10-03 19:43:46 -03:00
Bruno Oliveira 70c7273640 Fix request.fixturenames to return fixtures created dynamically
Fix #3057
2018-10-03 18:50:14 -03:00
Bruno Oliveira 56d0b5a7e2 Merge remote-tracking branch 'upstream/master' into merge-master-into-features 2018-09-22 18:14:36 -03:00
Bruno Oliveira 41f6ea13ce Fix 'Package has no len()' error during collection
Fix #3749
2018-09-20 17:53:21 -03:00
Bruno Oliveira 27772f67c0
Merge pull request #3987 from nicoddemus/fix-find-scope-3941
Fix scope determination with indirect parameters
2018-09-19 20:06:45 -03:00
Bruno Oliveira 86a14d007d Fix scope determination with indirect parameters
Fix #3941
2018-09-14 21:33:59 -03:00