-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
27 lines (20 loc) · 812 Bytes
/
conftest.py
File metadata and controls
27 lines (20 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import sys
import os
import json
import subprocess
import tempfile
import yaml
# Shared test utilities
PYKEN = os.path.join(os.path.dirname(__file__), 'pyken.py')
def run_pyken(*args, input_data=None):
"""Run pyken.py with given args and input data, return subprocess result."""
cmd = [sys.executable, PYKEN] + list(args)
return subprocess.run(cmd, input=input_data, capture_output=True, text=True)
def make_mapping_file(content):
"""Create a temporary mapping file with the given YAML content."""
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as f:
yaml.dump(yaml.safe_load(content), f)
return f.name
def load_mapping_from_yaml(yaml_content):
"""Parse YAML content and return the mapping dict."""
return yaml.safe_load(yaml_content)