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)
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)
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"]
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"])
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)
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"), "...")
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"])
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'])
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*\'"')
def test_parse_with_options(): argv = [ "--violations", "pycodestyle", "--options=\"--exclude='*/migrations*'\"", ] arg_dict = parse_quality_args(argv) assert arg_dict.get("options") == "\"--exclude='*/migrations*'\""
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", ]
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") == "..."
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'])
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'), '..')
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") == ".."
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") == "..."
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"), "..")
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)
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"], )
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"), "...")
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'))
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"))