diff --git a/pytest_param_files/__init__.py b/pytest_param_files/__init__.py index 4fb6c86..56d4f05 100644 --- a/pytest_param_files/__init__.py +++ b/pytest_param_files/__init__.py @@ -1,4 +1,4 @@ """Create pytest parametrize decorators from external files.""" from .main import ParamTestData, with_parameters # noqa: F401 -__version__ = "0.2.1" +__version__ = "0.2.2" diff --git a/pytest_param_files/main.py b/pytest_param_files/main.py index 7beca89..44a786c 100644 --- a/pytest_param_files/main.py +++ b/pytest_param_files/main.py @@ -3,7 +3,7 @@ import difflib from pathlib import Path import re -from typing import Any, List, Tuple, Union +from typing import Any, List, Tuple, Union, cast import pytest @@ -140,17 +140,26 @@ def read(self) -> List[Tuple[int, str, str, str, str]]: return tests def assert_expected( - self, actual: str, data: ParamTestData, rstrip: bool = False + self, + actual: str, + data: ParamTestData, + rstrip: bool = False, + rstrip_lines: bool = False, ) -> None: """Assert the actual result of the test. :param rstrip: Whether to apply `str.rstrip` to actual and expected before comparing. + :param rstrip_lines: Whether to apply `str.rstrip` + to each line of actual and expected before comparing. """ __tracebackhide__ = True - expected = data.expected + expected = cast(str, data.expected) if rstrip: actual = actual.rstrip() expected = expected.rstrip() + if rstrip_lines: + actual = "\n".join(line.rstrip() for line in actual.splitlines()) + expected = "\n".join(line.rstrip() for line in expected.splitlines()) try: assert actual == expected