-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change pytest deprecation warnings into errors for 6.0 release (#7362)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
- Loading branch information
1 parent
a9799f0
commit 7ec6401
Showing
19 changed files
with
122 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
**PytestDeprecationWarning are now errors by default.** | ||
|
||
Following our plan to remove deprecated features with as little disruption as | ||
possible, all warnings of type ``PytestDeprecationWarning`` now generate errors | ||
instead of warning messages. | ||
|
||
**The affected features will be effectively removed in pytest 6.1**, so please consult the | ||
`Deprecations and Removals <https://docs.pytest.org/en/latest/deprecations.html>`__ | ||
section in the docs for directions on how to update existing code. | ||
|
||
In the pytest ``6.0.X`` series, it is possible to change the errors back into warnings as a | ||
stopgap measure by adding this to your ``pytest.ini`` file: | ||
|
||
.. code-block:: ini | ||
[pytest] | ||
filterwarnings = | ||
ignore::pytest.PytestDeprecationWarning | ||
But this will stop working when pytest ``6.1`` is released. | ||
|
||
**If you have concerns** about the removal of a specific feature, please add a | ||
comment to `#5584 <https://github.com/pytest-dev/pytest/issues/5584>`__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
import sys | ||
import warnings | ||
from types import ModuleType | ||
from typing import Any | ||
from typing import List | ||
|
||
import pytest | ||
from _pytest.deprecated import PYTEST_COLLECT_MODULE | ||
|
||
|
||
COLLECT_FAKEMODULE_ATTRIBUTES = [ | ||
|
@@ -33,7 +31,8 @@ def __dir__(self) -> List[str]: | |
def __getattr__(self, name: str) -> Any: | ||
if name not in self.__all__: | ||
raise AttributeError(name) | ||
warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2) | ||
# Uncomment this after 6.0 release (#7361) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nicoddemus
Author
Member
|
||
# warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2) | ||
return getattr(pytest, name) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import pytest | ||
|
||
|
||
class CustomItem(pytest.Item, pytest.File): | ||
class CustomItem(pytest.Item): | ||
def runtest(self): | ||
pass | ||
|
||
|
||
class CustomFile(pytest.File): | ||
def collect(self): | ||
yield CustomItem.from_parent(name="foo", parent=self) | ||
|
||
|
||
def pytest_collect_file(path, parent): | ||
return CustomItem(path, parent) | ||
return CustomFile.from_parent(fspath=path, parent=parent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
I'm running the 6.0.1 release, why is this still here? Something I could help with?