Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure tests are runnable when standalone #552

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import pathlib
import copy
import collections
from typing import Union

from absl.testing import absltest
from absl.testing import parameterized

from google.generativeai import protos
Expand Down Expand Up @@ -81,3 +81,7 @@ def test_get_model(self, request_options, expected_timeout, expected_retry):

self.assertEqual(self.observed_timeout[0], expected_timeout)
self.assertEqual(str(self.observed_retry[0]), str(expected_retry))


if __name__ == "__main__":
absltest.main()
5 changes: 5 additions & 0 deletions tests/test_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import pathlib
import re

from absl.testing import absltest
from absl.testing import parameterized

ROOT = pathlib.Path(__file__).parent.parent
Expand All @@ -32,3 +33,7 @@ def test_check_glm_imports(self):
match,
msg=f"Bad `glm.` usage, use `genai.protos` instead,\n in {fpath}",
)


if __name__ == "__main__":
absltest.main()
7 changes: 5 additions & 2 deletions tests/test_responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
from absl.testing import parameterized
from google.generativeai import protos
from google.generativeai import responder
import IPython.display
import PIL.Image


HERE = pathlib.Path(__file__).parent
TEST_PNG_PATH = HERE / "test_img.png"
Expand Down Expand Up @@ -250,3 +249,7 @@ def fun(a: annotation):
cfd = responder.FunctionDeclaration.from_function(fun)
got = cfd.parameters.properties["a"]
self.assertEqual(got, expected)


if __name__ == "__main__":
absltest.main()
Loading