Skip to content

Commit e17bc4d

Browse files
committed
skip some stateful tests from CI runs
1 parent 8c16eb9 commit e17bc4d

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ uv run ruff format getstream/ tests/
121121

122122
pytest is used to run tests and to inject fixtures, simple tests can be written as simple python functions making assert calls. Make sure to have a look at the available test fixtures under `tests/fixtures.py`
123123

124+
#### Skipping Tests in CI
125+
126+
Some tests may not be suitable for running in a CI environment (GitHub Actions). To skip a test in CI, use the `@pytest.mark.skip_in_ci` decorator:
127+
128+
```python
129+
import pytest
130+
131+
@pytest.mark.skip_in_ci
132+
def test_something():
133+
# This test will be skipped when running in GitHub Actions
134+
...
135+
```
136+
137+
The test will run normally in local development environments but will be automatically skipped when running in GitHub Actions.
138+
124139
### Generate code from spec
125140

126141
To regenerate the Python source from OpenAPI, just run the `./generate.sh` script from this repo.

tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
import os
23
from dotenv import load_dotenv
34
from tests.fixtures import client, call, get_user, shared_call
45

@@ -8,3 +9,23 @@
89
@pytest.fixture(scope="session", autouse=True)
910
def load_env():
1011
load_dotenv()
12+
13+
14+
def pytest_configure(config):
15+
"""Register custom markers."""
16+
config.addinivalue_line(
17+
"markers", "skip_in_ci: mark test to skip when running in CI"
18+
)
19+
20+
21+
def is_running_in_github_actions():
22+
"""Check if the tests are running in GitHub Actions CI."""
23+
return os.environ.get("GITHUB_ACTIONS") == "true"
24+
25+
26+
def pytest_runtest_setup(item):
27+
"""Skip tests marked with skip_in_ci when running in GitHub Actions."""
28+
if is_running_in_github_actions():
29+
skip_in_ci_marker = item.get_closest_marker("skip_in_ci")
30+
if skip_in_ci_marker is not None:
31+
pytest.skip("Test skipped in CI environment")

tests/test_video_examples.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def test_create_call_with_custom_session_inactivity_timeout(call: Call):
297297
assert response.data.call.settings.session.inactivity_timeout_seconds == 5
298298

299299

300+
@pytest.mark.skip_in_ci
300301
def test_create_call_type_with_custom_session_inactivity_timeout(client: Stream):
301302
# create a call type with a session inactivity timeout of 5 minutes
302303
response = client.video.create_call_type(
@@ -358,6 +359,7 @@ def test_create_call_with_custom_frame_recording_settings(client: Stream):
358359
assert response.data.call.settings.frame_recording.quality == "1080p"
359360

360361

362+
@pytest.mark.skip_in_ci
361363
def test_create_call_type_with_custom_frame_recording_settings(client: Stream):
362364
# create a call type with frame recording settings
363365
response = client.video.create_call_type(

tests/test_video_integration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_teams(client: Stream):
103103
assert len(response.data.calls) > 0
104104

105105

106+
@pytest.mark.skip_in_ci
106107
class TestCallTypes:
107108
def test_creating_storage_with_reserved_name_should_fail(self, client: Stream):
108109
with pytest.raises(Exception) as exc_info:
@@ -290,6 +291,7 @@ def test_custom_recording_website(self, client: Stream):
290291
),
291292
)
292293

294+
@pytest.mark.skip_in_ci
293295
def test_delete_call_type(self, client: Stream):
294296
try:
295297
response = client.video.delete_call_type(name=CALL_TYPE_NAME)

0 commit comments

Comments
 (0)