Permalink
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also .
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
23
contributors
Commits on Jul 24, 2020
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.
`os.scandir()`, introduced in Python 3.5, is much faster than `os.listdir()`. See https://www.python.org/dev/peps/pep-0471/. It also has a `DirEntry` which can be used to further reduce syscalls in some cases.
Commits on Jul 28, 2020
The links were still pointing to the latest version (instead of stable) and also took the opportunity to update the text a bit.
Commits on Jul 29, 2020
Merge pull request #7550 from pytest-dev/release-6.0.0
Extra colon to make code block render correctly
…again Apparently the previous fix c1ca42b didn't work. Hopefully this time I'm testing this correctly.
Instead of slowing down startup, and making the code harder to follow, compile it lazily (it is still cached internally).
1. Remove sys.maxunicode check & comment. Nowadays it is always a constant 0x10ffff. 2. Pre-generate the pattern. Possible due to 1. 3. Compile the regex lazily. No reason to pay startup cost for it. 4. Add docstring in particular to explain a subtle point.
Part of the effort to reduce dependency on the py library. Besides that, py.xml implements its own XML serialization which is pretty scary. I tried to keep the code with minimal changes (though it could use some cleanups). The differences in behavior I have noticed are: - Attributes in the output are not sorted. - Some unneeded escaping is no longer performed, for example escaping `"` to `"` in a text node.
We now only use `py.path.local`.
mark: fix pylint not-callable error on pytest.mark.parametrize(...), again
junitxml: convert from py.xml to xml.etree.ElementTree
pathlib: stop using py.path.local.visit(), use os.scandir
mark: fix extraneous spaces in dummy type-checking marks
….set_level() This probably regressed in fcbaab8.
logging: fix capture handler level not reset on teardown after caplog.set_level()
…ies-release-process
As discussed in #7556
Co-authored-by: mattreex <mattreex.9@gail.com> Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Commits on Jul 30, 2020
Add missing changelog for issue 7569
Prepare release 6.0.1 (cherry picked from commit 022bff2)
We barely use it; the couple places that do are not really worth the extra dependency, I think the code is clearer without it. Also simplifies one (regular) itertools usage. Also improves a check and an error message in `pytest.raises`.
Commits on Jul 31, 2020
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.
Stop using more-itertools
Commits on Aug 01, 2020
Merge pull request #7584 from pytest-dev/release-6.0.1
typing: set no_implicit_reexport
Format docstrings in a consistent style
Fixed location of double-backquote for verbatim text.
Minor formatting fix in xunit_setup.rst
This prevents referring to a generic type without filling in its generic type parameters. The FixtureDef typing might need some more refining in the future.
typing: set disallow_any_generics
Commits on Aug 02, 2020
Configure setuptools_scm using pyproject.toml
Commits on Aug 03, 2020
In preparation for enforcing some docstring lints.
There are some ones we *would* like to enforce, like
D401 First line should be in imperative mood
but have too many false positives, so I left them out.
Commits on Aug 04, 2020
Enforce some pydocstyle lints with flake8-docstrings & docstring fixes in testing/
This is a follow up to 3f82006 which didn't make it clear that log_print is also removed in the changelog and didn't remove it from the reference docs.
This makes mypy raise an error whenever it detects code which is
statically unreachable, e.g.
x: int
if isinstance(x, str):
... # Statement is unreachable [unreachable]
This is really neat and finds quite a few logic and typing bugs.
Sometimes the code is intentionally unreachable in terms of types, e.g.
raising TypeError when a function is given an argument with a wrong
type. In these cases a `type: ignore[unreachable]` is needed, but I
think it's a nice code hint.
Properly remove log_print
Add docs for releasing major/release candidates
typing: set warn_unreachable
typing: resultlog, pytester, longrepr
Co-authored-by: Ran Benita <ran@unusedvar.com>
Commits on Aug 05, 2020
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Commits on Aug 06, 2020
Fix test_plain_unittest_does_not_support_async on pypy3
An equivalent for these py.path.local functions is needed for some upcoming py.path -> pathlib conversions.
Didn't call it absolute or absolute_path to avoid conflicts with possible variable names. Didn't call it abspath to avoid confusion with os.path.abspath.
Commits on Aug 07, 2020
Some py.path -> pathlib conversions
The correct name is visible in the Bitbucket link.
Fix typos in Ali Afshar's name
Commits on Aug 10, 2020
… class See the code comment for the rationale.
It now has a str/bytes type parameter.
capture: add type annotations to CaptureFixture
Commits on Aug 12, 2020
Commits on Aug 13, 2020
Currently the badge encourages you to set it up now. :)
Replace inactive Azure Pipelines badge with GHA
Commits on Aug 14, 2020
and include a demo of toml 'literal strings' Update doc/en/warnings.rst Apply suggestion by Ran Fix linting Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Add changelog for PR #7631
We used it as a shortcut for avoiding coverage, but pylint has a special interpretation of it as an abstract method which we don't want.
Don't use NotImplementedError in `@overload`s
Commits on Aug 15, 2020
This fixes an issue where pylint complains about missing implementations of abstract methods in subclasses of `File` which only override `collect()` (as they should). It is also cleaner and makes sense, these methods really don't need to be overridden. The previous methods defined directly on `FSCollector` and `Package` are deprecated, to be removed in pytest 7. See commits e2934c3 and f10ab02 for reference.
Commits on Aug 16, 2020
…ing when it was disabled The `CaptureManager.global_and_fixture_disabled()` context manager (and `CaptureFixture.disabled()` which calls it) did `suspend(); ...; resume()` but if the capturing was already suspended, the `resume()` would resume it when it shouldn't. This caused caused some messages to be swallowed when `--log-cli` is used because it uses `global_and_fixture_disabled` when capturing is not necessarily resumed.
Commits on Aug 17, 2020
Commits on Aug 18, 2020
Only define gethookproxy, isinitpath on Session
Commits on Aug 19, 2020
Commits on Aug 22, 2020
The path part of a `<path>::part1::part2` style collection argument must be a file, not a directory. Previously this crashed with an uncool assert "invalid arg".
…s called more than once
Commits on Aug 23, 2020
main: improve message on `pytest path/to/a/directory::mytest`
logging: fix handler level restored incorrectly if caplog.set_level is called more than once
The 0-1 was a bit too optimistic: CI got "no tests ran in 3.98s".
testing: fix flaky test when executed slowly
Commits on Aug 24, 2020
capture: fix disabled()/global_and_fixture_disabled() enabling capturing when it was disabled
Make it a bit more accurate and use the same format that pytest_runtest_protocol uses.
hookspec: improve collection phase documentation a bit
It doesn't add much, mostly just an eye sore, particularly with the overloads.
Similar to the previous commit, this makes things more straightforward.
This reverts commit f10ab02. The commit was good in that it removed a non-trivial amount of code duplication. However it was done in the wrong layer (nodes.py) and split up a major part of the collection (the filesystem traversal) to a separate class making it harder to understand. We should try to reduce the duplication, but in a more appropriate manner.
The end result in the `else` branch is the same, but flows naturally.
Already covered in a condition above.
This is a more sensible interface for matchnodes. This also fixes a sort-of bug where a recursive call to matchnodes raises NoMatch which would terminate the entire tree, even if other branches may find a match. Though I don't think it's actually possible.
It's a little more sane this way.
The weird name was due to f396733, now that I understand it a bit better can give it a more descriptive name.
Things are easier to understand without the weird exception.
This removes an unhelpful level of indirection and enables some upcoming upcoming simplifications.
Now all of the logic is in one place and may be simplified and refactored in more sensible way.
They are only used for the duration of this function.
Commits on Aug 25, 2020
Start simplifying collection code in Session
* Update talks/trainings page - Remove past webinar - Add new open training - Add some talks/webinars by Oliver Bestwalter and by me - Remove some stale link targets * Move sidebar to index
In ff8b788 NOTSET was changed to a singleton enum, which ended up unexpectedly triggering a code path in ID generation which checks for `isinstance(Enum)`. Add an explicit case for it, which is not too bad anyway.
python: fix empty parametrize() leading to "NotSetType.token" id
Commits on Aug 26, 2020
When a Python object (module/class/instance) is collected, for each name
in `obj.__dict__` (and up its MRO) the pytest_pycollect_makeitem hook is
called for potentially creating a node for it.
These Python objects have a bunch of builtin attributes that are
extremely unlikely to be collected. But due to their pervasiveness,
dispatching the hook for them ends up being mildly expensive and also
pollutes PYTEST_DEBUG=1 output and such.
Let's just ignore these attributes.
On the pandas test suite commit 04e9e0afd476b1b8bed930e47bf60e,
collect only, irrelevant lines snipped, about 5% improvement:
Before:
```
51195095 function calls (48844352 primitive calls) in 39.089 seconds
ncalls tottime percall cumtime percall filename:lineno(function)
226602/54 0.145 0.000 38.940 0.721 manager.py:90(_hookexec)
72227 0.285 0.000 20.146 0.000 python.py:424(_makeitem)
72227 0.171 0.000 16.678 0.000 python.py:218(pytest_pycollect_makeitem)
```
After:
```
48410921 function calls (46240870 primitive calls) in 36.950 seconds
ncalls tottime percall cumtime percall filename:lineno(function)
181429/54 0.113 0.000 36.777 0.681 manager.py:90(_hookexec)
27054 0.130 0.000 17.755 0.001 python.py:465(_makeitem)
27054 0.121 0.000 16.219 0.001 python.py:218(pytest_pycollect_makeitem)
```
Commits on Aug 27, 2020
RFC: python: skip work pytest_pycollect_makeitem work on certain names
Inline `_makeitem()` so that `self.ihook` (which is moderately expensive) can be called only once. Note: the removed test "test_makeitem_non_underscore" comes from an old behavior of skipping names that start with `_` which has since been generalized, making the test no longer relevant.
Commits on Aug 28, 2020
I think the straight code is easier to understand.
As related in #7696
python: small optimization in PyCollector.collect()
Commits on Aug 29, 2020
fixture: remove `@scopeproperty`
Commits on Sep 03, 2020
Commits on Sep 04, 2020
Warnings are a central part of Python, so much that Python itself has command-line and environtment variables to handle warnings. By moving the concept of warning handling into Config, it becomes natural to filter warnings issued as early as possible, even before the "_pytest.warnings" plugin is given a chance to spring into action. This also avoids the weird coupling between config and the warnings plugin that was required before. Fix #6681 Fix #2891 Fix #7620 Fix #7626 Close #7649 Co-authored-by: Ran Benita <ran@unusedvar.com>
Fix handle of exceptions in ReprEntry with tb=line
config: start migrating Config.{rootdir,inifile} from py.path.local to pathlib
…e it Before, `PluginManager` was a copy of the pluggy doc, and `PytestPluginManager` was documented separately. pytest users only really need to know about `PytestPluginManager`, so instead of splitting have the `PytestPluginManager` documentation include all of `PluginManager` members and remove `PluginManager` from the reference (it is still shown as the base class).
When a name is exported from `pytest`, prefer to refer to it by that rather than its `_pytest` import path. It is shorter and more appropriate in user-facing documentation (although that's not really visible). Our plan is to expose more names for typing purposes, in which can this could be more comprehensive.
The release-on-comment script is always executed on *master*, so we should execute the `release.py` script using tox to ensure we create the right environment. Also fixed errors in the error handling code.
Use tox to execute release script
doc/reference: include PluginManager in PytestPluginManager and remove it
doc: prefer to reference by public name when possible
Commits on Sep 05, 2020
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
The sign-up is closed.
Commits on Sep 06, 2020
doc: Remove Workshoptage training
Commits on Sep 08, 2020
- be more vague about "packaging metadata" over explicitly mentioning `setup.py` (such that `pyproject.toml`-based distributions are allowed) - drop extensions on `README.txt` / `LICENSE.txt` (it's more common to have `.md` / `.rst` / no extension) - remove duplicate mention of license packaging metadata
Commits on Sep 09, 2020
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Update pytest-dev requirements
Commits on Sep 11, 2020
doc: fix a few broken cross references
Prepare release 6.0.2 (cherry picked from commit fe69bd5)
Merge pull request #7720 from pytest-dev/release-6.0.2
Commits on Sep 12, 2020
Fix INTERNALERROR when accessing locals / globals with faulty `exec`
…rated function For decorated functions, the lineno of the FunctionDef AST node points to the `def` line, not to the first decorator line. On the other hand, in code objects, the `co_firstlineno` points to the first decorator line. Assertion rewriting inserts some imports to code it rewrites. The imports are inserted at the lineno of the first statement in the AST. In turn, the code object compiled from the rewritten AST uses the lineno of the first statement (which is the first inserted import). This means that given a module like this, ```py @foo @bar def baz(): pass ``` the lineno of the code object without assertion rewriting (`--assertion=plain`) is 1, but with assertion rewriting it is 3. And *this* causes some issues for the exception repr when e.g. the decorator line is invalid and raises during collection. The code becomes confused and crashes with INTERNALERROR> File "_pytest/_code/code.py", line 638, in get_source INTERNALERROR> lines.append(space_prefix + source.lines[line_index].strip()) INTERNALERROR> IndexError: list index out of range Fix it by special casing decorators. Maybe there are other cases like this but off hand I can't think of another Python construct where the lineno of the item would be after its first line, and this is the only such issue we have had reported.
Commits on Sep 13, 2020
remove unused bitbucket link
permit tox config in non-tox.ini files for pytest-dev member projects
should be a noop (despite the major version bump) -- I rewrote the action to be more stable and need fewer security updates
Commits on Sep 14, 2020
Update to deadsnakes/action@v2.0.0
Add full command-line flags to the reference docs
Commits on Sep 15, 2020
Capitalize the first word in a sentence and add a period at the end.
Commits on Sep 16, 2020
Usually, we use semi-colon punctuation mark to connect closely related ideas. Sentences which are after semicolon, begins with small letter, and last sentence always ends with a period mark, see "Garner's Modern American Usage" book for more information about usage of punctuation mark. So removing punctuation mark altogether is a good idea, as @gnikonorov suggested [1]. [1]: #7760 (review)
Co-authored-by: Florian Bruhin <me@the-compiler.org>
[Docs] remove semi-colon punctuation mark
Commits on Sep 17, 2020
Commits on Sep 19, 2020
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Warning about record_testsuite_property not working with xdist
Add guidelines section about backporting
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com> Co-authored-by: Thomas Grainger <tagrain@gmail.com> Co-authored-by: Kyle Altendorf <sda@fstab.net>
RELEASING: ~~first merge PR, then tag~~ clarify where to push the tag
Co-authored-by: Ran Benita <ran@unusedvar.com>
Commits on Sep 21, 2020
Commits on Sep 22, 2020
This indicates at least for people using type checkers that these classes are not designed for inheritance and we make no stability guarantees regarding inheritance of them. Currently this doesn't show up in the docs. Sphinx does actually support `@final`, however it only works when imported directly from `typing`, while we import from `_pytest.compat`. In the future there might also be a `@sealed` decorator which would cover some more cases.
Commits on Sep 23, 2020
Mark some public and to-be-public classes as `@final`
Use new pip resolver in plugins tox env
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
Commits on Sep 26, 2020
changelog: some consistency cleanups
This file was deleted.
This file was deleted.