Ejemplo n.º 1
0
def test_update_version_string(optmanager):
    """Verify we update the version string idempotently."""
    assert optmanager.version == TEST_VERSION
    assert optmanager.version_action.version == TEST_VERSION

    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),
    ]

    optmanager.update_version_string()

    assert optmanager.version == TEST_VERSION
    assert (optmanager.version_action.version == TEST_VERSION +
            " (Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0) " +
            utils.get_python_version())
Ejemplo n.º 2
0
def test_update_version_string(optmanager):
    """Verify we update the version string idempotently."""
    assert optmanager.version == TEST_VERSION
    assert optmanager.parser.version == TEST_VERSION

    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),
    ]

    optmanager.update_version_string()

    assert optmanager.version == TEST_VERSION
    assert (optmanager.parser.version == TEST_VERSION + ' ('
            'Testing 100: 0.0.0, Testing 101: 0.0.0, Testing 300: 0.0.0) ' +
            utils.get_python_version())
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
from unittest import mock

import pytest

from flake8.main import debug
from flake8.options import manager


def test_dependencies():
    """Verify that we format our dependencies appropriately."""
    assert [] == debug.dependencies()


@pytest.mark.parametrize('plugins, expected', [
    ([], []),
    ([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))
Ejemplo n.º 6
0
from flake8.main import debug
from flake8.options import manager


def test_dependencies():
    """Verify that we format our dependencies appropriately."""
    assert [] == debug.dependencies()


@pytest.mark.parametrize(
    "plugins, expected",
    [
        ([], []),
        (
            [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},
Ejemplo n.º 7
0
def test_format_plugin():
    """Verify that format_plugin turns a tuple into a dictionary."""
    plugin = manager.OptionManager.format_plugin(
        manager.PluginVersion('Testing', '0.0.0', False))
    assert plugin['name'] == 'Testing'
    assert plugin['version'] == '0.0.0'