Esempio n. 1
0
 def test_enables_off_by_default_extensions(self):
     with mock.patch('flake8.engine._register_extensions') as re:
         re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
         parser, options = engine.get_parser()
         parser.parse_args(['--select=X'])
         sg = engine.StyleGuide(parser=parser)
         assert 'X' not in sg.options.ignore
Esempio n. 2
0
def install_hook():
    vcs = find_vcs()

    if not vcs:
        p = get_parser()[0]
        sys.stderr.write('Error: could not find either a git or mercurial '
                         'directory. Please re-run this in a proper '
                         'repository.')
        p.print_help()
        sys.exit(1)

    status = 0
    if 'git' in vcs:
        if os.path.exists(vcs):
            sys.exit('Error: hook already exists (%s)' % vcs)
        with open(vcs, 'w') as fd:
            fd.write(git_hook_file)
        # rwxr--r--
        os.chmod(vcs, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
    elif 'hg' in vcs:
        _install_hg_hook(vcs)
    else:
        status = 1

    sys.exit(status)
Esempio n. 3
0
def install_hook():
    vcs = find_vcs()

    if not vcs:
        p = get_parser()
        sys.stderr.write('Error: could not find either a git or mercurial '
                         'directory. Please re-run this in a proper '
                         'repository.')
        p.print_help()
        sys.exit(1)

    status = 0
    if 'git' in vcs:
        with open(vcs, 'w+') as fd:
            fd.write(git_hook_file)
        # 0b111100100 == rwxr--r--
        # Python 2.5 doesn't support 0b syntax so note that the above binary
        # value is equivalent to 484 in decimal
        os.chmod(vcs, 484)
    elif 'hg' in vcs:
        _install_hg_hook(vcs)
    else:
        status = 1

    sys.exit(status)
Esempio n. 4
0
def install_hook():
    vcs = find_vcs()

    if not vcs:
        p = get_parser()[0]
        sys.stderr.write('Error: could not find either a git or mercurial '
                         'directory. Please re-run this in a proper '
                         'repository.')
        p.print_help()
        sys.exit(1)

    status = 0
    if 'git' in vcs:
        if os.path.exists(vcs):
            sys.exit('Error: hook already exists (%s)' % vcs)
        with open(vcs, 'w') as fd:
            fd.write(git_hook_file)
        # rwxr--r--
        os.chmod(vcs, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
    elif 'hg' in vcs:
        _install_hg_hook(vcs)
    else:
        status = 1

    sys.exit(status)
Esempio n. 5
0
 def test_enables_off_by_default_extensions(self):
     with mock.patch('flake8.engine._register_extensions') as re:
         re.return_value = ([('fake_ext', '0.1a1')], [], [], ['X'])
         parser, options = engine.get_parser()
         parser.parse_args(['--select=X'])
         sg = engine.StyleGuide(parser=parser)
         assert 'X' not in sg.options.ignore
Esempio n. 6
0
 def initialize_options(self):
     self.option_to_cmds = {}
     parser = get_parser()[0]
     for opt in parser.option_list:
         cmd_name = opt._long_opts[0][2:]
         option_name = cmd_name.replace('-', '_')
         self.option_to_cmds[option_name] = opt
         setattr(self, option_name, None)
Esempio n. 7
0
 def initialize_options(self):
     self.option_to_cmds = {}
     parser = get_parser()[0]
     for opt in parser.option_list:
         cmd_name = opt._long_opts[0][2:]
         option_name = cmd_name.replace('-', '_')
         self.option_to_cmds[option_name] = cmd_name
         setattr(self, option_name, None)
Esempio n. 8
0
def scan_for_checkers(request):
    parser, options_hooks = get_parser()
    args_marker = request.node.get_marker("flake8_args")
    if args_marker is None:
        args = []
    else:
        args = list(args_marker.args)
    opts, args = parser.parse_args(args)
    opts.ignore = tuple(opts.ignore)
    EbbLint.parse_options(opts)
Esempio n. 9
0
def scan_for_checkers(request):
    parser, options_hooks = get_parser()
    args_marker = request.node.get_closest_marker('flake8_args')
    if args_marker is None:
        args = []
    else:
        args = list(args_marker.args)
    opts, args = parser.parse_args(args)
    opts.ignore = tuple(opts.ignore)
    EbbLint.parse_options(opts)
Esempio n. 10
0
 def test_get_parser(self):
     # setup
     re = self.start_patch("flake8.engine._register_extensions")
     gpv = self.start_patch("flake8.engine.get_python_version")
     pgp = self.start_patch("pep8.get_parser")
     m = mock.Mock()
     re.return_value = ([("pyflakes", "0.7"), ("mccabe", "0.2")], [], [])
     gpv.return_value = "Python Version"
     pgp.return_value = m
     # actual call we're testing
     parser, hooks = engine.get_parser()
     # assertions
     re.assert_called()
     gpv.assert_called()
     pgp.assert_called_once_with("flake8", "%s (pyflakes: 0.7, mccabe: 0.2) Python Version" % __version__)
     m.remove_option.assert_called()
     m.add_option.assert_called()
     self.assertEqual(parser, m)
     self.assertEqual(hooks, [])
     # clean-up
     self.stop_patches()
Esempio n. 11
0
def install_hook():
    vcs = find_vcs()

    if not vcs:
        p = get_parser()
        sys.stderr.write('Error: could not find either a git or mercurial '
                         'directory. Please re-run this in a proper '
                         'repository.')
        p.print_help()
        sys.exit(1)

    status = 0
    if 'git' in vcs:
        with open(vcs, 'w+') as fd:
            fd.write(git_hook_file)
        os.chmod(vcs, 744)
    elif 'hg' in vcs:
        _install_hg_hook(vcs)
    else:
        status = 1

    sys.exit(status)
Esempio n. 12
0
def install_hook():
    vcs = find_vcs()

    if not vcs:
        p = get_parser()
        sys.stderr.write('Error: could not find either a git or mercurial '
                         'directory. Please re-run this in a proper '
                         'repository.')
        p.print_help()
        sys.exit(1)

    status = 0
    if 'git' in vcs:
        with open(vcs, 'w+') as fd:
            fd.write(git_hook_file)
        os.chmod(vcs, 744)
    elif 'hg' in vcs:
        _install_hg_hook(vcs)
    else:
        status = 1

    sys.exit(status)
Esempio n. 13
0
 def test_get_parser(self):
     # setup
     re = self.start_patch('flake8.engine._register_extensions')
     gpv = self.start_patch('flake8.engine.get_python_version')
     pgp = self.start_patch('pep8.get_parser')
     m = mock.Mock()
     re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [])
     gpv.return_value = 'Python Version'
     pgp.return_value = m
     # actual call we're testing
     parser, hooks = engine.get_parser()
     # assertions
     re.assert_called()
     gpv.assert_called()
     pgp.assert_called_once_with(
         'flake8',
         '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__)
     m.remove_option.assert_called()
     m.add_option.assert_called()
     self.assertEqual(parser, m)
     self.assertEqual(hooks, [])
     # clean-up
     self.stop_patches()
Esempio n. 14
0
 def test_get_parser(self):
     # setup
     re = self.start_patch('flake8.engine._register_extensions')
     gpv = self.start_patch('flake8.engine.get_python_version')
     pgp = self.start_patch('pep8.get_parser')
     m = mock.Mock()
     re.return_value = ([('pyflakes', '0.7'), ('mccabe', '0.2')], [], [])
     gpv.return_value = 'Python Version'
     pgp.return_value = m
     # actual call we're testing
     parser, hooks = engine.get_parser()
     # assertions
     re.assert_called()
     gpv.assert_called()
     pgp.assert_called_once_with(
         'flake8',
         '%s (pyflakes: 0.7, mccabe: 0.2) Python Version' % __version__)
     m.remove_option.assert_called()
     m.add_option.assert_called()
     self.assertEqual(parser, m)
     self.assertEqual(hooks, [])
     # clean-up
     self.stop_patches()
Esempio n. 15
0
# -*- coding: utf-8 -*-
Esempio n. 16
0
# -*- coding: utf-8 -*-