1717
1818media = pathlib .Path (__file__ ).parents [1 ] / "third_party"
1919
20-
2120class UnitTests (absltest .TestCase ):
2221 def test_files_create_text (self ):
2322 # [START files_create_text]
2423 from google import genai
24+
2525 client = genai .Client ()
2626 myfile = client .files .upload (file = media / "poem.txt" )
2727 print (f"{ myfile = } " )
@@ -36,6 +36,7 @@ def test_files_create_text(self):
3636 def test_files_create_image (self ):
3737 # [START files_create_image]
3838 from google import genai
39+
3940 client = genai .Client ()
4041 myfile = client .files .upload (file = media / "Cajun_instruments.jpg" )
4142 print (f"{ myfile = } " )
@@ -50,6 +51,7 @@ def test_files_create_image(self):
5051 def test_files_create_audio (self ):
5152 # [START files_create_audio]
5253 from google import genai
54+
5355 client = genai .Client ()
5456 myfile = client .files .upload (file = media / "sample.mp3" )
5557 print (f"{ myfile = } " )
@@ -87,6 +89,7 @@ def test_files_create_video(self):
8789 def test_files_create_pdf (self ):
8890 # [START files_create_pdf]
8991 from google import genai
92+
9093 client = genai .Client ()
9194 sample_pdf = client .files .upload (file = media / "test.pdf" )
9295 response = client .models .generate_content (
@@ -118,6 +121,7 @@ def test_files_create_from_IO(self):
118121 def test_files_list (self ):
119122 # [START files_list]
120123 from google import genai
124+
121125 client = genai .Client ()
122126 print ("My files:" )
123127 for f in client .files .list ():
@@ -127,6 +131,7 @@ def test_files_list(self):
127131 def test_files_get (self ):
128132 # [START files_get]
129133 from google import genai
134+
130135 client = genai .Client ()
131136 myfile = client .files .upload (file = media / "poem.txt" )
132137 file_name = myfile .name
@@ -139,7 +144,7 @@ def test_files_get(self):
139144 def test_files_delete (self ):
140145 # [START files_delete]
141146 from google import genai
142- from google . api_core import exceptions
147+
143148 client = genai .Client ()
144149 myfile = client .files .upload (file = media / "poem.txt" )
145150
@@ -150,10 +155,10 @@ def test_files_delete(self):
150155 model = "gemini-2.0-flash" ,
151156 contents = [myfile , "Describe this file." ]
152157 )
158+ print (result )
153159 except genai .errors .ClientError :
154160 pass
155161 # [END files_delete]
156162
157-
158163if __name__ == "__main__" :
159164 absltest .main ()
0 commit comments