コード例 #1
0
ファイル: test_code_formatting.py プロジェクト: Brtle/obspy
    def test_flake8(self):
        """
        Test codebase for compliance with the flake8 tool.
        """
        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        # not sure if there's a better way to get a hold of default ignore
        # codes..
        default_ignore_codes = \
            flake8.get_style_guide().options.__dict__['ignore']
        ignore_codes = list(set(default_ignore_codes + FLAKE8_IGNORE_CODES))
        style_guide = flake8.get_style_guide(ignore=ignore_codes)

        untracked_files = get_untracked_files_from_git() or []
        files = []
        for filename in get_all_py_files():
            if filename in untracked_files:
                continue
            for pattern in FLAKE8_EXCLUDE_FILES:
                if fnmatch.fnmatch(filename, pattern):
                    break
            else:
                files.append(filename)
        report = style_guide.check_files(files)

        # Make sure no error occurred.
        assert report.total_errors == 0
コード例 #2
0
    def test_flake8(self):
        """
        Test codebase for compliance with the flake8 tool.
        """
        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        # not sure if there's a better way to get a hold of default ignore
        # codes..
        default_ignore_codes = \
            flake8.get_style_guide().options.__dict__['ignore']
        ignore_codes = list(set(default_ignore_codes + FLAKE8_IGNORE_CODES))
        style_guide = flake8.get_style_guide(ignore=ignore_codes)

        untracked_files = get_untracked_files_from_git() or []
        files = []
        for filename in get_all_py_files():
            if filename in untracked_files:
                continue
            for pattern in FLAKE8_EXCLUDE_FILES:
                if fnmatch.fnmatch(filename, pattern):
                    break
            else:
                files.append(filename)
        report = style_guide.check_files(files)

        # Make sure no error occured.
        assert report.total_errors == 0
コード例 #3
0
    def test_flake8(self):
        test_dir = os.path.dirname(
            os.path.abspath(inspect.getfile(inspect.currentframe())))
        mtspec_dir = os.path.dirname(test_dir)

        # Ignore automatically generated files.
        ignore_files = [os.path.join("gui", "qt_window.py")]
        ignore_files = [os.path.join(mtspec_dir, _i) for _i in ignore_files]
        files = []
        for dirpath, _, filenames in os.walk(mtspec_dir):
            filenames = [
                _i for _i in filenames
                if os.path.splitext(_i)[-1] == os.path.extsep + "py"
            ]
            if not filenames:
                continue
            for py_file in filenames:
                full_path = os.path.join(dirpath, py_file)
                if full_path in ignore_files:
                    continue
                files.append(full_path)

        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        style_guide = flake8.get_style_guide()
        report = style_guide.check_files(files)

        # Make sure no error occured.
        self.assertEqual(report.total_errors, 0)
コード例 #4
0
def test_flake8():
    test_dir = os.path.dirname(os.path.abspath(inspect.getfile(
        inspect.currentframe())))
    pyflex = os.path.dirname(test_dir)

    ignore_files = []
    ignore_files = [os.path.join(pyflex, _i) for _i in ignore_files]
    files = []
    for dirpath, _, filenames in os.walk(pyflex):
        filenames = [_i for _i in filenames if
                     os.path.splitext(_i)[-1] == os.path.extsep + "py"]
        if not filenames:
            continue
        for py_file in filenames:
            full_path = os.path.join(dirpath, py_file)
            if full_path in ignore_files:  # pragma: no cover
                continue
            files.append(full_path)

    # Import the legacy API as flake8 3.0 currently has not official
    # public API - this has to be changed at some point.
    from flake8.api import legacy as flake8
    style_guide = flake8.get_style_guide()
    report = style_guide.check_files(files)

    # Make sure no error occured.
    assert report.total_errors == 0
コード例 #5
0
    def test_flake8(self):
        test_dir = os.path.dirname(os.path.abspath(inspect.getfile(
            inspect.currentframe())))
        mtspec_dir = os.path.dirname(test_dir)

        # Ignore automatically generated files.
        ignore_files = [os.path.join("gui", "qt_window.py")]
        ignore_files = [os.path.join(mtspec_dir, _i) for _i in ignore_files]
        files = []
        for dirpath, _, filenames in os.walk(mtspec_dir):
            filenames = [_i for _i in filenames if
                         os.path.splitext(_i)[-1] == os.path.extsep + "py"]
            if not filenames:
                continue
            for py_file in filenames:
                full_path = os.path.join(dirpath, py_file)
                if full_path in ignore_files:
                    continue
                files.append(full_path)

        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        style_guide = flake8.get_style_guide()
        report = style_guide.check_files(files)

        # Make sure no error occured.
        self.assertEqual(report.total_errors, 0)
コード例 #6
0
    def test_flake8(self):
        """
        Test codebase for compliance with the flake8 tool.
        """
        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        # --hang-closing allows valid indented closing brackets, see
        # https://github.com/PyCQA/pycodestyle/issues/103#issuecomment-17366719
        style_guide = flake8.get_style_guide(
            ignore=FLAKE8_IGNORE_CODES, hang_closing=True)

        untracked_files = get_untracked_files_from_git() or []
        files = []
        for filename in get_all_py_files():
            if filename in untracked_files:
                continue
            for pattern in FLAKE8_EXCLUDE_FILES:
                if fnmatch.fnmatch(filename, pattern):
                    break
            else:
                files.append(filename)
        report = style_guide.check_files(files)

        # Make sure no error occurred.
        assert report.total_errors == 0
コード例 #7
0
    def test_flake8(self):
        """
        Test codebase for compliance with the flake8 tool.
        """
        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        # not sure if there's a better way to get a hold of default ignore
        # codes..
        default_ignore_codes = \
            flake8.get_style_guide().options.__dict__['ignore']
        try:
            import pycodestyle
        except ImportError:
            pass
        else:
            default_ignore_codes += pycodestyle.DEFAULT_IGNORE.split(',')
        ignore_codes = list(set(default_ignore_codes + FLAKE8_IGNORE_CODES))
        # --hang-closing allows valid indented closing brackets, see
        # https://github.com/PyCQA/pycodestyle/issues/103#issuecomment-17366719
        style_guide = flake8.get_style_guide(
            ignore=ignore_codes, hang_closing=True)

        untracked_files = get_untracked_files_from_git() or []
        files = []
        for filename in get_all_py_files():
            if filename in untracked_files:
                continue
            for pattern in FLAKE8_EXCLUDE_FILES:
                if fnmatch.fnmatch(filename, pattern):
                    break
            else:
                files.append(filename)
        report = style_guide.check_files(files)

        # Make sure no error occurred.
        assert report.total_errors == 0
コード例 #8
0
def test_flake8():
    test_dir = os.path.dirname(
        os.path.abspath(inspect.getfile(inspect.currentframe())))
    lasif_dir = os.path.dirname(test_dir)

    # Ignore automatically generated files.
    ignore_files = [
        os.path.join("misfit_gui", "qt_window.py"),
        os.path.join("ses3d_model_gui", "ses3d_model_gui.py"),
    ]
    ignore_files = [os.path.join(lasif_dir, _i) for _i in ignore_files]
    files = []
    for dirpath, _, filenames in os.walk(lasif_dir):
        filenames = [
            _i for _i in filenames
            if os.path.splitext(_i)[-1] == os.path.extsep + "py"
        ]
        if not filenames:
            continue
        for py_file in filenames:
            full_path = os.path.join(dirpath, py_file)
            if full_path in ignore_files:
                continue
            files.append(full_path)

    # Import the legacy API as flake8 3.0 currently has not official
    # public API - this has to be changed at some point.
    from flake8.api import legacy as flake8

    # We ignore E501 because sometimes it interferes with Black style
    # formatting and it gets really annoying. Black takes care of nice
    # formatting anyway.
    style_guide = flake8.get_style_guide(extend_ignore=(
        "F811",
        "F401",
        "E402",
        "E722",
        "E741",
        "E503",
        "W503",
        "W605",
        "E203",
        "E501",
        "E231",
    ))
    report = style_guide.check_files(files)

    # Make sure no error occured.
    assert report.total_errors == 0
コード例 #9
0
    def test_flake8(self):
        """
        Test codebase for compliance with the flake8 tool.
        """
        # Import the legacy API as flake8 3.0 currently has not official
        # public API - this has to be changed at some point.
        from flake8.api import legacy as flake8
        style_guide = flake8.get_style_guide(ignore=FLAKE8_IGNORE_CODES)

        untracked_files = get_untracked_files_from_git() or []
        files = []
        for filename in get_all_py_files():
            if filename in untracked_files:
                continue
            for pattern in FLAKE8_EXCLUDE_FILES:
                if fnmatch.fnmatch(filename, pattern):
                    break
            else:
                files.append(filename)
        report = style_guide.check_files(files)

        # Make sure no error occured.
        assert report.total_errors == 0
コード例 #10
0
ファイル: rhsm_stylish.py プロジェクト: alikins/rhsm-stylish
 def __init__(self, tree, filename):
     self.messages = []
     self.tree = tree
     self.filename = filename
     self.style_guide = flake8.get_style_guide(checker_class=RhsmStylishChecker)
     self.checkers = _get_checkers()