File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # conftest.py
2+ import pytest , os , sys
3+ from pathlib import Path
4+ script_dir = Path (__file__ ).parents [0 ]
5+ sys .path .append (os .path .join (script_dir , '../Tools/PythonTools' ))
6+ from update_expected_output import copy_existing_files
7+
8+
9+ @pytest .hookimpl (tryfirst = True , hookwrapper = True )
10+ def pytest_runtest_makereport (item , call ):
11+ outcome = yield
12+ report = outcome .get_result ()
13+
14+ # Only proceed during the "call" phase
15+ if report .when != "call" :
16+ return
17+
18+ # Read environment variables
19+ copy_all_output = os .getenv ("UPDATE_ALL_EXPECTED_OUTPUT" , "" ).upper () == "TRUE"
20+ copy_failed_output = os .getenv ("UPDATE_FAILED_EXPECTED_OUTPUT" , "" ).upper () == "TRUE"
21+
22+ # Logic:
23+ # - UPDATE_ALL_EXPECTED_OUTPUT → always copy
24+ # - UPDATE_FAILED_EXPECTED_OUTPUT → copy only if test failed
25+ if copy_all_output or (copy_failed_output and report .failed ):
26+ # Build test path
27+ test_name = item .name
28+ test_name = test_name .replace ('-' , '/' , 1 )
29+ test_path = Path (item .config .rootdir ) / test_name
30+
31+ copy_existing_files (test_path )
32+
33+
34+
You can’t perform that action at this time.
0 commit comments