82 lines
2.2 KiB
Python
82 lines
2.2 KiB
Python
import json
|
|
import os
|
|
|
|
runtime_params = []
|
|
|
|
def pytest_runtest_makereport(item, call):
|
|
if call.when != "call":
|
|
return
|
|
|
|
entry = {"nodeid": item.nodeid, "params": {}}
|
|
|
|
if hasattr(item, "callspec"):
|
|
entry["params"] = item.callspec.params
|
|
else:
|
|
request = getattr(item, "_request", None)
|
|
if request and hasattr(request, "funcargs"):
|
|
entry["params"] = request.funcargs
|
|
|
|
runtime_params.append(entry)
|
|
|
|
def pytest_sessionfinish(session, exitstatus):
|
|
os.makedirs("ci-reports/markdown", exist_ok=True)
|
|
print("✅ Dumping runtime_params.json...")
|
|
with open("ci-reports/markdown/runtime_params.json", "w") as f:
|
|
json.dump(runtime_params, f, indent=2)
|
|
'''
|
|
|
|
# conftest.py
|
|
|
|
import json
|
|
import os
|
|
|
|
def serialize_object(obj):
|
|
"""Convertit récursivement un objet en une forme sérialisable (brute)."""
|
|
if isinstance(obj, (str, int, float, bool)) or obj is None:
|
|
return obj
|
|
if isinstance(obj, (list, tuple, set)):
|
|
return [serialize_object(x) for x in obj]
|
|
if isinstance(obj, dict):
|
|
return {str(k): serialize_object(v) for k, v in obj.items()}
|
|
try:
|
|
return str(obj)
|
|
except Exception:
|
|
return "<unserializable>"
|
|
|
|
runtime_data = []
|
|
|
|
def pytest_runtest_makereport(item, call):
|
|
if call.when != "call":
|
|
return
|
|
|
|
item_data = {}
|
|
for attr in dir(item):
|
|
if attr.startswith("_"):
|
|
continue
|
|
try:
|
|
value = getattr(item, attr)
|
|
item_data[attr] = serialize_object(value)
|
|
except Exception:
|
|
item_data[attr] = "<error>"
|
|
|
|
call_data = {}
|
|
for attr in dir(call):
|
|
if attr.startswith("_"):
|
|
continue
|
|
try:
|
|
value = getattr(call, attr)
|
|
call_data[attr] = serialize_object(value)
|
|
except Exception:
|
|
call_data[attr] = "<error>"
|
|
|
|
runtime_data.append({
|
|
"item": item_data,
|
|
"call": call_data
|
|
})
|
|
|
|
def pytest_sessionfinish(session, exitstatus):
|
|
os.makedirs("ci-reports/markdown", exist_ok=True)
|
|
print("✅ Dumping runtime_params.json...")
|
|
with open("ci-reports/markdown/runtime_params.json", "w") as f:
|
|
json.dump(runtime_params, f, indent=2)
|
|
''' |