Skip to content

Commit e392108

Browse files
authored
Refactor test_simple_header_cli with parameterization
1 parent cd5402a commit e392108

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

tests/cli_test.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import subprocess
33
from pathlib import Path
44

5+
import pytest
56

67
DIR = Path(__file__).resolve().parent
78

@@ -53,24 +54,17 @@
5354
"""
5455

5556

56-
def test_simple_header_cli(tmp_path: Path) -> None:
57+
@pytest.mark.parametrize(
58+
"name",
59+
["sample_header.h", "sample header with spaces.h"],
60+
ids=["no_spaces", "spaces"],
61+
)
62+
def test_simple_header_cli(tmp_path: Path, name: str) -> None:
5763
# Run pybind11-mkdoc and put the output in a temp file
5864
tf = tmp_path / "tmp.h"
59-
header = DIR / "sample_header_docs" / "sample_header.h"
65+
header = DIR / "sample_header_docs" / name
6066
subprocess.run([sys.executable, "-m", "pybind11_mkdoc", "-o", tf, header], check=True)
6167

62-
# Ensure the header file matches
63-
res = tf.read_text(encoding="utf-8")
64-
65-
assert res == expected
66-
67-
def test_simple_header_with_spaces_cli(tmp_path: Path) -> None:
68-
# Run pybind11-mkdoc and put the output in a temp file
69-
tf = tmp_path / "tmp.h"
70-
header = DIR / "sample_header_docs" / "sample header with spaces.h"
71-
subprocess.run([sys.executable, "-m", "pybind11_mkdoc", "-o", tf, header], check=True)
72-
73-
7468
# Ensure the header file matches
7569
res = tf.read_text(encoding="utf-8")
7670

0 commit comments

Comments
 (0)