From 8b50e5234bc415c7f2c20a9ee68dceb87333d355 Mon Sep 17 00:00:00 2001 From: wwakabobik Date: Fri, 30 Aug 2024 15:33:13 +0200 Subject: [PATCH] Linter fixes --- tests/conftest.py | 9 ++++----- ...lotly_reporter_draw_automation_state_report.py | 15 ++++++++------- ...ines_plotly_reporter_draw_test_case_by_area.py | 10 +++++++--- ...reporter_utils_csv_parser_load_history_data.py | 4 ++-- ...reporter_utils_csv_parser_save_history_data.py | 8 ++++---- tests/utils/test_reporter_utils_logger_config.py | 4 ++-- 6 files changed, 27 insertions(+), 23 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index c8bdd4b..11f0869 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,7 +3,6 @@ from os import path, remove from random import randint -from typing import Generator import pytest from faker import Faker @@ -19,12 +18,12 @@ @pytest.fixture -def create_test_file() -> Generator: +def create_test_file(): """ Fixture to create random test file :return: filename - :rtype: Generator + :rtype: str (generator) """ test_file = f"not_existing_{fake.file_name()}" with open(test_file, "w", encoding="utf-8") as file: @@ -81,12 +80,12 @@ def case_stat_random(case_stat, random_stat): # pylint: disable=redefined-outer @pytest.fixture -def csv_file() -> Generator: +def csv_file(): """ Fixture to create random test file :return: filename - :rtype: Generator + :rtype: str (generator) """ test_file = f"not_existing_{fake.file_name(extension='csv')}" with open(test_file, "w", encoding="utf-8") as file: diff --git a/tests/engines/test_engines_plotly_reporter_draw_automation_state_report.py b/tests/engines/test_engines_plotly_reporter_draw_automation_state_report.py index 1c8699c..23295b0 100644 --- a/tests/engines/test_engines_plotly_reporter_draw_automation_state_report.py +++ b/tests/engines/test_engines_plotly_reporter_draw_automation_state_report.py @@ -55,11 +55,10 @@ def test_draw_automation_state_report_no_filename(random_plotly_reporter): random_plotly_reporter.draw_automation_state_report(reports=[fake.pydict()]) -def test_draw_automation_state_report_creates_file(caplog, case_stat, case_stat_random, random_plotly_reporter): +def test_draw_automation_state_report_creates_file(case_stat, case_stat_random, random_plotly_reporter): """ Init PlotlyReporter and call draw_automation_state_report with valid parameters should create file - :param caplog: caplog fixture :param case_stat: fixture returns empty CaseStat object :param case_stat_random: fixture returns filled with random data CaseStat object :param random_plotly_reporter: fixture returns PlotlyReporter @@ -75,11 +74,12 @@ def test_draw_automation_state_report_creates_file(caplog, case_stat, case_stat_ remove(filename) -def test_draw_automation_state_report_creates_correct_image(caplog, random_expected_image, compare_image): +def test_draw_automation_state_report_creates_correct_image( + random_expected_image, compare_image # pylint: disable=W0621 +): """ Init PlotlyReporter and call draw_automation_state_report with valid parameters should create correct image - :param caplog: caplog fixture :param random_expected_image: fixture, returns any of possible expected cases :param compare_image: fixture, returns function to compare images """ @@ -94,11 +94,12 @@ def test_draw_automation_state_report_creates_correct_image(caplog, random_expec remove(filename) -def test_draw_automation_state_report_changes_state_markers(caplog, random_expected_image, compare_image, random_rgb): +def test_draw_automation_state_report_changes_state_markers( + random_expected_image, compare_image, random_rgb # pylint: disable=W0621 +): """ - Init PlotlyReporter and call draw_automation_state_report with valid parameters and state_markers should create correct image + Init PlotlyReporter and call draw_automation_state_report with state_markers should create different image - :param caplog: caplog fixture :param random_expected_image: fixture, returns any of possible expected cases :param compare_image: fixture, returns function to compare images :param random_rgb: fixture, returns random rgb in string format diff --git a/tests/engines/test_engines_plotly_reporter_draw_test_case_by_area.py b/tests/engines/test_engines_plotly_reporter_draw_test_case_by_area.py index a051531..0fdb889 100644 --- a/tests/engines/test_engines_plotly_reporter_draw_test_case_by_area.py +++ b/tests/engines/test_engines_plotly_reporter_draw_test_case_by_area.py @@ -83,7 +83,7 @@ def test_draw_test_case_by_area_creates_file(case_stat, case_stat_random, random remove(filename) -def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image): +def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image): # pylint: disable=W0621 """ Init PlotlyReporter and call draw_test_case_by_area with valid parameters should create correct image @@ -101,7 +101,9 @@ def test_draw_test_case_by_area_creates_correct_image(random_expected_image, com remove(filename) -def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare_image, random_rgb): +def test_draw_test_case_by_area_changes_ar_colors( + random_expected_image, compare_image, random_rgb # pylint: disable=W0621 +): """ Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image @@ -123,7 +125,9 @@ def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare remove(filename) -def test_draw_test_case_by_area_changes_lines(random_expected_image, compare_image, random_rgb): +def test_draw_test_case_by_area_changes_lines( + random_expected_image, compare_image, random_rgb # pylint: disable=W0621 +): """ Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors should create correct image diff --git a/tests/utils/test_reporter_utils_csv_parser_load_history_data.py b/tests/utils/test_reporter_utils_csv_parser_load_history_data.py index a24002e..d59593e 100644 --- a/tests/utils/test_reporter_utils_csv_parser_load_history_data.py +++ b/tests/utils/test_reporter_utils_csv_parser_load_history_data.py @@ -20,8 +20,8 @@ def test_load_history_data(csv_file, random_stat): year = fake.year() month = fake.month() day_of_month = fake.day_of_month() - with open(csv_file, "w", encoding="utf-8") as f: - f.write(f"{year},{month},{day_of_month},{total},{automated},{not_automated},{not_applicable}\n") + with open(csv_file, "w", encoding="utf-8") as writable_file: + writable_file.write(f"{year},{month},{day_of_month},{total},{automated},{not_automated},{not_applicable}\n") data = parser.load_history_data() diff --git a/tests/utils/test_reporter_utils_csv_parser_save_history_data.py b/tests/utils/test_reporter_utils_csv_parser_save_history_data.py index 3b80564..4c8ac5e 100644 --- a/tests/utils/test_reporter_utils_csv_parser_save_history_data.py +++ b/tests/utils/test_reporter_utils_csv_parser_save_history_data.py @@ -22,8 +22,8 @@ def test_save_history_data(csv_file, random_stat, case_stat): parser.save_history_data(report=case_stat) - with open(csv_file, "r", encoding="utf-8") as f: - data = f.read() + with open(csv_file, "r", encoding="utf-8") as readable_file: + data = readable_file.read() assert data == ( f"{datetime.today().strftime('%Y')}," f"{datetime.today().strftime('%m')}," @@ -55,6 +55,6 @@ def test_save_history_data_already_stored(csv_file, case_stat_random): parser.save_history_data(report=case_stat_random) parser.save_history_data(report=case_stat_random) - with open(csv_file, "r") as f: - data = f.read() + with open(csv_file, "r", encoding="utf-8") as readable_file: + data = readable_file.read() assert data.count("\n") == 1 diff --git a/tests/utils/test_reporter_utils_logger_config.py b/tests/utils/test_reporter_utils_logger_config.py index 7dd6584..59caa19 100644 --- a/tests/utils/test_reporter_utils_logger_config.py +++ b/tests/utils/test_reporter_utils_logger_config.py @@ -30,8 +30,8 @@ def test_setup_logger_default_level(caplog): message = str(fake.random_letters(randint(1, 10))) * randint(1, 10) logger.debug(message) - with open(log_file, "r", encoding="utf-8") as f: - assert message in f.read() + with open(log_file, "r", encoding="utf-8") as readable_file: + assert message in readable_file.read() assert message in caplog.text finally: if path.exists(log_file):