Files
config-convert-cli/tests/conftest.py
7000pctAUTO d682bc5e18
Some checks failed
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
fix: resolve CI/CD test failures and linting issues
2026-02-04 07:32:20 +00:00

84 lines
1.4 KiB
Python

"""Pytest configuration and fixtures."""
import pytest
import tempfile
import os
@pytest.fixture
def sample_json():
return {
"name": "test-project",
"version": "1.0.0",
"debug": True,
"database": {
"host": "localhost",
"port": 5432,
"ssl": False
},
"tags": ["python", "cli"]
}
@pytest.fixture
def sample_yaml():
return """name: test-project
version: '1.0.0'
debug: true
database:
host: localhost
port: 5432
ssl: false
tags:
- python
- cli
"""
@pytest.fixture
def sample_toml():
return """name = "test-project"
version = "1.0.0"
debug = true
[database]
host = "localhost"
port = 5432
ssl = false
tags = ["python", "cli"]
"""
@pytest.fixture
def sample_env():
return """NAME=test-project
VERSION=1.0.0
DEBUG=true
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_SSL=false
TAGS=python,cli
"""
@pytest.fixture
def temp_file():
def _create_temp_file(content="", suffix=".txt"):
fd, path = tempfile.mkstemp(suffix=suffix)
os.write(fd, content.encode())
os.close(fd)
yield path
os.unlink(path)
return _create_temp_file
@pytest.fixture
def temp_dir():
def _create_temp_dir():
path = tempfile.mkdtemp()
yield path
import shutil
shutil.rmtree(path)
return _create_temp_dir