eugeniy / pytest-tornado

A py.test plugin providing fixtures and markers to simplify testing of asynchronous tornado applications.
Apache License 2.0
121 stars 34 forks source link

Fix pytest deprecation warning for pytest version greater than 5.4 #60

Closed finsberg closed 4 years ago

finsberg commented 4 years ago

Running the test using pytest version 5.4 or newer gives the following deprecation warning from pytest

pytest_tornado/plugin.py:70: 17 tests with warnings
  /Users/henriknf/local/src/pytest-tornado/pytest_tornado/plugin.py:70: PytestDeprecationWarning: direct construction of Function has been deprecated, please use Function.from_parent
    item = pytest.Function(name, parent=collector)

Here is a fix that is also backward compatible with older versions of pytest

okin commented 4 years ago

Since this uses pkg_resources you should add a dependency to setuptools.

finsberg commented 4 years ago

pkg_resources is part of the standard library, is it not?

finsberg commented 4 years ago

I am sorry, pkg_resources is not part the the standard library but a part of setuptools (see e.g https://setuptools.readthedocs.io/en/latest/pkg_resources.html). Don't know if it make sense to add this as a dependency to setuptools if it is part of setuptools?

okin commented 4 years ago

Please excuse if I was being unclear.

Since you are using pkg_resources (which comes with setuptools) in the new code you should add a dependency to setuptools in setup.py of this project.

This makes it clear that it depends on modules provided by setuptools and will aid nyone who wishes to packages this for a distribution of their choice. This clearly isn't a problem if people are only using pip but I wouldn't rely on this.

finsberg commented 4 years ago

I totally get your point. I have added setuptools to the install requirements now.

vidartf commented 4 years ago

Since we already import setuptools in setup.py adding it as a dependency might be a little confusing, but I think it is good for dependency tracking 👍 (the bootstrapping issue would also be fixed if we were to add a pyproject.toml file as specified in PEP 518).