コード例 #1
0
    def test_parse_invalid_arg(self):
        # No code quality test provided
        invalid_argv = [[], ["--html-report", "diff_cover.html"]]

        for argv in invalid_argv:
            with self.assertRaises(SystemExit):
                print(f"args = {argv}")
                parse_quality_args(argv)
コード例 #2
0
    def test_parse_invalid_arg(self):
        # No code quality test provided
        invalid_argv = [[], ['--html-report', 'diff_cover.html']]

        for argv in invalid_argv:
            with self.assertRaises(SystemExit):
                print("args = {}".format(argv))
                parse_quality_args(argv)
コード例 #3
0
def _test_parse_with_path_patterns(name):
    argv = ["--violations", "pep8"]
    arg_dict = parse_quality_args(argv)
    assert arg_dict.get("include") is None

    argv = ["--violations", "pep8", f"--{name}", "noneed/*.py"]
    arg_dict = parse_quality_args(argv)
    assert arg_dict.get(name) == ["noneed/*.py"]

    argv = ["--violations", "pep8", f"--{name}", "noneed/*.py", "other/**/*.py"]
    arg_dict = parse_quality_args(argv)
    assert arg_dict.get(name) == ["noneed/*.py", "other/**/*.py"]
コード例 #4
0
    def _test_parse_with_path_patterns(self, name):
        argv = ["--violations", "pep8"]
        arg_dict = parse_quality_args(argv)
        self.assertIsNone(arg_dict.get("include"))

        argv = ["--violations", "pep8", f"--{name}", "noneed/*.py"]
        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get(name), ["noneed/*.py"])

        argv = [
            "--violations", "pep8", f"--{name}", "noneed/*.py", "other/**/*.py"
        ]
        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get(name), ["noneed/*.py", "other/**/*.py"])
コード例 #5
0
    def test_parse_with_no_html_report(self):
        argv = ['--violations', 'pylint']

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get('violations'), 'pylint')
        self.assertEqual(arg_dict.get('input_reports'), [])
        self.assertEqual(arg_dict.get('ignore_unstaged'), False)
コード例 #6
0
    def test_parse_with_no_html_report(self):
        argv = ["--violations", "pylint"]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get("violations"), "pylint")
        self.assertEqual(arg_dict.get("input_reports"), [])
        self.assertFalse(arg_dict.get("ignore_unstaged"))
        self.assertEqual(arg_dict.get("diff_range_notation"), "...")
コード例 #7
0
    def test_parse_with_exclude(self):
        argv = ["--violations", "pep8"]
        arg_dict = parse_quality_args(argv)
        self.assertIsNone(arg_dict.get("exclude"))

        argv = ["--violations", "pep8", "--exclude", "noneed/*.py"]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get("exclude"), ["noneed/*.py"])

        argv = [
            "--violations", "pep8", "--exclude", "noneed/*.py", "other/**/*.py"
        ]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get("exclude"),
                         ["noneed/*.py", "other/**/*.py"])
コード例 #8
0
    def test_parse_with_exclude(self):
        argv = ['--violations', 'pep8']
        arg_dict = parse_quality_args(argv)
        self.assertIsNone(arg_dict.get('exclude'))

        argv = ['--violations', 'pep8', '--exclude', 'noneed/*.py']

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get('exclude'), ['noneed/*.py'])

        argv = [
            '--violations', 'pep8', '--exclude', 'noneed/*.py', 'other/**/*.py'
        ]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get('exclude'),
                         ['noneed/*.py', 'other/**/*.py'])
コード例 #9
0
 def test_parse_with_options(self):
     argv = [
         '--violations', 'pycodestyle',
         '--options="--exclude=\'*/migrations*\'"'
     ]
     arg_dict = parse_quality_args(argv)
     self.assertEqual(arg_dict.get('options'),
                      '"--exclude=\'*/migrations*\'"')
コード例 #10
0
def test_parse_with_options():
    argv = [
        "--violations",
        "pycodestyle",
        "--options=\"--exclude='*/migrations*'\"",
    ]
    arg_dict = parse_quality_args(argv)
    assert arg_dict.get("options") == "\"--exclude='*/migrations*'\""
コード例 #11
0
def test_parse_with_multiple_input_reports():
    argv = ["--violations", "pylint", "pylint_report_1.txt", "pylint_report_2.txt"]

    arg_dict = parse_quality_args(argv)
    assert arg_dict.get("input_reports") == [
        "pylint_report_1.txt",
        "pylint_report_2.txt",
    ]
コード例 #12
0
def test_parse_with_no_html_report():
    argv = ["--violations", "pylint"]

    arg_dict = parse_quality_args(argv)
    assert arg_dict.get("violations") == "pylint"
    assert arg_dict.get("input_reports") == []
    assert not arg_dict.get("ignore_unstaged")
    assert arg_dict.get("diff_range_notation") == "..."
コード例 #13
0
    def test_parse_with_multiple_input_reports(self):
        argv = [
            '--violations', 'pylint', 'pylint_report_1.txt',
            'pylint_report_2.txt'
        ]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(arg_dict.get('input_reports'),
                         ['pylint_report_1.txt', 'pylint_report_2.txt'])
コード例 #14
0
    def test_parse_diff_range_notation(self):
        argv = ['--violations', 'pep8', '--diff-range-notation=..']

        arg_dict = parse_quality_args(argv)

        self.assertEqual(arg_dict.get('violations'), 'pep8')
        self.assertIsNone(arg_dict.get('html_report'))
        self.assertEqual(arg_dict.get('input_reports'), [])
        self.assertFalse(arg_dict.get('ignore_unstaged'))
        self.assertEqual(arg_dict.get('diff_range_notation'), '..')
コード例 #15
0
def test_parse_diff_range_notation():
    argv = ["--violations", "pep8", "--diff-range-notation=.."]

    arg_dict = parse_quality_args(argv)

    assert arg_dict.get("violations") == "pep8"
    assert arg_dict.get("html_report") is None
    assert arg_dict.get("input_reports") == []
    assert not arg_dict.get("ignore_unstaged")
    assert arg_dict.get("diff_range_notation") == ".."
コード例 #16
0
def test_parse_with_html_report():
    argv = ["--violations", "pycodestyle", "--html-report", "diff_cover.html"]

    arg_dict = parse_quality_args(argv)

    assert arg_dict.get("violations") == "pycodestyle"
    assert arg_dict.get("html_report") == "diff_cover.html"
    assert arg_dict.get("input_reports") == []
    assert not arg_dict.get("ignore_unstaged")
    assert arg_dict.get("diff_range_notation") == "..."
コード例 #17
0
    def test_parse_diff_range_notation(self):
        argv = ["--violations", "pep8", "--diff-range-notation=.."]

        arg_dict = parse_quality_args(argv)

        self.assertEqual(arg_dict.get("violations"), "pep8")
        self.assertIsNone(arg_dict.get("html_report"))
        self.assertEqual(arg_dict.get("input_reports"), [])
        self.assertFalse(arg_dict.get("ignore_unstaged"))
        self.assertEqual(arg_dict.get("diff_range_notation"), "..")
コード例 #18
0
    def test_parse_with_html_report(self):
        argv = [
            '--violations', 'pycodestyle', '--html-report', 'diff_cover.html'
        ]

        arg_dict = parse_quality_args(argv)

        self.assertEqual(arg_dict.get('violations'), 'pycodestyle')
        self.assertEqual(arg_dict.get('html_report'), 'diff_cover.html')
        self.assertEqual(arg_dict.get('input_reports'), [])
        self.assertEqual(arg_dict.get('ignore_unstaged'), False)
コード例 #19
0
    def test_parse_with_multiple_input_reports(self):
        argv = [
            "--violations", "pylint", "pylint_report_1.txt",
            "pylint_report_2.txt"
        ]

        arg_dict = parse_quality_args(argv)
        self.assertEqual(
            arg_dict.get("input_reports"),
            ["pylint_report_1.txt", "pylint_report_2.txt"],
        )
コード例 #20
0
    def test_parse_with_html_report(self):
        argv = [
            "--violations", "pycodestyle", "--html-report", "diff_cover.html"
        ]

        arg_dict = parse_quality_args(argv)

        self.assertEqual(arg_dict.get("violations"), "pycodestyle")
        self.assertEqual(arg_dict.get("html_report"), "diff_cover.html")
        self.assertEqual(arg_dict.get("input_reports"), [])
        self.assertFalse(arg_dict.get("ignore_unstaged"))
        self.assertEqual(arg_dict.get("diff_range_notation"), "...")
コード例 #21
0
    def test_parse_with_ignored_unstaged(self):
        argv = ['--violations', 'pylint', '--ignore-unstaged']

        arg_dict = parse_quality_args(argv)
        self.assertTrue(arg_dict.get('ignore_unstaged'))
コード例 #22
0
    def test_parse_with_ignored_unstaged(self):
        argv = ["--violations", "pylint", "--ignore-unstaged"]

        arg_dict = parse_quality_args(argv)
        self.assertTrue(arg_dict.get("ignore_unstaged"))