summaryrefslogtreecommitdiffstats
path: root/tests/units/reporter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/reporter')
-rw-r--r--tests/units/reporter/conftest.py2
-rw-r--r--tests/units/reporter/test__init__.py2
-rw-r--r--tests/units/reporter/test_csv.py9
-rw-r--r--tests/units/reporter/test_md_reporter.py4
4 files changed, 8 insertions, 9 deletions
diff --git a/tests/units/reporter/conftest.py b/tests/units/reporter/conftest.py
index ae7d3df..d0eed36 100644
--- a/tests/units/reporter/conftest.py
+++ b/tests/units/reporter/conftest.py
@@ -5,4 +5,4 @@
from tests.units.result_manager.conftest import list_result_factory, result_manager, result_manager_factory, test_result_factory
-__all__ = ["result_manager", "result_manager_factory", "list_result_factory", "test_result_factory"]
+__all__ = ["list_result_factory", "result_manager", "result_manager_factory", "test_result_factory"]
diff --git a/tests/units/reporter/test__init__.py b/tests/units/reporter/test__init__.py
index af26b54..71cccdd 100644
--- a/tests/units/reporter/test__init__.py
+++ b/tests/units/reporter/test__init__.py
@@ -188,5 +188,5 @@ class TestReportJinja:
def test_fail__init__file_not_found(self) -> None:
"""Test __init__ failure if file is not found."""
- with pytest.raises(FileNotFoundError, match="template file is not found: /gnu/terry/pratchett"):
+ with pytest.raises(FileNotFoundError, match=r"template file is not found: [/|\\]gnu[/|\\]terry[/|\\]pratchett"):
ReportJinja(Path("/gnu/terry/pratchett"))
diff --git a/tests/units/reporter/test_csv.py b/tests/units/reporter/test_csv.py
index 1d59dae..d88098e 100644
--- a/tests/units/reporter/test_csv.py
+++ b/tests/units/reporter/test_csv.py
@@ -8,6 +8,7 @@
import csv
import pathlib
from typing import Any, Callable
+from unittest.mock import patch
import pytest
@@ -49,8 +50,8 @@ class TestReportCsv:
# Generate the CSV report
ReportCsv.generate(result_manager, csv_filename)
- # Read the generated CSV file
- with pathlib.Path.open(csv_filename, encoding="utf-8") as csvfile:
+ # Read the generated CSV file - newline required on Windows..
+ with pathlib.Path.open(csv_filename, encoding="utf-8", newline="") as csvfile:
reader = csv.reader(csvfile, delimiter=",")
rows = list(reader)
@@ -82,11 +83,9 @@ class TestReportCsv:
max_test_entries = 10
result_manager = result_manager_factory(max_test_entries)
- # Create a temporary CSV file path and make tmp_path read_only
- tmp_path.chmod(0o400)
csv_filename = tmp_path / "read_only.csv"
- with pytest.raises(OSError, match="Permission denied"):
+ with patch("pathlib.Path.open", side_effect=OSError("Any OSError")), pytest.raises(OSError, match="Any OSError"):
# Generate the CSV report
ReportCsv.generate(result_manager, csv_filename)
diff --git a/tests/units/reporter/test_md_reporter.py b/tests/units/reporter/test_md_reporter.py
index a607733..c0676bb 100644
--- a/tests/units/reporter/test_md_reporter.py
+++ b/tests/units/reporter/test_md_reporter.py
@@ -5,7 +5,7 @@
from __future__ import annotations
-from io import StringIO
+from io import BytesIO, TextIOWrapper
from pathlib import Path
import pytest
@@ -46,7 +46,7 @@ def test_md_report_base() -> None:
results = ResultManager()
- with StringIO() as mock_file:
+ with TextIOWrapper(BytesIO(b"1 2 3")) as mock_file:
report = FakeMDReportBase(mock_file, results)
assert report.generate_heading_name() == "Fake MD Report Base"