-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
40 lines (30 loc) · 1.53 KB
/
Copy pathconftest.py
File metadata and controls
40 lines (30 loc) · 1.53 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Root-level pytest conftest that optionally removes "Prism tests are disabled"
skip markers when RUN_PRISM_TESTS=true is set.
Used by the SDK staging validation CI workflow to enable the full
Stainless-generated API test suite against the Prism mock server.
This file lives at the project root (outside tests/) and won't be
overwritten by Stainless SDK regeneration.
"""
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false
# pyright: reportUnknownParameterType=false, reportUnknownArgumentType=false
# pyright: reportMissingTypeArgument=false
from __future__ import annotations
import os
import pytest
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
if os.environ.get("RUN_PRISM_TESTS", "").lower() != "true":
return
for item in items:
# Remove skip markers whose reason is "Prism tests are disabled"
markers_to_keep: list[pytest.Mark] = []
for marker in item.iter_markers("skip"):
reason = marker.kwargs.get("reason", "") or (marker.args[0] if marker.args else "")
if reason == "Prism tests are disabled":
continue # drop this skip marker
markers_to_keep.append(marker)
# Rebuild the item's markers without the Prism skip markers
skip_markers = list(item.iter_markers("skip"))
if len(skip_markers) != len(markers_to_keep):
# There was at least one Prism skip marker removed
item.own_markers = [m for m in item.own_markers if m.name != "skip" or m in markers_to_keep]