Skip to content

Commit 2ca412d

Browse files
feat: working tests
1 parent 376e953 commit 2ca412d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

genai/text_generation/test_text_generation.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,41 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import os
16+
17+
from google import genai
18+
19+
import pytest
20+
1521
import textgen_chat_with_txt
1622
import textgen_chat_with_txt_stream
1723
import textgen_with_txt
1824
import textgen_with_txt_img
1925
import textgen_with_txt_stream
2026

2127

28+
PROJECT_ID = os.getenv("GOOGLE_CLOUD_PROJECT")
29+
30+
31+
@pytest.fixture(autouse=True)
32+
def setup_client():
33+
original_Client = genai.Client
34+
35+
class AutoInitClient(original_Client):
36+
def __new__(cls, *args, **kwargs):
37+
return original_Client(
38+
vertexai=True,
39+
project=PROJECT_ID,
40+
location="us-central1"
41+
)
42+
43+
genai.Client = AutoInitClient
44+
45+
yield
46+
47+
genai.Client = original_Client
48+
49+
2250
def test_textgen_with_txt() -> None:
2351
response = textgen_with_txt.generate_content()
2452
assert response

0 commit comments

Comments
 (0)