From f3ff20ada4069045b273c25afa76222117926c74 Mon Sep 17 00:00:00 2001 From: Oleksii Proshchenko <80070761+MasterpieceElbow@users.noreply.github.com> Date: Wed, 5 Jan 2022 16:10:25 +0200 Subject: [PATCH] Group one_line tests, edited start of README.md --- README.md | 4 ++++ tests/test_main.py | 28 +++++++++++----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3930d1e7..decc04b9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# Linter formatter + +- Read [the guideline](https://github.com/mate-academy/py-task-guideline/blob/main/README.md) before start + Линтер flake8 выдает такой отчет об ошибках при проверке каталога с файлами исходного кода: ```python diff --git a/tests/test_main.py b/tests/test_main.py index 2d33aa41..a2669925 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -74,11 +74,19 @@ def test_format_linter_error(error_linter, error_mate): ) -def test_format_linter_error_one_line(): - code = inspect.getsource(format_linter_error) +@pytest.mark.parametrize( + "func", + [ + format_linter_error, + format_single_linter_file, + format_linter_report, + ], +) +def test_format_functions_one_line(func): + code = inspect.getsource(func) assert ( isinstance(ast.parse(code).body[0].body[0], ast.Return) is True - ), "Function 'format_linter_error' should contain only return statement" + ), f"Function '{func.__name__}' should contain only return statement" @pytest.mark.parametrize( @@ -137,13 +145,6 @@ def test_format_single_linter_file(file_path, errors, result): ) -def test_format_single_linter_file_one_line(): - code = inspect.getsource(format_single_linter_file) - assert ( - isinstance(ast.parse(code).body[0].body[0], ast.Return) is True - ), "Function 'format_single_linter_file' should contain only return statement" - - @pytest.mark.parametrize( "errors_linter,errors_mate", [ @@ -342,10 +343,3 @@ def test_format_linter_report(errors_linter, errors_mate): f"Function 'format_linter_report' should return {errors_mate} " f"when 'errors' equals to {errors_linter}" ) - - -def test_format_linter_report_one_line(): - code = inspect.getsource(format_linter_report) - assert ( - isinstance(ast.parse(code).body[0].body[0], ast.Return) is True - ), "Function 'format_linter_report' should contain only return statement"