How to use the flake8.options.manager.PluginVersion function in flake8

To help you get started, we’ve selected a few flake8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyCQA / flake8 / tests / unit / test_debug.py View on Github external
      manager.PluginVersion('mccabe', '0.5.9', False)],
        [{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
         {'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
    ([manager.PluginVersion('pycodestyle', '2.0.0', False),
      manager.PluginVersion('my-local', '0.0.1', True),
      manager.PluginVersion('mccabe', '0.5.9', False)],
        [{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
         {'plugin': 'my-local', 'version': '0.0.1', 'is_local': True},
         {'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
])
def test_plugins_from(plugins, expected):
    """Test that we format plugins appropriately."""
    option_manager = mock.Mock(registered_plugins=set(plugins))
    assert expected == debug.plugins_from(option_manager)
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_generate_epilog(optmanager):
    """Verify how we generate the epilog for help text."""
    assert optmanager.parser.epilog is None

    optmanager.registered_plugins = [
        manager.PluginVersion('Testing 100', '0.0.0', False),
        manager.PluginVersion('Testing 101', '0.0.0', False),
        manager.PluginVersion('Testing 300', '0.0.0', False),
    ]

    expected_value = (
        'Installed plugins: Testing 100: 0.0.0, Testing 101: 0.0.0, Testing'
        ' 300: 0.0.0'
    )

    optmanager.generate_epilog()
    assert optmanager.parser.epilog == expected_value
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_plugins_are_sorted_in_generate_versions(optmanager):
    """Verify we sort before joining strings in generate_versions."""
    optmanager.registered_plugins = [
        manager.PluginVersion('pyflakes', '1.5.0', False),
        manager.PluginVersion('mccabe', '0.7.0', False),
        manager.PluginVersion('pycodestyle', '2.2.0', False),
        manager.PluginVersion('flake8-docstrings', '0.6.1', False),
        manager.PluginVersion('flake8-bugbear', '2016.12.1', False),
    ]
    assert (optmanager.generate_versions()
            == 'flake8-bugbear: 2016.12.1, '
               'flake8-docstrings: 0.6.1, '
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_generate_versions(optmanager):
    """Verify a comma-separated string is generated of registered plugins."""
    optmanager.registered_plugins = [
        manager.PluginVersion('Testing 100', '0.0.0', False),
        manager.PluginVersion('Testing 101', '0.0.0', False),
        manager.PluginVersion('Testing 300', '0.0.0', True),
    ]
    assert (optmanager.generate_versions()
            == 'Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0')
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_generate_epilog(optmanager):
    """Verify how we generate the epilog for help text."""
    assert optmanager.parser.epilog is None

    optmanager.registered_plugins = [
        manager.PluginVersion('Testing 100', '0.0.0', False),
        manager.PluginVersion('Testing 101', '0.0.0', False),
        manager.PluginVersion('Testing 300', '0.0.0', False),
    ]

    expected_value = (
        'Installed plugins: Testing 100: 0.0.0, Testing 101: 0.0.0, Testing'
        ' 300: 0.0.0'
    )

    optmanager.generate_epilog()
    assert optmanager.parser.epilog == expected_value
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_generate_versions_with_format_string(optmanager):
    """Verify a comma-separated string is generated of registered plugins."""
    optmanager.registered_plugins.update([
        manager.PluginVersion('Testing', '0.0.0', False),
        manager.PluginVersion('Testing', '0.0.0', False),
        manager.PluginVersion('Testing', '0.0.0', False),
    ])
    assert (
        optmanager.generate_versions() == 'Testing: 0.0.0'
    )
github PyCQA / flake8 / tests / unit / test_option_manager.py View on Github external
def test_plugins_are_sorted_in_generate_versions(optmanager):
    """Verify we sort before joining strings in generate_versions."""
    optmanager.registered_plugins = [
        manager.PluginVersion('pyflakes', '1.5.0', False),
        manager.PluginVersion('mccabe', '0.7.0', False),
        manager.PluginVersion('pycodestyle', '2.2.0', False),
        manager.PluginVersion('flake8-docstrings', '0.6.1', False),
        manager.PluginVersion('flake8-bugbear', '2016.12.1', False),
    ]
    assert (optmanager.generate_versions()
            == 'flake8-bugbear: 2016.12.1, '
               'flake8-docstrings: 0.6.1, '
github PyCQA / flake8 / tests / unit / test_debug.py View on Github external
    ([manager.PluginVersion('pycodestyle', '2.0.0', False)],
        [{'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
    ([manager.PluginVersion('pycodestyle', '2.0.0', False),
      manager.PluginVersion('mccabe', '0.5.9', False)],
        [{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
         {'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
    ([manager.PluginVersion('pycodestyle', '2.0.0', False),
      manager.PluginVersion('my-local', '0.0.1', True),
      manager.PluginVersion('mccabe', '0.5.9', False)],
        [{'plugin': 'mccabe', 'version': '0.5.9', 'is_local': False},
         {'plugin': 'my-local', 'version': '0.0.1', 'is_local': True},
         {'plugin': 'pycodestyle', 'version': '2.0.0', 'is_local': False}]),
])
def test_plugins_from(plugins, expected):
    """Test that we format plugins appropriately."""
    option_manager = mock.Mock(registered_plugins=set(plugins))
    assert expected == debug.plugins_from(option_manager)
github PyCQA / flake8 / tests / unit / test_debug.py View on Github external
def test_print_information(dumps, information, print_mock):
    """Verify we print and exit only when we have plugins."""
    plugins = [
        manager.PluginVersion('pycodestyle', '2.0.0', False),
        manager.PluginVersion('mccabe', '0.5.9', False),
    ]
    option_manager = mock.Mock(registered_plugins=set(plugins))
    action = debug.DebugAction(
        "--bug-report", dest="bug_report", option_manager=option_manager,
    )
    with pytest.raises(SystemExit):
        action(None, None, None, None)
    print_mock.assert_called_once_with('{}')
    dumps.assert_called_once_with({}, indent=2, sort_keys=True)
    information.assert_called_once_with(option_manager)