From 7528c44dcc4afffa6903f79c69ee4887cba8d893 Mon Sep 17 00:00:00 2001 From: Kai Chappell Date: Sun, 6 Apr 2025 14:03:06 +0000 Subject: [PATCH] pytest plugin: hooks and markers Register text_validation marker via pytest_configure hook. --- src/veritext/pytest_plugin/__init__.py | 22 ++++++++++++++++++++++ src/veritext/pytest_plugin/plugin.py | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 src/veritext/pytest_plugin/__init__.py create mode 100644 src/veritext/pytest_plugin/plugin.py diff --git a/src/veritext/pytest_plugin/__init__.py b/src/veritext/pytest_plugin/__init__.py new file mode 100644 index 0000000..5a6db4a --- /dev/null +++ b/src/veritext/pytest_plugin/__init__.py @@ -0,0 +1,22 @@ +"""Pytest plugin for text validation. + +This plugin provides native pytest integration for Veritext, enabling +text validation assertions in test suites. + +Example: + >>> from veritext.pytest_plugin import validate_text + >>> + >>> def test_summary_quality(): + ... text = "The quick brown fox jumps over the lazy dog." + ... validate_text( + ... text, + ... min_length=10, + ... max_length=100, + ... max_reading_grade=8.0, + ... ) +""" + +from veritext.pytest_plugin.assertions import validate_text +from veritext.pytest_plugin.plugin import pytest_configure + +__all__ = ["pytest_configure", "validate_text"] diff --git a/src/veritext/pytest_plugin/plugin.py b/src/veritext/pytest_plugin/plugin.py new file mode 100644 index 0000000..9d4234c --- /dev/null +++ b/src/veritext/pytest_plugin/plugin.py @@ -0,0 +1,18 @@ +"""Pytest hooks for Veritext plugin.""" + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + import pytest + + +def pytest_configure(config: "pytest.Config") -> None: + """Register Veritext markers. + + Args: + config: Pytest configuration object. + """ + config.addinivalue_line( + "markers", + "text_validation: mark test as a text validation test", + )