mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 14:54:17 +00:00
application: Pass returned prelim options to .configure_logging()
The verbosity and output file options can be obtained from options returned by `.parse_preliminary_options_and_args()`, instead of state from the `Application` object.
This commit is contained in:
parent
6043e90855
commit
55ef2c6f5e
3 changed files with 17 additions and 8 deletions
|
|
@ -28,10 +28,10 @@ def get_style_guide(**kwargs):
|
||||||
:class:`StyleGuide`
|
:class:`StyleGuide`
|
||||||
"""
|
"""
|
||||||
application = app.Application()
|
application = app.Application()
|
||||||
application.parse_preliminary_options_and_args([])
|
prelim_opts, prelim_args = application.parse_preliminary_options_and_args(
|
||||||
flake8.configure_logging(
|
[]
|
||||||
application.prelim_opts.verbose, application.prelim_opts.output_file
|
|
||||||
)
|
)
|
||||||
|
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||||
application.make_config_finder()
|
application.make_config_finder()
|
||||||
application.find_plugins()
|
application.find_plugins()
|
||||||
application.register_plugin_options()
|
application.register_plugin_options()
|
||||||
|
|
|
||||||
|
|
@ -357,10 +357,10 @@ class Application(object):
|
||||||
"""
|
"""
|
||||||
# NOTE(sigmavirus24): When updating this, make sure you also update
|
# NOTE(sigmavirus24): When updating this, make sure you also update
|
||||||
# our legacy API calls to these same methods.
|
# our legacy API calls to these same methods.
|
||||||
self.parse_preliminary_options_and_args(argv)
|
prelim_opts, prelim_args = self.parse_preliminary_options_and_args(
|
||||||
flake8.configure_logging(
|
argv
|
||||||
self.prelim_opts.verbose, self.prelim_opts.output_file
|
|
||||||
)
|
)
|
||||||
|
flake8.configure_logging(prelim_opts.verbose, prelim_opts.output_file)
|
||||||
self.make_config_finder()
|
self.make_config_finder()
|
||||||
self.find_plugins()
|
self.find_plugins()
|
||||||
self.register_plugin_options()
|
self.register_plugin_options()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
"""Tests for Flake8's legacy API."""
|
"""Tests for Flake8's legacy API."""
|
||||||
|
import argparse
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
@ -8,9 +10,16 @@ from flake8.formatting import base as formatter
|
||||||
|
|
||||||
def test_get_style_guide():
|
def test_get_style_guide():
|
||||||
"""Verify the methods called on our internal Application."""
|
"""Verify the methods called on our internal Application."""
|
||||||
|
prelim_opts = argparse.Namespace(
|
||||||
|
output_file=None,
|
||||||
|
verbose=0,
|
||||||
|
)
|
||||||
mockedapp = mock.Mock()
|
mockedapp = mock.Mock()
|
||||||
mockedapp.prelim_opts.verbose = 0
|
mockedapp.prelim_opts = prelim_opts
|
||||||
mockedapp.prelim_opts.output_file = None
|
mockedapp.parse_preliminary_options_and_args.return_value = (
|
||||||
|
prelim_opts,
|
||||||
|
[],
|
||||||
|
)
|
||||||
with mock.patch('flake8.main.application.Application') as application:
|
with mock.patch('flake8.main.application.Application') as application:
|
||||||
application.return_value = mockedapp
|
application.return_value = mockedapp
|
||||||
style_guide = api.get_style_guide()
|
style_guide = api.get_style_guide()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue