mirror of
https://github.com/rendercv/rendercv.git
synced 2026-04-17 13:33:53 -04:00
Property-based tests verify invariants across random inputs, catching edge cases that hand-picked parametrized tests miss. Covers 6 modules: - string_processor: keyword bolding, placeholder substitution, URL cleaning - markdown_parser: Typst escaping robustness, formatting preservation - date: date parsing, placeholder generation, time span arithmetic - override_dictionary: immutability, path traversal, error conditions - path_resolver: name variant generation, OUTPUT_FOLDER resolution - Pydantic validators: Typst dimensions, social network usernames Bugs surfaced during development: - clean_url only strips one trailing slash (double slash passes through) - get_date_object crashes on year < 10 (single digit isoformat) - YEAR_IN_TWO_DIGITS is 1 char for years < 10
32 lines
927 B
Python
32 lines
927 B
Python
import pathlib
|
|
|
|
import pytest
|
|
from hypothesis import settings as hypothesis_settings
|
|
|
|
hypothesis_settings.register_profile("ci", max_examples=200, deadline=None)
|
|
hypothesis_settings.register_profile("dev", max_examples=30, deadline=None)
|
|
hypothesis_settings.register_profile("default", max_examples=100, deadline=None)
|
|
|
|
|
|
def pytest_addoption(parser: pytest.Parser) -> None:
|
|
parser.addoption(
|
|
"--update-testdata",
|
|
action="store_true",
|
|
default=False,
|
|
help="Update the updatable testdata",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def update_testdata(request: pytest.FixtureRequest) -> bool:
|
|
return request.config.getoption("--update-testdata")
|
|
|
|
|
|
@pytest.fixture
|
|
def testdata_dir(request: pytest.FixtureRequest) -> pathlib.Path:
|
|
module_path = pathlib.Path(request.node.module.__file__)
|
|
module_name = module_path.stem
|
|
base_dir = module_path.parent
|
|
|
|
return base_dir / "testdata" / module_name
|