diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index a9997a3..c9516a9 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -35,6 +35,7 @@ jobs: pip install types-requests pip install pytest pip install faker + pip install pillow - name: Add 'testrail_api_reporter' to PYTHONPATH run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/testrail_api_reporter:." >> $GITHUB_ENV - name: Analysing the code with pylint diff --git a/.github/workflows/master_linters.yml b/.github/workflows/master_linters.yml index 1db0e39..b749c68 100644 --- a/.github/workflows/master_linters.yml +++ b/.github/workflows/master_linters.yml @@ -31,6 +31,7 @@ jobs: pip install types-requests pip install pytest pip install faker + pip install pillow - name: Add 'testrail_api_reporter' to PYTHONPATH run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/testrail_api_reporter:." >> $GITHUB_ENV - name: Analysing the code with pylint diff --git a/testrail_api_reporter/engines/plotly_reporter.py b/testrail_api_reporter/engines/plotly_reporter.py index c1bdd30..ec0ba19 100644 --- a/testrail_api_reporter/engines/plotly_reporter.py +++ b/testrail_api_reporter/engines/plotly_reporter.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- """ Confluence sender module """ +from typing import Optional + import plotly from ..utils.csv_parser import CSVParser @@ -231,7 +233,7 @@ def draw_test_case_by_area(self, filename=None, cases=None, ar_colors=None, line def draw_history_state_chart( self, - chart_name: str | None = None, + chart_name: Optional[str] = None, history_data=None, filename=None, trace1_decor=None, diff --git a/testrail_api_reporter/utils/reporter_utils.py b/testrail_api_reporter/utils/reporter_utils.py index 70783ec..18c3c23 100644 --- a/testrail_api_reporter/utils/reporter_utils.py +++ b/testrail_api_reporter/utils/reporter_utils.py @@ -2,12 +2,12 @@ """ This module contains service functions for reporter """ from logging import Logger from os import popen -from typing import Optional, Any +from typing import Optional, Any, Union import requests -def format_error(error: list | str | Exception) -> str: +def format_error(error: Union[list, str, Exception]) -> str: """ Service function for parse errors to human-readable format @@ -58,7 +58,7 @@ def delete_file(filename: str, debug: bool = True, logger: Optional[Logger] = No logger.debug(f"Removed {filename}") -def zip_file(filename: str, suffix: str | None = None, debug: bool = True, logger: Optional[Logger] = None) -> str: +def zip_file(filename: str, suffix: Optional[str] = None, debug: bool = True, logger: Optional[Logger] = None) -> str: """ Service function to ZIP file @@ -79,8 +79,8 @@ def zip_file(filename: str, suffix: str | None = None, debug: bool = True, logge def check_captions_and_files( - captions: list | None | Any, files: list, debug: bool = True, logger: Optional[Logger] = None -) -> list | None: + captions: Union[list, None, Any], files: list, debug: bool = True, logger: Optional[Logger] = None +) -> Optional[list]: """ Service function to check captions and file lists @@ -114,7 +114,7 @@ def init_get_cases_process() -> tuple[list, bool, None, None, int]: :return: cases_list, first_run, criteria, response, retry """ - cases_list = [] + cases_list: list = [] first_run = True criteria = None response = None diff --git a/tests/conftest.py b/tests/conftest.py index 3174c55..c8bdd4b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,6 +3,7 @@ from os import path, remove from random import randint +from typing import Generator import pytest from faker import Faker @@ -14,17 +15,16 @@ from testrail_api_reporter.utils.case_stat import CaseStat # pylint: disable=import-error,no-name-in-module - fake = Faker() @pytest.fixture -def create_test_file() -> str: +def create_test_file() -> Generator: """ Fixture to create random test file :return: filename - :rtype: str + :rtype: Generator """ test_file = f"not_existing_{fake.file_name()}" with open(test_file, "w", encoding="utf-8") as file: @@ -65,7 +65,7 @@ def case_stat() -> CaseStat: @pytest.fixture -def case_stat_random(case_stat, random_stat): +def case_stat_random(case_stat, random_stat): # pylint: disable=redefined-outer-name """ Fixture to return object of CaseStat @@ -81,12 +81,12 @@ def case_stat_random(case_stat, random_stat): @pytest.fixture -def csv_file() -> str: +def csv_file() -> Generator: """ Fixture to create random test file :return: filename - :rtype: str + :rtype: Generator """ test_file = f"not_existing_{fake.file_name(extension='csv')}" with open(test_file, "w", encoding="utf-8") as file: @@ -155,7 +155,7 @@ def random_type_platforms() -> list[dict]: @pytest.fixture -def random_plotly_reporter(random_type_platforms) -> PlotlyReporter: +def random_plotly_reporter(random_type_platforms) -> PlotlyReporter: # pylint: disable=redefined-outer-name """ Returns PlotlyReporter object with random type platforms @@ -167,7 +167,8 @@ def random_plotly_reporter(random_type_platforms) -> PlotlyReporter: @pytest.fixture() def random_rgb(): - """Returns fixture to get rgb in string format """ + """Returns fixture to get rgb in string format""" + def get_rgb() -> str: """ Returns rgb in string format 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 9d0ef05..1c8699c 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 @@ -29,16 +29,14 @@ def random_expected_image(case_stat): case_stat.not_automated = 27205 case_stat.not_applicable = 10092 return {"filename": f"{getcwd()}/tests/assets/expected_automation_state.png", "data": [case_stat]} - else: - case_stat.set_name("Automation State") - return {"filename": f"{getcwd()}/tests/assets/expected_automation_state_empty.png", "data": [case_stat]} + case_stat.set_name("Automation State") + return {"filename": f"{getcwd()}/tests/assets/expected_automation_state_empty.png", "data": [case_stat]} -def test_draw_automation_state_report_no_reports(caplog, random_plotly_reporter): +def test_draw_automation_state_report_no_reports(random_plotly_reporter): """ Init PlotlyReporter and call draw_automation_state_report without reports should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No TestRail reports are provided, report aborted!"): @@ -47,11 +45,10 @@ def test_draw_automation_state_report_no_reports(caplog, random_plotly_reporter) ) -def test_draw_automation_state_report_no_filename(caplog, random_plotly_reporter): +def test_draw_automation_state_report_no_filename(random_plotly_reporter): """ Init PlotlyReporter and call draw_automation_state_report without filename should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No output filename is provided, report aborted!"): diff --git a/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py b/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py index 95749a1..25b3c88 100644 --- a/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py +++ b/tests/engines/test_engines_plotly_reporter_draw_history_state_chart.py @@ -8,22 +8,20 @@ fake = Faker() -def test_draw_history_state_chart_no_chart_name(caplog, random_plotly_reporter): +def test_draw_history_state_chart_no_chart_name(random_plotly_reporter): """ Init PlotlyReporter and call draw_history_state_chart without chart_name should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No chart name is provided, report aborted!"): random_plotly_reporter.draw_history_state_chart() # type: ignore -def test_draw_history_state_chart_no_filename(caplog, random_plotly_reporter): +def test_draw_history_state_chart_no_filename(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority without filename should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ fake_name = fake.name() @@ -32,87 +30,79 @@ def test_draw_history_state_chart_no_filename(caplog, random_plotly_reporter): random_plotly_reporter.draw_history_state_chart(chart_name=fake_name) -def test_draw_history_state_chart_creates_file(caplog, random_plotly_reporter): +def test_draw_history_state_chart_creates_file(random_plotly_reporter): """ Init PlotlyReporter and call draw_history_state_chart with valid parameters should create file - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ raise NotImplementedError -def test_draw_history_state_chart_creates_correct_image(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_creates_correct_image(random_plotly_reporter, compare_image): """ Init PlotlyReporter and call draw_history_state_chart with valid parameters should create valid image - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_default_history_data(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_default_history_data(random_plotly_reporter, compare_image): """ Init PlotlyReporter and call draw_history_state_chart with default history data - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_custom_history_data(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_custom_history_data(random_plotly_reporter, compare_image): """ Init PlotlyReporter and call draw_history_state_chart with custom history data - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_trace1_decor(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_trace1_decor(random_plotly_reporter, compare_image): """ Init PlotlyReporter and call draw_history_state_chart with custom trace1 decor - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_trace2_decor(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_trace2_decor(random_plotly_reporter, compare_image): """ Init PlotlyReporter and call draw_history_state_chart with custom trace2 decor - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_reverse_traces(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_reverse_traces(random_plotly_reporter, compare_image): """ - Init PlotlyReporter and call draw_history_state_chart with reverced traces + Init PlotlyReporter and call draw_history_state_chart with reversed traces - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ raise NotImplementedError -def test_draw_history_state_chart_filename_pattern(caplog, random_plotly_reporter, compare_image): +def test_draw_history_state_chart_filename_pattern(random_plotly_reporter, compare_image): """ - Init PlotlyReporter and call draw_history_state_chart with reverced traces + Init PlotlyReporter and call draw_history_state_chart with filename pattern - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter :param compare_image: fixture, returns function to compare images """ 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 1e0ee03..a051531 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 @@ -41,11 +41,10 @@ def random_expected_image(case_stat): } -def test_draw_test_case_by_area_no_cases(caplog, random_plotly_reporter): +def test_draw_test_case_by_area_no_cases(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_area without cases should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No TestRail cases are provided, report aborted!"): @@ -54,22 +53,20 @@ def test_draw_test_case_by_area_no_cases(caplog, random_plotly_reporter): ) -def test_draw_test_case_by_area_no_filename(caplog, random_plotly_reporter): +def test_draw_test_case_by_area_no_filename(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_area without filename should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No output filename is provided, report aborted!"): random_plotly_reporter.draw_test_case_by_area(cases=[fake.pydict()]) -def test_draw_test_case_by_area_creates_file(caplog, case_stat, case_stat_random, random_plotly_reporter): +def test_draw_test_case_by_area_creates_file(case_stat, case_stat_random, random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_area 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 @@ -86,11 +83,10 @@ def test_draw_test_case_by_area_creates_file(caplog, case_stat, case_stat_random remove(filename) -def test_draw_test_case_by_area_creates_correct_image(caplog, random_expected_image, compare_image): +def test_draw_test_case_by_area_creates_correct_image(random_expected_image, compare_image): """ Init PlotlyReporter and call draw_test_case_by_area 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 """ @@ -105,11 +101,10 @@ def test_draw_test_case_by_area_creates_correct_image(caplog, random_expected_im remove(filename) -def test_draw_test_case_by_area_changes_ar_colors(caplog, random_expected_image, compare_image, random_rgb): +def test_draw_test_case_by_area_changes_ar_colors(random_expected_image, compare_image, random_rgb): """ Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors 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 :param random_rgb: fixture, returns random rgb in string format @@ -128,11 +123,10 @@ def test_draw_test_case_by_area_changes_ar_colors(caplog, random_expected_image, remove(filename) -def test_draw_test_case_by_area_changes_lines(caplog, random_expected_image, compare_image, random_rgb): +def test_draw_test_case_by_area_changes_lines(random_expected_image, compare_image, random_rgb): """ Init PlotlyReporter and call draw_test_case_by_area with valid parameters and ar_colors 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 :param random_rgb: fixture, returns random rgb in string format diff --git a/tests/engines/test_engines_plotly_reporter_draw_test_case_by_priority.py b/tests/engines/test_engines_plotly_reporter_draw_test_case_by_priority.py index 98b8076..303b994 100644 --- a/tests/engines/test_engines_plotly_reporter_draw_test_case_by_priority.py +++ b/tests/engines/test_engines_plotly_reporter_draw_test_case_by_priority.py @@ -11,11 +11,10 @@ fake = Faker() -def test_draw_test_case_by_priority_no_cases(caplog, random_plotly_reporter): +def test_draw_test_case_by_priority_no_cases(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority without cases should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No TestRail values are provided, report aborted!"): @@ -24,22 +23,20 @@ def test_draw_test_case_by_priority_no_cases(caplog, random_plotly_reporter): ) -def test_draw_test_case_by_priority_no_filename(caplog, random_plotly_reporter): +def test_draw_test_case_by_priority_no_filename(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority without filename should raise ValueError - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ with pytest.raises(ValueError, match="No output filename is provided, report aborted!"): random_plotly_reporter.draw_test_case_by_priority(values=[fake.pydict()]) -def test_draw_test_case_by_priority_creates_file(caplog, random_plotly_reporter): +def test_draw_test_case_by_priority_creates_file(random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority with valid parameters should create file - :param caplog: caplog fixture :param random_plotly_reporter: fixture returns PlotlyReporter """ filename = fake.file_name(extension=choice(("png", "jpg", "jpeg", "webp"))) @@ -54,11 +51,10 @@ def test_draw_test_case_by_priority_creates_file(caplog, random_plotly_reporter) remove(filename) -def test_draw_test_case_by_priority_creates_correct_image(caplog, compare_image, random_plotly_reporter): +def test_draw_test_case_by_priority_creates_correct_image(compare_image, random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority with valid parameters should create correct image - :param caplog: caplog fixture :param compare_image: fixture, returns function to compare images :param random_plotly_reporter: fixture returns PlotlyReporter """ @@ -71,11 +67,10 @@ def test_draw_test_case_by_priority_creates_correct_image(caplog, compare_image, remove(filename) -def test_draw_test_case_by_priority_creates_change_lines(caplog, compare_image, random_plotly_reporter, random_rgb): +def test_draw_test_case_by_priority_creates_change_lines(compare_image, random_plotly_reporter, random_rgb): """ Init PlotlyReporter and call draw_test_case_by_priority with custom lines - :param caplog: caplog fixture :param compare_image: fixture, returns function to compare images :param random_plotly_reporter: fixture returns PlotlyReporter :param random_rgb: fixture, returns random rgb in string format @@ -90,11 +85,10 @@ def test_draw_test_case_by_priority_creates_change_lines(caplog, compare_image, remove(filename) -def test_draw_test_case_by_priority_creates_change_labels(caplog, compare_image, random_plotly_reporter): +def test_draw_test_case_by_priority_creates_change_labels(compare_image, random_plotly_reporter): """ Init PlotlyReporter and call draw_test_case_by_priority with custom labels - :param caplog: caplog fixture :param compare_image: fixture, returns function to compare images :param random_plotly_reporter: fixture returns PlotlyReporter """ @@ -108,11 +102,10 @@ def test_draw_test_case_by_priority_creates_change_labels(caplog, compare_image, remove(filename) -def test_draw_test_case_by_priority_creates_change_colors(caplog, compare_image, random_plotly_reporter, random_rgb): +def test_draw_test_case_by_priority_creates_change_colors(compare_image, random_plotly_reporter, random_rgb): """ Init PlotlyReporter and call draw_test_case_by_priority with custom labels - :param caplog: caplog fixture :param compare_image: fixture, returns function to compare images :param random_plotly_reporter: fixture returns PlotlyReporter """ diff --git a/tests/engines/test_engines_plotly_reporter_init.py b/tests/engines/test_engines_plotly_reporter_init.py index 22c90d4..a4c93ec 100644 --- a/tests/engines/test_engines_plotly_reporter_init.py +++ b/tests/engines/test_engines_plotly_reporter_init.py @@ -19,7 +19,7 @@ fake = Faker() -def test_plotly_reporter_init_default_params(caplog): +def test_plotly_reporter_init_default_params(): """Init PlotlyReporter with default parameters""" type_platforms = [{"name": fake.word(), "sections": [randint(1, 10000)]} for _ in range(randint(1, 5))] @@ -30,9 +30,14 @@ def test_plotly_reporter_init_default_params(caplog): assert path.exists("PlotlyReporter.log") attributes = vars(plotly_reporter) - assert attributes['_PlotlyReporter__pr_labels'] == ["Low", "Medium", "High", "Critical"] - assert attributes['_PlotlyReporter__pr_colors'] == ["rgb(173,216,230)", "rgb(34,139,34)", "rgb(255,255,51)", "rgb(255, 153, 153)"] - assert attributes['_PlotlyReporter__ar_colors'] == [ + assert attributes["_PlotlyReporter__pr_labels"] == ["Low", "Medium", "High", "Critical"] + assert attributes["_PlotlyReporter__pr_colors"] == [ + "rgb(173,216,230)", + "rgb(34,139,34)", + "rgb(255,255,51)", + "rgb(255, 153, 153)", + ] + assert attributes["_PlotlyReporter__ar_colors"] == [ "rgb(255, 153, 153)", "rgb(255,255,51)", "rgb(34,139,34)", @@ -40,11 +45,11 @@ def test_plotly_reporter_init_default_params(caplog): "rgb(65,105,225)", "rgb(192, 192, 192)", ] - assert attributes['_PlotlyReporter__lines'] == {"color": "rgb(0,0,51)", "width": 1.5} - assert attributes['_PlotlyReporter__type_platforms'] == type_platforms + assert attributes["_PlotlyReporter__lines"] == {"color": "rgb(0,0,51)", "width": 1.5} + assert attributes["_PlotlyReporter__type_platforms"] == type_platforms -def test_plotly_reporter_init_custom_params(caplog): +def test_plotly_reporter_init_custom_params(): """Init PlotlyReporter with custom parameters""" logger_file = fake.file_name(extension="log") logger_name = fake.name() @@ -72,17 +77,17 @@ def test_plotly_reporter_init_custom_params(caplog): assert path.exists(logger_file) attributes = vars(plotly_reporter) - assert attributes['_PlotlyReporter__pr_labels'] == pr_labels - assert attributes['_PlotlyReporter__pr_colors'] == pr_colors - assert attributes['_PlotlyReporter__ar_colors'] == ar_colors - assert attributes['_PlotlyReporter__lines'] == lines - assert attributes['_PlotlyReporter__type_platforms'] == type_platforms + assert attributes["_PlotlyReporter__pr_labels"] == pr_labels + assert attributes["_PlotlyReporter__pr_colors"] == pr_colors + assert attributes["_PlotlyReporter__ar_colors"] == ar_colors + assert attributes["_PlotlyReporter__lines"] == lines + assert attributes["_PlotlyReporter__type_platforms"] == type_platforms finally: if path.exists(logger_file): remove(logger_file) -def test_plotly_reporter_init_no_type_platforms(caplog): +def test_plotly_reporter_init_no_type_platforms(): """Init PlotlyReporter without type_platforms should raise ValueError""" with pytest.raises(ValueError, match="Platform types is not provided, Plotly Reporter cannot be initialized!"): PlotlyReporter() diff --git a/tests/utils/test_reporter_utils_case_stat.py b/tests/utils/test_reporter_utils_case_stat.py index 2c69efb..7cf3f1c 100644 --- a/tests/utils/test_reporter_utils_case_stat.py +++ b/tests/utils/test_reporter_utils_case_stat.py @@ -10,6 +10,7 @@ def test_case_stat_init(): + """Check default CaseStat init""" name = fake.word() case_stat = CaseStat(name) assert case_stat.name == name 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 5970e78..a24002e 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,7 +20,7 @@ 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") as f: + 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") data = parser.load_history_data() @@ -34,7 +34,7 @@ def test_load_history_data(csv_file, random_stat): ] -def test_load_history_data_no_filename(csv_file): +def test_load_history_data_no_filename(): """No filename is provided for load history""" parser = CSVParser() 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 ae41cda..3b80564 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,7 +22,7 @@ def test_save_history_data(csv_file, random_stat, case_stat): parser.save_history_data(report=case_stat) - with open(csv_file, "r") as f: + with open(csv_file, "r", encoding="utf-8") as f: data = f.read() assert data == ( f"{datetime.today().strftime('%Y')}," @@ -32,7 +32,7 @@ def test_save_history_data(csv_file, random_stat, case_stat): ) -def test_save_history_data_no_filename(csv_file): +def test_save_history_data_no_filename(): """No filename provided for save history data""" parser = CSVParser() @@ -48,7 +48,7 @@ def test_save_history_data_no_report(csv_file): parser.save_history_data() -def test_save_history_data_already_stored(csv_file, random_stat, case_stat_random): +def test_save_history_data_already_stored(csv_file, case_stat_random): """History already stored for such day for save history data""" parser = CSVParser(filename=csv_file) diff --git a/tests/utils/test_reporter_utils_logger_config.py b/tests/utils/test_reporter_utils_logger_config.py index 5428895..7dd6584 100644 --- a/tests/utils/test_reporter_utils_logger_config.py +++ b/tests/utils/test_reporter_utils_logger_config.py @@ -30,7 +30,7 @@ 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") as f: + with open(log_file, "r", encoding="utf-8") as f: assert message in f.read() assert message in caplog.text finally: @@ -38,7 +38,7 @@ def test_setup_logger_default_level(caplog): remove(log_file) -def test_setup_logger_custom_level(tmp_path): +def test_setup_logger_custom_level(): """Init logger with any other level""" log_file = fake.file_name(extension="log") try: