From 8140fa654b604e6a929bdaf6ab892f289f2396dd Mon Sep 17 00:00:00 2001 From: Adam Wilson Date: Fri, 30 May 2025 12:26:55 -0600 Subject: [PATCH] init tests --- requirements.txt | 3 + tests/pytest.ini | 151 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 tests/pytest.ini diff --git a/requirements.txt b/requirements.txt index 6d7adc217..9a65c3fb5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -54,6 +54,7 @@ huggingface-hub==0.32.0 humanfriendly==10.0 idna==3.10 importlib-metadata==6.11.0 +iniconfig==2.1.0 inquirerpy==0.3.4 Jinja2==3.1.6 jiter==0.10.0 @@ -116,6 +117,7 @@ pandas==2.2.3 pathspec==0.12.1 pfzy==0.3.4 pillow==10.4.0 +pluggy==1.6.0 ply==3.11 prompt_toolkit==3.0.51 propcache==0.3.1 @@ -133,6 +135,7 @@ pydantic_core==2.33.2 Pygments==2.19.1 pyparsing==3.2.3 pyperclip==1.9.0 +pytest==8.3.5 python-dateutil==2.9.0.post0 python-dotenv==1.1.0 python-magic==0.4.27 diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 000000000..db67f9949 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,151 @@ +# pytest.ini - Comprehensive configuration for unit, integration, and e2e tests + +[pytest] + +# Minimum pytest version required +minversion = 6.0 + +# Test discovery patterns +python_files = test_*.py *_test.py +python_classes = Test* *Tests +python_functions = test_* + +# Test paths - pytest will look for tests in these directories +testpaths = + tests + tests/unit + tests/integration + tests/e2e + +# Additional command line options (applied to every pytest run) +addopts = + # Verbose output with more details + -v + # Show extra test summary info for all except passed tests + -ra + # Show local variables in tracebacks + --tb=short + # Enable strict mode for markers and configuration + --strict-markers + --strict-config + # Capture stdout/stderr per-test + --capture=no + # Show slowest 10 tests + --durations=10 + # Enable coverage reporting (requires pytest-cov) + --cov=src + --cov-report=term-missing + --cov-report=html:htmlcov + --cov-report=xml + # Fail if coverage is below threshold + --cov-fail-under=80 + +# Test markers - define custom markers to avoid warnings +markers = + slow: marks tests as slow (deselect with '-m "not slow"') + fast: marks tests as fast + unit: marks tests as unit tests + integration: marks tests as integration tests + e2e: marks tests as end-to-end tests + smoke: marks tests as smoke tests + regression: marks tests as regression tests + api: marks tests as API tests + ui: marks tests as UI tests + database: marks tests that require database + network: marks tests that require network access + external: marks tests that depend on external services + skip_ci: marks tests to skip in CI environment + windows_only: marks tests that only run on Windows + linux_only: marks tests that only run on Linux + mac_only: marks tests that only run on macOS + +# Ignore certain directories and files during test collection +ignore = + setup.py + conftest.py + migrations/ + .tox/ + build/ + dist/ + *.egg + .git/ + __pycache__/ + .pytest_cache/ + node_modules/ + .venv/ + venv/ + +# Configure logging +log_cli = true +log_cli_level = INFO +log_cli_format = %(asctime)s [%(levelname)8s] %(name)s: %(message)s +log_cli_date_format = %Y-%m-%d %H:%M:%S + +log_file = tests/logs/pytest.log +log_file_level = DEBUG +log_file_format = %(asctime)s [%(levelname)8s] %(filename)s:%(lineno)d: %(message)s +log_file_date_format = %Y-%m-%d %H:%M:%S + +# Configure warnings +filterwarnings = + error + ignore::UserWarning + ignore::DeprecationWarning + ignore::PendingDeprecationWarning + ignore:.*U.*mode is deprecated:DeprecationWarning + +# Test timeout (requires pytest-timeout) +timeout = 300 +timeout_method = thread + +# Parallel execution configuration (requires pytest-xdist) +# Uncomment to enable parallel test execution +# addopts = -n auto + +# Django specific settings (if using pytest-django) +# DJANGO_SETTINGS_MODULE = myproject.settings.test +# django_find_project = false + +# Database settings for tests (if applicable) +# database_cleanup = truncate + +# Asyncio configuration (if using pytest-asyncio) +asyncio_mode = auto + +# Configure test collection +collect_ignore = [ + "setup.py", + "conftest.py" +] + +# Minimum line length for test output +console_output_style = progress + +# Configure doctest options +doctest_optionflags = + NORMALIZE_WHITESPACE + IGNORE_EXCEPTION_DETAIL + ELLIPSIS + +# Configure test session data +cache_dir = .pytest_cache + +# Configure temporary directory for tests +tmp_path_retention_count = 3 +tmp_path_retention_policy = failed + +# Additional ini options for specific plugins can be added here +# For example, if using pytest-mock: +# mock_use_standalone_module = true + +# For pytest-html reports: +# addopts = --html=reports/report.html --self-contained-html + +# For pytest-bdd: +# bdd_features_base_dir = features/ + +# Environment variables can be set (requires pytest-env) +# env = +# ENVIRONMENT = test +# DEBUG = 1 +# DATABASE_URL = sqlite:///:memory: \ No newline at end of file