[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#995737: pytest breaks pytest-doctestplus autopkgtest: pytest.PytestAssertRewriteWarning: Module already imported so cannot be rewritten: pytest_doctestplus



Source: pytest, pytest-doctestplus
Control: found -1 pytest/6.2.5-1
Control: found -1 pytest-doctestplus/0.11.0-1
Severity: serious
Tags: sid bookworm
X-Debbugs-CC: debian-ci@lists.debian.org
User: debian-ci@lists.debian.org
Usertags: breaks needs-update

Dear maintainer(s),

With a recent upload of pytest the autopkgtest of pytest-doctestplus
fails in testing when that autopkgtest is run with the binary packages
of pytest from unstable. It passes when run with only packages from
testing. In tabular form:

                       pass            fail
pytest                 from testing    6.2.5-1
pytest-doctestplus     from testing    0.11.0-1
all others             from testing    from testing

I copied some of the output at the bottom of this report.

Currently this regression is blocking the migration of pytest to testing
[1]. Due to the nature of this issue, I filed this bug report against
both packages. Can you please investigate the situation and reassign the
bug to the right package?

More information about this bug and the reason for filing it can be found on
https://wiki.debian.org/ContinuousIntegration/RegressionEmailInformation

Paul

[1] https://qa.debian.org/excuses.php?package=pytest

https://ci.debian.net/data/autopkgtest/testing/amd64/p/pytest-doctestplus/15768646/log.gz

=================================== FAILURES
===================================
_________________________ test_ignore_warnings_module
__________________________

testdir = <Testdir
local('/tmp/pytest-of-debci/pytest-0/test_ignore_warnings_module0')>

    def test_ignore_warnings_module(testdir):

        # First check that we get a warning if we don't add the
IGNORE_WARNINGS
        # directive
        p = testdir.makepyfile(
            """
            def myfunc():
                '''
                >>> import warnings
                >>> warnings.warn('A warning occurred', UserWarning)
                '''
                pass
            """)
>       reprec = testdir.inline_run(p, "--doctest-plus", "-W error")

/tmp/autopkgtest-lxc.37ycsxwg/downtmp/build.mpq/src/tests/test_doctestplus.py:414:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
/usr/lib/python3/dist-packages/_pytest/pytester.py:1615: in inline_run
    return self._pytester.inline_run(
/usr/lib/python3/dist-packages/_pytest/pytester.py:1072: in inline_run
    ret = main([str(x) for x in args], plugins=plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:143: in main
    config = _prepareconfig(args, plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:318: in
_prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/helpconfig.py:100: in
pytest_cmdline_parse
    config: Config = outcome.get_result()
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1003: in
pytest_cmdline_parse
    self.parse(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1283: in parse
    self._preparse(args, addopts=addopts)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1167: in _preparse
    self._consider_importhook(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1114: in
_consider_importhook
    self._mark_plugins_for_rewrite(hook)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1135: in
_mark_plugins_for_rewrite
    hook.mark_rewrite(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:259: in
mark_rewrite
    self._warn_already_imported(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:266: in
_warn_already_imported
    self.config.issue_config_time_warning(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _

self = <_pytest.config.Config object at 0x7ff7857c78e0>
warning = PytestAssertRewriteWarning('Module already imported so cannot
be rewritten: pytest_doctestplus')
stacklevel = 5

    def issue_config_time_warning(self, warning: Warning, stacklevel:
int) -> None:
        """Issue and handle a warning during the "configure" stage.

        During ``pytest_configure`` we can't capture warnings using the
``catch_warnings_for_item``
        function because it is not possible to have hookwrappers around
``pytest_configure``.

        This function is mainly intended for plugins that need to issue
warnings during
        ``pytest_configure`` (or similar stages).

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        """
        if self.pluginmanager.is_blocked("warnings"):
            return

        cmdline_filters = self.known_args_namespace.pythonwarnings or []
        config_filters = self.getini("filterwarnings")

        with warnings.catch_warnings(record=True) as records:
            warnings.simplefilter("always", type(warning))
            apply_warning_filters(config_filters, cmdline_filters)
>           warnings.warn(warning, stacklevel=stacklevel)
E           pytest.PytestAssertRewriteWarning: Module already imported
so cannot be rewritten: pytest_doctestplus

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1321:
PytestAssertRewriteWarning
___________________________ test_ignore_warnings_rst
___________________________

testdir = <Testdir
local('/tmp/pytest-of-debci/pytest-0/test_ignore_warnings_rst0')>

    def test_ignore_warnings_rst(testdir):

        # First check that we get a warning if we don't add the
IGNORE_WARNINGS
        # directive
        p = testdir.makefile(".rst",
                             """
            ::
                >>> import warnings
                >>> warnings.warn('A warning occurred', UserWarning)
            """)
>       reprec = testdir.inline_run(p, "--doctest-plus", "--doctest-rst",
                                    "--text-file-format=rst", "-W error")

/tmp/autopkgtest-lxc.37ycsxwg/downtmp/build.mpq/src/tests/test_doctestplus.py:441:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
/usr/lib/python3/dist-packages/_pytest/pytester.py:1615: in inline_run
    return self._pytester.inline_run(
/usr/lib/python3/dist-packages/_pytest/pytester.py:1072: in inline_run
    ret = main([str(x) for x in args], plugins=plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:143: in main
    config = _prepareconfig(args, plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:318: in
_prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/helpconfig.py:100: in
pytest_cmdline_parse
    config: Config = outcome.get_result()
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1003: in
pytest_cmdline_parse
    self.parse(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1283: in parse
    self._preparse(args, addopts=addopts)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1167: in _preparse
    self._consider_importhook(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1114: in
_consider_importhook
    self._mark_plugins_for_rewrite(hook)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1135: in
_mark_plugins_for_rewrite
    hook.mark_rewrite(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:259: in
mark_rewrite
    self._warn_already_imported(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:266: in
_warn_already_imported
    self.config.issue_config_time_warning(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _

self = <_pytest.config.Config object at 0x7ff784d29640>
warning = PytestAssertRewriteWarning('Module already imported so cannot
be rewritten: pytest_doctestplus')
stacklevel = 5

    def issue_config_time_warning(self, warning: Warning, stacklevel:
int) -> None:
        """Issue and handle a warning during the "configure" stage.

        During ``pytest_configure`` we can't capture warnings using the
``catch_warnings_for_item``
        function because it is not possible to have hookwrappers around
``pytest_configure``.

        This function is mainly intended for plugins that need to issue
warnings during
        ``pytest_configure`` (or similar stages).

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        """
        if self.pluginmanager.is_blocked("warnings"):
            return

        cmdline_filters = self.known_args_namespace.pythonwarnings or []
        config_filters = self.getini("filterwarnings")

        with warnings.catch_warnings(record=True) as records:
            warnings.simplefilter("always", type(warning))
            apply_warning_filters(config_filters, cmdline_filters)
>           warnings.warn(warning, stacklevel=stacklevel)
E           pytest.PytestAssertRewriteWarning: Module already imported
so cannot be rewritten: pytest_doctestplus

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1321:
PytestAssertRewriteWarning
__________________________ test_show_warnings_module
___________________________

testdir = <Testdir
local('/tmp/pytest-of-debci/pytest-0/test_show_warnings_module0')>

    def test_show_warnings_module(testdir):

        p = testdir.makepyfile(
            """
            def myfunc():
                '''
                >>> import warnings
                >>> warnings.warn('A warning occurred', UserWarning)  #
doctest: +SHOW_WARNINGS
                UserWarning: A warning occurred
                '''
                pass
            """)
>       reprec = testdir.inline_run(p, "--doctest-plus", "-W error")

/tmp/autopkgtest-lxc.37ycsxwg/downtmp/build.mpq/src/tests/test_doctestplus.py:469:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
/usr/lib/python3/dist-packages/_pytest/pytester.py:1615: in inline_run
    return self._pytester.inline_run(
/usr/lib/python3/dist-packages/_pytest/pytester.py:1072: in inline_run
    ret = main([str(x) for x in args], plugins=plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:143: in main
    config = _prepareconfig(args, plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:318: in
_prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/helpconfig.py:100: in
pytest_cmdline_parse
    config: Config = outcome.get_result()
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1003: in
pytest_cmdline_parse
    self.parse(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1283: in parse
    self._preparse(args, addopts=addopts)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1167: in _preparse
    self._consider_importhook(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1114: in
_consider_importhook
    self._mark_plugins_for_rewrite(hook)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1135: in
_mark_plugins_for_rewrite
    hook.mark_rewrite(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:259: in
mark_rewrite
    self._warn_already_imported(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:266: in
_warn_already_imported
    self.config.issue_config_time_warning(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _

self = <_pytest.config.Config object at 0x7ff7857c7eb0>
warning = PytestAssertRewriteWarning('Module already imported so cannot
be rewritten: pytest_doctestplus')
stacklevel = 5

    def issue_config_time_warning(self, warning: Warning, stacklevel:
int) -> None:
        """Issue and handle a warning during the "configure" stage.

        During ``pytest_configure`` we can't capture warnings using the
``catch_warnings_for_item``
        function because it is not possible to have hookwrappers around
``pytest_configure``.

        This function is mainly intended for plugins that need to issue
warnings during
        ``pytest_configure`` (or similar stages).

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        """
        if self.pluginmanager.is_blocked("warnings"):
            return

        cmdline_filters = self.known_args_namespace.pythonwarnings or []
        config_filters = self.getini("filterwarnings")

        with warnings.catch_warnings(record=True) as records:
            warnings.simplefilter("always", type(warning))
            apply_warning_filters(config_filters, cmdline_filters)
>           warnings.warn(warning, stacklevel=stacklevel)
E           pytest.PytestAssertRewriteWarning: Module already imported
so cannot be rewritten: pytest_doctestplus

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1321:
PytestAssertRewriteWarning
____________________________ test_show_warnings_rst
____________________________

testdir = <Testdir
local('/tmp/pytest-of-debci/pytest-0/test_show_warnings_rst0')>

    def test_show_warnings_rst(testdir):

        p = testdir.makefile(".rst",
                             """
            ::
                >>> import warnings
                >>> warnings.warn('A warning occurred', UserWarning)  #
doctest: +SHOW_WARNINGS
                UserWarning: A warning occurred
            """)
>       reprec = testdir.inline_run(p, "--doctest-plus", "--doctest-rst",
                                    "--text-file-format=rst", "-W error")

/tmp/autopkgtest-lxc.37ycsxwg/downtmp/build.mpq/src/tests/test_doctestplus.py:495:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _
/usr/lib/python3/dist-packages/_pytest/pytester.py:1615: in inline_run
    return self._pytester.inline_run(
/usr/lib/python3/dist-packages/_pytest/pytester.py:1072: in inline_run
    ret = main([str(x) for x in args], plugins=plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:143: in main
    config = _prepareconfig(args, plugins)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:318: in
_prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
/usr/lib/python3/dist-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:92: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3/dist-packages/pluggy/manager.py:83: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3/dist-packages/_pytest/helpconfig.py:100: in
pytest_cmdline_parse
    config: Config = outcome.get_result()
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1003: in
pytest_cmdline_parse
    self.parse(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1283: in parse
    self._preparse(args, addopts=addopts)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1167: in _preparse
    self._consider_importhook(args)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1114: in
_consider_importhook
    self._mark_plugins_for_rewrite(hook)
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1135: in
_mark_plugins_for_rewrite
    hook.mark_rewrite(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:259: in
mark_rewrite
    self._warn_already_imported(name)
/usr/lib/python3/dist-packages/_pytest/assertion/rewrite.py:266: in
_warn_already_imported
    self.config.issue_config_time_warning(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _

self = <_pytest.config.Config object at 0x7ff784df0760>
warning = PytestAssertRewriteWarning('Module already imported so cannot
be rewritten: pytest_doctestplus')
stacklevel = 5

    def issue_config_time_warning(self, warning: Warning, stacklevel:
int) -> None:
        """Issue and handle a warning during the "configure" stage.

        During ``pytest_configure`` we can't capture warnings using the
``catch_warnings_for_item``
        function because it is not possible to have hookwrappers around
``pytest_configure``.

        This function is mainly intended for plugins that need to issue
warnings during
        ``pytest_configure`` (or similar stages).

        :param warning: The warning instance.
        :param stacklevel: stacklevel forwarded to warnings.warn.
        """
        if self.pluginmanager.is_blocked("warnings"):
            return

        cmdline_filters = self.known_args_namespace.pythonwarnings or []
        config_filters = self.getini("filterwarnings")

        with warnings.catch_warnings(record=True) as records:
            warnings.simplefilter("always", type(warning))
            apply_warning_filters(config_filters, cmdline_filters)
>           warnings.warn(warning, stacklevel=stacklevel)
E           pytest.PytestAssertRewriteWarning: Module already imported
so cannot be rewritten: pytest_doctestplus

/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1321:
PytestAssertRewriteWarning
=========================== short test summary info
============================
FAILED tests/test_doctestplus.py::test_ignore_warnings_module -
pytest.Pytest...
FAILED tests/test_doctestplus.py::test_ignore_warnings_rst -
pytest.PytestAss...
FAILED tests/test_doctestplus.py::test_show_warnings_module -
pytest.PytestAs...
FAILED tests/test_doctestplus.py::test_show_warnings_rst -
pytest.PytestAsser...
========================= 4 failed, 39 passed in 3.55s
=========================

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


Reply to: