From 1f6adf64f8673d6d72a7c69b167b2b9260289b97 Mon Sep 17 00:00:00 2001 From: QuentinN42 Date: Thu, 10 Feb 2022 12:49:51 +0100 Subject: [PATCH] test: Class to test all fmt --- coverage.xml | 6 +++++- tests/test_format.py | 17 ++++++++++++++--- yamllint/format.py | 6 +++++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/coverage.xml b/coverage.xml index 97a1626..d58a31d 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,5 +1,5 @@ - + @@ -634,6 +634,10 @@ + + + + diff --git a/tests/test_format.py b/tests/test_format.py index 2152afb..e2ceb4b 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -16,9 +16,6 @@ from yamllint.format import ( ) -INPUT = [] - - class TextToXMLTestCase(unittest.TestCase): specials = { @@ -91,3 +88,17 @@ class FormaterTestCase(unittest.TestCase): inst.show_problems_for_file([], "a") with self.assertRaises(NotImplementedError): inst.show_problem(None, "a") + + +class FormatersTestCase(unittest.TestCase): + + args = [ + (ParsableFormater(True), {"file1.yml": []}, ""), + ] + + def test_all_formaters(self): + for inst, inp, ret in self.args: + self.assertEqual( + inst.show_problems_for_all_files(inp), + ret + ) diff --git a/yamllint/format.py b/yamllint/format.py index b6f44d7..95c7712 100644 --- a/yamllint/format.py +++ b/yamllint/format.py @@ -381,7 +381,11 @@ class CodeclimateFormater(Formater): def max_level(all_problems): """Return the max level of all problems.""" - all_levels = [problem.level for problems in all_problems.values() for problem in problems] + all_levels = [ + problem.level + for problems in all_problems.values() + for problem in problems + ] if all_levels: return max(map(lambda x: PROBLEM_LEVELS[x], all_levels)) return 0