Initial upload: ConfigConvert CLI with full test suite and CI/CD
This commit is contained in:
84
tests/conftest.py
Normal file
84
tests/conftest.py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
"""Pytest configuration and fixtures."""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
||||||
Reference in New Issue
Block a user