Skip to content

pytest 5.2.3 breaks tests on Python 3.5 – 3.8 #322

@asottile

Description

@asottile

In GitLab by @ericvw on Nov 14, 2019, 22:59

pytest 5.2.3 is causing test failures for Python 3.5 up to 3.8, inclusive. I believe re-kicking off CI should also result in the observed behavior.

Downgrading pytest to 5.2.2 results in all tests passing as expected.

I've bisected pytest 5.2.2...5.2.3 and have identified github:pytest-dev/pytest@9275012ef789048998d1b87b9536bd7c2c063596 as the commit that changes the behavior of the flake8 test suite. The PR is github:pytest-dev/pytest#5831.

I'm working on determining and understanding the root cause better and will update with my findings unless someone else beats me to it. I wanted to report what I have been able to find out so far.

To reproduce: In a clean virtual environment (I used Python 3.8)…

$ pip install -e .
$ pip install -U pytest mock
$ pytest

# Alternatively...
$ pip install -U tox
$ tox

[…]

========================================= FAILURES =========================================
_____________________________________ test_legacy_api ______________________________________

tmpdir = local('/private/var/folders/t8/80zbh8_x0tb4yz8nctl91kcw0000gs/T/pytest-of-xxxx/pytest-28/test_legacy_api0')

    def test_legacy_api(tmpdir):
        """A basic end-to-end test for the legacy api reporting errors."""
        with tmpdir.as_cwd():
            t_py = tmpdir.join('t.py')
            t_py.write('import os  # unused import\n')

>           style_guide = legacy.get_style_guide()

tests/integration/test_api_legacy.py:11:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/flake8/api/legacy.py:37: in get_style_guide
    application.register_plugin_options()
src/flake8/main/application.py:190: in register_plugin_options
    self.check_plugins.register_options(self.option_manager)
src/flake8/plugins/manager.py:490: in register_options
    list(self.manager.map(register_and_enable))
src/flake8/plugins/manager.py:298: in map
    yield func(self.plugins[name], *args, **kwargs)
src/flake8/plugins/manager.py:486: in register_and_enable
    call_register_options(plugin)
src/flake8/plugins/manager.py:398: in generated_function
    return method(optmanager, *args, **kwargs)
src/flake8/plugins/manager.py:217: in register_options
    add_options(optmanager)
src/flake8/plugins/pyflakes.py:100: in add_options
    parser.add_option(
src/flake8/options/manager.py:405: in add_option
    self._current_group.add_argument(*option_args, **option_kwargs)
/Users/[omitted]/.pyenv/versions/3.8.0/lib/python3.8/argparse.py:1386: in add_argument
    return self._add_action(action)
/Users/[omitted]/.pyenv/versions/3.8.0/lib/python3.8/argparse.py:1590: in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
/Users/[omitted]/.pyenv/versions/3.8.0/lib/python3.8/argparse.py:1400: in _add_action
    self._check_conflict(action)
/Users/[omitted]/.pyenv/versions/3.8.0/lib/python3.8/argparse.py:1539: in _check_conflict
    conflict_handler(action, confl_optionals)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <argparse._ArgumentGroup object at 0x10b470dc0>
action = _StoreAction(option_strings=['--builtins'], dest='builtins', nargs=None, const=None, default=None, type=functools.part...separated_list=True, normalize_paths=False), choices=No
ne, help='define more built-ins, comma separated', metavar=None)
conflicting_actions = [('--builtins', _StoreAction(option_strings=['--builtins'], dest='builtins', nargs=None, const=None, default=None, typ...parated_list=True, normalize_paths=False),
 choices=None, help='define more built-ins, comma separated', metavar=None))]

    def _handle_conflict_error(self, action, conflicting_actions):
        message = ngettext('conflicting option string: %s',
                           'conflicting option strings: %s',
                           len(conflicting_actions))
        conflict_string = ', '.join([option_string
                                     for option_string, action
                                     in conflicting_actions])
>       raise ArgumentError(action, message % conflict_string)
E       argparse.ArgumentError: argument --builtins: conflicting option string: --builtins

/Users/[omitted]/.pyenv/versions/3.8.0/lib/python3.8/argparse.py:1548: ArgumentError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions