Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_cli_config():
"""Verify opening and reading the file specified via the cli."""
cli_filepath = CLI_SPECIFIED_FILEPATH
finder = config.ConfigFileFinder('flake8', None, [])
parsed_config = finder.cli_config(cli_filepath)
assert parsed_config.has_section('flake8')
def test_get_local_plugins():
"""Verify get_local_plugins returns expected plugins."""
config_fixture_path = 'tests/fixtures/config_files/local-plugin.ini'
config_finder = config.ConfigFileFinder('flake8', [])
with mock.patch.object(config_finder, 'local_config_files') as localcfs:
localcfs.return_value = [config_fixture_path]
local_plugins = config.get_local_plugins(config_finder)
assert local_plugins.extension == ['XE = test_plugins:ExtensionTestPlugin']
assert local_plugins.report == ['XR = test_plugins:ReportTestPlugin']
def test_generate_possible_local_files(args, expected):
"""Verify generation of all possible config paths."""
finder = config.ConfigFileFinder('flake8', args, [])
assert (list(finder.generate_possible_local_files())
== expected)
def get_style_guide(**kwargs):
r"""Provision a StyleGuide for use.
:param \*\*kwargs:
Keyword arguments that provide some options for the StyleGuide.
:returns:
An initialized StyleGuide
:rtype:
:class:`StyleGuide`
"""
application = app.Application()
prelim_opts, remaining_args = application.parse_preliminary_options([])
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
config_finder = config.ConfigFileFinder(
application.program, prelim_opts.append_config
)
application.find_plugins(
config_finder, prelim_opts.config, prelim_opts.isolated
)
application.register_plugin_options()
application.parse_configuration_and_cli(config_finder, remaining_args)
# We basically want application.initialize to be called but with these
# options set instead before we make our formatter, notifier, internal
# style guide and file checker manager.
options = application.options
for key, value in kwargs.items():
try:
getattr(options, key)
setattr(options, key, value)