88def test_use_does_not_raise_without_token ():
99 """Test that replicate.use() works even when no API token is available."""
1010 sys .path .insert (0 , "src" )
11-
11+
1212 with patch .dict (os .environ , {}, clear = True ):
1313 with patch .dict (sys .modules , {"cog" : None }):
1414 import replicate
15-
15+
1616 # Should not raise an exception
1717 model = replicate .use ("test/model" )
1818 assert model is not None
@@ -21,10 +21,10 @@ def test_use_does_not_raise_without_token():
2121def test_cog_current_scope ():
2222 """Test that cog.current_scope().context is read on each client creation."""
2323 sys .path .insert (0 , "src" )
24-
24+
2525 mock_context = MagicMock ()
2626 mock_context .items .return_value = [("REPLICATE_API_TOKEN" , "test-token-1" )]
27-
27+
2828 mock_scope = MagicMock ()
2929 mock_scope .context = mock_context
3030
@@ -34,19 +34,19 @@ def test_cog_current_scope():
3434 with patch .dict (os .environ , {}, clear = True ):
3535 with patch .dict (sys .modules , {"cog" : mock_cog }):
3636 import replicate
37-
37+
3838 model = replicate .use ("test/model" )
39-
39+
4040 # Access the client property - this should trigger client creation and cog.current_scope call
4141 _ = model ._client
4242
4343 assert mock_cog .current_scope .call_count == 1
4444
4545 # Change the token and access client again - should trigger another call
4646 mock_context .items .return_value = [("REPLICATE_API_TOKEN" , "test-token-2" )]
47-
47+
4848 # Create a new model to trigger another client creation
4949 model2 = replicate .use ("test/model2" )
5050 _ = model2 ._client
51-
51+
5252 assert mock_cog .current_scope .call_count == 2
0 commit comments