-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Hi. We have implemented a pytest collector quite some time ago that gets testcases from YAML files. I have noticed the following deprecation warnings recently:
tests/functiontest/conftest.py:221
/Users/maiera/PycharmProjects/pywbem/pywbem/tests/functiontest/conftest.py:221:
PytestDeprecationWarning: direct construction of YamlFile has been deprecated, please use YamlFile.from_parent
return YamlFile(path, parent)
tests/functiontest/conftest.py:249
/Users/maiera/PycharmProjects/pywbem/pywbem/tests/functiontest/conftest.py:249:
PytestDeprecationWarning: direct construction of YamlItem has been deprecated, please use YamlItem.from_parent
yield YamlItem(tc_name, self, testcase, filepath)
The source code for the collection is here: https://github.com/pywbem/pywbem/blob/master/tests/functiontest/conftest.py#L225
I have the following issues with that:
-
The
pytest.Fileclass is missing completely from the pytest API Reference docs. -
The
pytest.Itemclass does not list afrom_parent()method in the pytest API Reference docs for Item. -
For our
YamlFile, I was able to map the arguments from the ctor to thefrom_parent()method, but for ourYamlItemit turns out we are passing the YAML file name as an additional argument to theYamlItemctor (for better error reporting), and I did not find a way to specify that via thefrom_parent()method. Is there some way for theYamlItemobject to get at the file name of the YAML file? If not, could you possibly allow for additional kwargs that are passed on?
Versions:
Python 3.8.5 on MacOs
$ pytest --version
This is pytest version 5.4.3, imported from /Users/maiera/virtualenvs/pywbem38/lib/python3.8/site-packages/pytest/__init__.py
setuptools registered plugins:
requests-mock-1.8.0 at /Users/maiera/virtualenvs/pywbem38/lib/python3.8/site-packages/requests_mock/contrib/_pytest_plugin.py
yagot-0.5.0 at /Users/maiera/virtualenvs/pywbem38/lib/python3.8/site-packages/yagot_pytest/plugin.py
pytest-cov-2.10.1 at /Users/maiera/virtualenvs/pywbem38/lib/python3.8/site-packages/pytest_cov/plugin.py
We have pinned pytest to <6.0.0 due to issue #7591 which was fixed meanwhile (thanks for that!!) but not yet released. After realizing that, I retested with pytest 6.0.1 and the same warnings were issued.