From a1f1bd5c6ab4fba2565370df789fa096e3b7263a Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 21:56:25 +0000 Subject: [PATCH] Add test files --- tests/conftest.py | 94 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..66eb168 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,94 @@ +"""Pytest configuration and fixtures.""" + +import pytest +from pathlib import Path +import tempfile +import os + + +@pytest.fixture +def sample_json_file(): + """Create a temporary JSON file for testing.""" + with tempfile.NamedTemporaryFile(mode="w", suffix=".json", delete=False) as f: + import json + json.dump({ + "name": "test-app", + "version": "1.0.0", + "debug": True, + "port": 8080, + "database": { + "host": "localhost", + "port": 5432 + }, + "features": ["auth", "api", "logging"] + }, f) + f.flush() + yield f.name + os.unlink(f.name) + + +@pytest.fixture +def sample_yaml_file(): + """Create a temporary YAML file for testing.""" + with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as f: + f.write(""" +name: test-app +version: 1.0.0 +debug: true +port: 8080 +database: + host: localhost + port: 5432 +features: + - auth + - api + - logging +""") + f.flush() + yield f.name + os.unlink(f.name) + + +@pytest.fixture +def sample_toml_file(): + """Create a temporary TOML file for testing.""" + with tempfile.NamedTemporaryFile(mode="w", suffix=".toml", delete=False) as f: + f.write(""" +name = "test-app" +version = "1.0.0" +debug = true +port = 8080 + +[database] +host = "localhost" +port = 5432 +""") + f.flush() + yield f.name + os.unlink(f.name) + + +@pytest.fixture +def sample_ini_file(): + """Create a temporary INI file for testing.""" + with tempfile.NamedTemporaryFile(mode="w", suffix=".ini", delete=False) as f: + f.write(""" +[app] +name = test-app +version = 1.0.0 +debug = true + +[database] +host = localhost +port = 5432 +""") + f.flush() + yield f.name + os.unlink(f.name) + + +@pytest.fixture +def temp_dir(): + """Create a temporary directory for testing.""" + with tempfile.TemporaryDirectory() as tmpdir: + yield Path(tmpdir)