Skip to content

Commit 2ded6d7

Browse files
committed
fix: properly provide bearer_token in test fixtures
The tests were failing because they were trying to create Replicate clients without providing the required bearer_token. Fixed by directly providing bearer_token="test-token" instead of trying to mock the environment.
1 parent e10fb3d commit 2ded6d7

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

tests/test_models_backward_compat.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Tests for backward compatibility in models.get() method.
33
"""
44

5-
from unittest.mock import Mock, AsyncMock, patch
5+
from unittest.mock import Mock, AsyncMock
66

77
import pytest
88

@@ -36,8 +36,7 @@ class TestModelGetBackwardCompatibility:
3636
@pytest.fixture
3737
def client(self):
3838
"""Create a Replicate client with mocked token."""
39-
with patch("replicate.lib.cog._get_api_token_from_environment", return_value="test-token"):
40-
return Replicate()
39+
return Replicate(bearer_token="test-token")
4140

4241
def test_legacy_format_owner_name(self, client, mock_model_response):
4342
"""Test legacy format: models.get('owner/name')."""
@@ -150,8 +149,7 @@ class TestAsyncModelGetBackwardCompatibility:
150149
@pytest.fixture
151150
async def async_client(self):
152151
"""Create an async Replicate client with mocked token."""
153-
with patch("replicate.lib.cog._get_api_token_from_environment", return_value="test-token"):
154-
return AsyncReplicate()
152+
return AsyncReplicate(bearer_token="test-token")
155153

156154
@pytest.mark.asyncio
157155
async def test_async_legacy_format_owner_name(self, async_client, mock_model_response):
@@ -208,8 +206,7 @@ class TestModelVersionIdentifierIntegration:
208206
@pytest.fixture
209207
def client(self):
210208
"""Create a Replicate client with mocked token."""
211-
with patch("replicate.lib.cog._get_api_token_from_environment", return_value="test-token"):
212-
return Replicate()
209+
return Replicate(bearer_token="test-token")
213210

214211
def test_legacy_format_parsing_edge_cases(self, client, mock_model_response):
215212
"""Test edge cases in legacy format parsing."""

0 commit comments

Comments
 (0)