-
-
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.
changelog minimal unittest for collect module deprecations \!fixup - changelog typo
- Loading branch information
1 parent
95fadd5
commit cdfbe35
Showing
6 changed files
with
54 additions
and
30 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 @@ | ||
Deprecate the ``pytest.collect`` module as it's just aliases into ``pytest``. |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import sys | ||
import warnings | ||
from types import ModuleType | ||
|
||
import pytest | ||
from _pytest.deprecated import PYTEST_COLLECT_MODULE | ||
|
||
|
||
COLLECT_FAKEMODULE_ATTRIBUTES = [ | ||
"Collector", | ||
"Module", | ||
"Function", | ||
"Instance", | ||
"Session", | ||
"Item", | ||
"Class", | ||
"File", | ||
"_fillfuncargs", | ||
] | ||
|
||
|
||
class FakeCollectModule(ModuleType): | ||
def __init__(self): | ||
super().__init__("pytest.collect") | ||
self.__all__ = list(COLLECT_FAKEMODULE_ATTRIBUTES) | ||
self.__pytest = pytest | ||
|
||
def __dir__(self): | ||
return dir(super()) + self.__all__ | ||
|
||
def __getattr__(self, name): | ||
if name not in self.__all__: | ||
raise AttributeError(name) | ||
warnings.warn(PYTEST_COLLECT_MODULE.format(name=name), stacklevel=2) | ||
return getattr(pytest, name) | ||
|
||
|
||
sys.modules["pytest.collect"] = FakeCollectModule() |
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