diff --git a/pytest_param_files/__init__.py b/pytest_param_files/__init__.py index 5f83596..2e50abf 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 # noqa: F401 -__version__ = "0.3.3" +__version__ = "0.3.4" diff --git a/pytest_param_files/main.py b/pytest_param_files/main.py index 12b64cc..694faf2 100644 --- a/pytest_param_files/main.py +++ b/pytest_param_files/main.py @@ -48,7 +48,7 @@ class ParamTestData: """The line number in the source file.""" title: str """The title of the test.""" - description: str + description: Optional[str] """The description of the test.""" content: Any """The input content of the test.""" @@ -175,7 +175,7 @@ def read(self) -> Iterator[ParamTestData]: description = match.group("description") else: title = first_line - description = "" + description = None tests.append([i, title, description]) section = 1 elif section == 1: @@ -230,7 +230,10 @@ def regen_file( actual = "\n".join(line.rstrip() for line in actual.splitlines()).rstrip() text = [] for index, current in enumerate(self.read()): - text.append(f"[{current.title}] {current.description}\n") + if current.description is not None: + text.append(f"[{current.title}] {current.description}\n") + else: + text.append(f"{current.title}\n") text.append(".\n") text.append(current.content) text.append(".\n")