Commit Graph

75 Commits

Author SHA1 Message Date
Ran Benita ed658d6829 Some py.path.local -> pathlib.Path
- Some conftest related functions
- _confcutdir
- Allow arbitrary os.PathLike[str] in gethookproxy.
2020-12-12 17:33:28 +02:00
Ran Benita f1e6fdcddb Export types of builtin fixture for type annotations
In order to allow users to type annotate fixtures they request, the
types need to be imported from the `pytest` namespace. They are/were
always available to import from the `_pytest` namespace, but that is
not guaranteed to be stable.

These types are only exported for the purpose of typing. Specifically,
the following are *not* public:

- Construction (`__init__`)
- Subclassing
- staticmethods and classmethods

We try to combat them being used anyway by:

- Marking the classes as `@final` when possible (already done).

- Not documenting private stuff in the API Reference.

- Using `_`-prefixed names or marking as `:meta private:` for private
  stuff.

- Adding a keyword-only `_ispytest=False` to private constructors,
  warning if False, and changing pytest itself to pass True. In the
  future it will (hopefully) become a hard error.

Hopefully that will be enough.
2020-11-13 11:25:09 +02:00
Ran Benita 4c0513bc18 fixtures: deprecate pytest.yield_fixture() 2020-11-07 17:06:40 +02:00
Ran Benita d6becfa177 fixtures: change _getautousenames to an iterator
This reads better.
2020-10-25 00:49:06 +03:00
Manuel Mariñez 13ddec9a00
Add alias clarification to deprecation warning (#7829)
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-10-06 11:48:34 -03:00
Anthony Sottile f81c6c00a9
Merge pull request #7852 from asottile/py36_pyupgrade
py36+: pyupgrade: py36+
2020-10-04 08:25:32 -07:00
Ran Benita bf09e7792f fixtures: some type annotations 2020-10-04 09:43:58 +03:00
Anthony Sottile 66bd44c13a py36+: pyupgrade: py36+ 2020-10-03 12:46:54 -07:00
Anthony Sottile fb1d550aac py36+: remove rexport of Path and PurePath 2020-10-03 12:16:52 -07:00
Bruno Oliveira c00fe960ba Allow ovewriting a parametrized fixture while reusing the parent fixture's value
Fix #1953
2020-09-11 16:53:34 -03:00
Bruno Oliveira c747dc5248 Drop support for positional arguments in @pytest.fixture 2020-08-19 08:11:42 -03:00
Bruno Oliveira 98530184a5 Remove funcargnames compatibility property 2020-08-19 08:11:39 -03:00
Ran Benita b8471aa527 testing: fix some docstring issues
In preparation for enforcing some docstring lints.
2020-08-03 10:10:43 +03:00
Ran Benita 8d98de8f8a typing: set no_implicit_reexport
In Python, if module A defines a name `name`, and module B does `import
name from A`, then another module C can `import name from B`.

Sometimes it is intentional -- module B is meant to "reexport" `name`.
But sometimes it is just confusion/inconsistency on where `name` should
be imported from.

mypy has a flag `--no-implicit-reexport` which puts some order into
this. A name can only be imported from a module if

1. The module defines the name
2. The module's `__all__` includes the name
3. The module imports the name as `from ... import .. as name`.

This flag is included in mypy's `--strict` flag.

I like this flag, but I realize it is a bit controversial, and in
particular item 3 above is a bit unfriendly to contributors who don't
know about it. So I didn't intend to add it to pytest.

But while investigating issue 7589 I came upon mypy issue 8754 which
causes `--no-implicit-reexport` to leak into installed libraries and
causes some unexpected typing differences *in pytest* if the user uses
this flag.

Since the diff mostly makes sense, let's just conform to it.
2020-07-31 10:09:11 +03:00
Ran Benita c15bb5d3de pathlib: replace py.path.local.visit() with our own function
Part of reducing dependency on `py`. Also enables upcoming improvements.

In cases where there are simpler alternatives (in tests), I used those.

What's left are a couple of uses in `_pytest.main` and `_pytest.python`
and they only have modest requirements, so all of the featureful code
from py is not needed.
2020-07-25 00:26:49 +03:00
Ran Benita a2f021b6f3 Remove no longer needed `noqa: F821` uses
Not needed since pyflakes 2.2.0.
2020-07-10 13:08:56 +03:00
Ran Benita f00bec2a12 Replace yield_fixture -> fixture in internal code
`yield_fixture` is a deprecated alias to `fixture`.
2020-06-25 14:05:46 +03:00
Bruno Oliveira db00612b84
Merge pull request #7364 from nicoddemus/parseoutcomes-plural-6505
assertoutcomes() only accepts plural forms
2020-06-15 20:27:40 -03:00
Bruno Oliveira ab6dacf1d1
Introduce --import-mode=importlib (#7246)
Fix #5821

Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-13 11:29:01 -03:00
Bruno Oliveira 3151219785 assertoutcomes() only accepts plural forms
Fix #6505
2020-06-13 10:29:22 -03:00
Ran Benita 2833884688 Type annotate pytest.fixture and more improvements to _pytest.fixtures 2020-06-05 11:34:20 +03:00
Bruno Oliveira 5dd987e10f
Merge pull request #6999 from bluetech/simplify-fixture-compat 2020-05-08 08:06:35 -03:00
Ran Benita 907e29a47b fixtures: deprecate pytest._fillfuncargs function
This function is exposed and kept alive for the oejskit plugin which is
abandoned and no longer works with recent plugins, so let's prepare to
completely remove it.
2020-04-24 18:54:46 +03:00
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
earonesty 7667ff51e7 Update fixtures.py 2020-03-03 09:59:38 -03:00
Bruno Oliveira d282424589
Fix unguarded `==` comparison in fixtures. (#6541)
Fix unguarded `==` comparison in fixtures.
2020-01-28 20:54:14 -03: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 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
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
Chris NeJame 99180939fe fixtures register finalizers with all fixtures before them in the stack 2020-01-15 11:00:42 -05:00
Daniel Hahler 54a954514b re-run black 2019-11-16 18:55:32 +01:00
MarcoGorelli d863c30c74 Fix plurality mismatch for and in pytest terminal summary 2019-10-27 15:16:24 +00: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
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
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 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
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