Revert "local-check-factory CLI option"

This reverts commit e72ce1831a.

Change-Id: Ia1b042aa036787ba2dfa86f49b1cff65a4bd0faf
This commit is contained in:
Ian Cordasco 2016-12-05 17:31:03 +00:00
parent e72ce1831a
commit 206b421d0a
3 changed files with 7 additions and 36 deletions

View File

@ -129,13 +129,3 @@ register. Such as:
[hacking]
local-check-factory = nova.tests.hacking.factory
In addition, hacking provides a flake8 option to specify the
``local-check-factory`` on the CLI. When specified via CLI with
the ``--local-check-factory`` option to flake8, the specified
factory takes precedence over ``tox.ini`` and the local checks
from ``tox.ini`` are not used.
For example, via CLI (any check specified in ``tox.ini`` are ignored)::
flake8 --local-check-factory mypkg.warn_checks --exit-zero

View File

@ -145,29 +145,20 @@ class ProxyChecks(GlobalCheck):
name = 'ProxyChecker'
@classmethod
def parse_options(cls, options):
def add_options(cls, parser):
# We're looking for local checks, so we need to include the local
# dir in the search path
sys.path.append('.')
local_check_fact = options.factory or CONF.get('local-check-factory')
if not options.factory:
# local factory on CLI trumps everything else
local_check = CONF.get_multiple('local-check', default=[])
for check_path in set(local_check):
if check_path.strip():
checker = pbr.util.resolve_name(check_path)
pep8.register_check(checker)
local_check = CONF.get_multiple('local-check', default=[])
for check_path in set(local_check):
if check_path.strip():
checker = pbr.util.resolve_name(check_path)
pep8.register_check(checker)
local_check_fact = CONF.get('local-check-factory')
if local_check_fact:
factory = pbr.util.resolve_name(local_check_fact)
factory(pep8.register_check)
sys.path.pop()
@classmethod
def add_options(cls, parser):
# allow local check factory to be specified as CLI option to flake8
# in which case its used as the sole source of checks
parser.add_option('--local-check-factory', action='store',
type='string', dest='factory')

View File

@ -14,10 +14,8 @@
# limitations under the License.
from flake8 import engine
import mock
import pep8
from hacking import core
import hacking.tests
@ -36,11 +34,3 @@ class HackingTestCase(hacking.tests.TestCase):
report=report)
checker.check_all()
self.assertIn("L100", report.counters)
@mock.patch.object(core, 'CONF')
def test_local_check_factory_cli_option(self, mock_conf):
mock_opts = mock.Mock()
mock_opts.factory = 'mypkg.factory'
self.assertRaises(
ImportError, core.ProxyChecks.parse_options, mock_opts)
self.assertFalse(mock_conf.called)