pytest: "usage of Generator.Function is deprecated" error coming from PyTest code, not ours
We upgraded one of our projects to PyTest 4.0.0, and our builds started failing with this deprecation error. We’re filtering out the warning for now to get our build running, because there’s nothing we can do about it. The warning isn’t coming from our code. As you can see from the stacktrace below, the warning is coming from PyTest code.
self = <CallInfo when='collect' exception: usage of Generator.Function is deprecated, please use pytest.Function instead>
func = <function <lambda> at 0x7fa771266d70>, when = 'collect'
treat_keyboard_interrupt_as_exception = False
def __init__(self, func, when, treat_keyboard_interrupt_as_exception=False):
#: context of invocation: one of "setup", "call",
#: "teardown", "memocollect"
self.when = when
self.start = time()
try:
> self.result = func()
../venv/lib/python2.7/site-packages/_pytest/runner.py:211:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../venv/lib/python2.7/site-packages/_pytest/runner.py:272: in <lambda>
call = CallInfo(lambda: list(collector.collect()), "collect")
../venv/lib/python2.7/site-packages/_pytest/python.py:769: in collect
function_class = self.Function
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = _CompatProperty(name='Function')
obj = <Generator 'test_parse_valid_tokens'>
owner = <class '_pytest.python.Generator'>
def __get__(self, obj, owner):
if obj is None:
return self
from _pytest.deprecated import COMPAT_PROPERTY
warnings.warn(
> COMPAT_PROPERTY.format(name=self.name, owner=owner.__name__), stacklevel=2
)
E RemovedInPytest4Warning: usage of Generator.Function is deprecated, please use pytest.Function instead
../venv/lib/python2.7/site-packages/_pytest/nodes.py:70: RemovedInPytest4Warning
Information from the test startup:
============================= test session starts ==============================
platform linux2 -- Python 2.7.12, pytest-4.0.0, py-1.7.0, pluggy-0.8.0
django settings: xxxxxxxxxxxx (from ini file)
rootdir: xxxxxxxxxxxxxxx, inifile: setup.cfg
plugins: django-2.9.1, forked-0.2, pysoa-0.55.0, mock-1.10.0, cov-2.6.0, xdist-1.24.1
Here’s a quick checklist in what to include:
- Include a detailed description of the bug or suggestion
-
pip list
of the virtual environment you are using (I’ve shared what I can without divulging confidential information) - pytest and operating system versions
- Minimal example if possible (Not possible because I don’t know what exactly causes this to replicate and I can’t share the project)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (10 by maintainers)
Commits related to this issue
- fix #4400 - rearrange the handling of yield test warnings/errors — committed to RonnyPfannschmidt/pytest by RonnyPfannschmidt 6 years ago
- fix #4400 - rearrange the handling of yield test warnings/errors — committed to RonnyPfannschmidt/pytest by RonnyPfannschmidt 6 years ago
- fix #4400 - rearrange the handling of yield test warnings/errors — committed to RonnyPfannschmidt/pytest by RonnyPfannschmidt 6 years ago
- Merge pull request #4403 from RonnyPfannschmidt/fix-4400 Fix #4400 - rearrange the handling of yield test warnings/errors — committed to pytest-dev/pytest by blueyed 6 years ago
- Update pytest to 4.0.1 (#1359) This PR updates [pytest](https://pypi.org/project/pytest) from **4.0.0** to **4.0.1**. <details> <summary>Changelog</summary> ### 4.0.1 ``` ... — committed to mozilla-services/tecken by pyup-bot 6 years ago
- Merge #1629 1629: Scheduled weekly dependency update for week 47 r=mythmon a=pyup-bot ### Update [botocore](https://pypi.org/project/botocore) from **1.12.47** to **1.12.51**. <details> <su... — committed to mozilla/normandy by bors[bot] 6 years ago
- Merge #47 47: Update pytest to 4.0.1 r=rehandalal a=pyup-bot This PR updates [pytest](https://pypi.org/project/pytest) from **4.0.0** to **4.0.1**. <details> <summary>Changelog</summary> ... — committed to rehandalal/therapist by bors[bot] 6 years ago
- Scheduled weekly dependency update for week 52 (#75) ### Update [sphinx](https://pypi.org/project/sphinx) from **1.7.8** to **1.8.3**. <details> <summary>Changelog</summary> ... — committed to wdv4758h/python-everywhere by pyup-bot 5 years ago
- Scheduled monthly dependency update for January (#433) ### Update [wheel](https://pypi.org/project/wheel) from **0.32.2** to **0.32.3**. <details> <summary>Changelog</summary> ... — committed to guykisel/inline-plz by pyup-bot 5 years ago
- Merge #32 32: Pin pytest to latest version 5.1.3 r=duckinator a=pyup-bot This PR pins [pytest](https://pypi.org/project/pytest) to the latest release **5.1.3**. <details> <summary>Changelog</s... — committed to duckinator/bork by bors[bot] 5 years ago
correct - you are really lucky the test was stateless ^^