Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pytest 6: PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent. #505

Closed
hroncok opened this issue Aug 8, 2020 · 3 comments · Fixed by #506

Comments

@hroncok
Copy link
Contributor

hroncok commented Aug 8, 2020

This is what I get when I run tests with pytest 6.0.1:

============================= test session starts ==============================
platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
plugins: expect-1.1.0
collected 0 items / 1 error

==================================== ERRORS ====================================
________________________ ERROR collecting test session _________________________
/usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
html5lib/tests/conftest.py:105: in pytest_collect_file
    return TokenizerFile(path, parent)
/usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
    warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

@gsnedders
Copy link
Member

To note, pytest-dev/pytest@c99c7d0 is the underlying change in PyTest; note that the introduction of from_parent was at the same time as the constructor deprecation in PyTest 5.4, and we presently need to continue supporting PyTest < 5 for Python 2.7 support. I suppose we could just fork on pytest.__version__ when creating the nodes if anyone wants to create a PR for this (and TokenizerFile isn't the only place which needs this in that contest.py).

@hroncok
Copy link
Contributor Author

hroncok commented Aug 8, 2020

Working on it BTW.

hroncok added a commit to hroncok/html5lib-python that referenced this issue Aug 8, 2020
Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes html5lib#505
hroncok added a commit to hroncok/html5lib-python that referenced this issue Aug 8, 2020
Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes html5lib#505
hroncok added a commit to hroncok/html5lib-python that referenced this issue Aug 8, 2020
Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes html5lib#505
@hroncok
Copy link
Contributor Author

hroncok commented Aug 8, 2020

#506

hroncok added a commit to hroncok/html5lib-python that referenced this issue Aug 10, 2020
Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes html5lib#505
jgraham pushed a commit that referenced this issue Aug 10, 2020
Add a wrapper not to break pytest 4 (needed for Python 2 support).

    ============================= test session starts ==============================
    platform linux -- Python 3.9.0b5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
    rootdir: /builddir/build/BUILD/html5lib-1.1, configfile: pytest.ini
    plugins: expect-1.1.0
    collected 0 items / 1 error

    ==================================== ERRORS ====================================
    ________________________ ERROR collecting test session _________________________
    /usr/lib/python3.9/site-packages/pluggy/hooks.py:286: in __call__
        return self._hookexec(self, self.get_hookimpls(), kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:93: in _hookexec
        return self._inner_hookexec(hook, methods, kwargs)
    /usr/lib/python3.9/site-packages/pluggy/manager.py:84: in <lambda>
        self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
    html5lib/tests/conftest.py:105: in pytest_collect_file
        return TokenizerFile(path, parent)
    /usr/lib/python3.9/site-packages/_pytest/nodes.py:95: in __call__
        warnings.warn(NODE_USE_FROM_PARENT.format(name=self.__name__), stacklevel=2)
    E   pytest.PytestDeprecationWarning: Direct construction of TokenizerFile has been deprecated, please use TokenizerFile.from_parent.
    E   See https://docs.pytest.org/en/stable/deprecations.html#node-construction-changed-to-node-from-parent for more details.

Fixes #505
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants