Skip to content

Commit 1e962f9

Browse files
test: Fix comments in cp-v2 pull request
2 parents 44e0714 + 84efe11 commit 1e962f9

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

tests/e2e-test/requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
pytest-playwright
2-
pytest-reporter-html1
3-
python-dotenv
4-
pytest-check
5-
pytest-html
6-
py
7-
beautifulsoup4
1+
pytest-playwright==0.*
2+
pytest-reporter-html1==0.*
3+
python-dotenv==1.*
4+
pytest-check==2.*
5+
pytest-html==4.*
6+
py==1.*
7+
beautifulsoup4==4.*

tests/e2e-test/tests/conftest.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
SCREENSHOTS_DIR = os.path.join(os.path.dirname(__file__), "screenshots")
1818
os.makedirs(SCREENSHOTS_DIR, exist_ok=True)
1919

20+
# Create logs directory if it doesn't exist
21+
os.makedirs("logs", exist_ok=True)
22+
23+
# Report path constant (must match --html= in workflow)
24+
REPORT_PATH = os.path.join("report", "report.html")
25+
2026

2127
@pytest.fixture
2228
def subtests(request):
@@ -145,7 +151,7 @@ def pytest_runtest_makereport(item, call):
145151
# Use relative path from report.html location
146152
relative_path = os.path.relpath(
147153
screenshot_path,
148-
os.path.dirname(os.path.abspath("report.html"))
154+
os.path.dirname(os.path.abspath(REPORT_PATH))
149155
)
150156

151157
# pytest-html expects this format for extras
@@ -163,9 +169,10 @@ def pytest_runtest_makereport(item, call):
163169
handler.flush()
164170
log_output = stream.getvalue()
165171

166-
# Only remove the handler, don't close the stream yet
167-
logger = logging.getLogger()
168-
logger.removeHandler(handler)
172+
# Only remove the handler on teardown phase so call-phase logs are captured
173+
if report.when == 'teardown':
174+
logger = logging.getLogger()
175+
logger.removeHandler(handler)
169176

170177
# Check if there are subtests
171178
subtests_html = ""
@@ -206,8 +213,9 @@ def pytest_runtest_makereport(item, call):
206213
else:
207214
report.description = f"<pre>{log_output.strip()}</pre>"
208215

209-
# Clean up references
210-
log_streams.pop(item.nodeid, None)
216+
# Clean up references only on teardown phase
217+
if report.when == 'teardown':
218+
log_streams.pop(item.nodeid, None)
211219
else:
212220
report.description = ""
213221

@@ -232,7 +240,7 @@ def pytest_collection_modifyitems(items):
232240

233241
def rename_duration_column():
234242
"""Rename Duration column to Execution Time in HTML report"""
235-
report_path = os.path.abspath("report.html")
243+
report_path = os.path.abspath(REPORT_PATH)
236244
if not os.path.exists(report_path):
237245
print("Report file not found, skipping column rename.")
238246
return

0 commit comments

Comments
 (0)