Skip to content

Commit 7313e21

Browse files
Remove duplicate test (#387)
* Cover methods like _handle_afc Change-Id: I0f45cb8566b681f5aaeda1500e74d95eaeab10ef * Remove duplicate code match test Change-Id: Ia9b7c3dcb8dd4d6bf163303b483225aa0b00e0e9
1 parent 8713cfd commit 7313e21

File tree

2 files changed

+1
-51
lines changed

2 files changed

+1
-51
lines changed

tests/test_async_code_match.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_code_match_for_async_methods(self):
8787
for node in ast.walk(source_nodes):
8888
if isinstance(
8989
node, (ast.FunctionDef, ast.AsyncFunctionDef)
90-
) and not node.name.startswith("_"):
90+
) and not node.name.startswith("__"):
9191
name = node.name[:-6] if node.name.endswith("_async") else node.name
9292
if name in EXEMPT_FUNCTIONS or self._inspect_decorator_exemption(node, fpath):
9393
continue

tests/test_generative_models.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -847,56 +847,6 @@ def test_count_tokens_smoke(self, kwargs):
847847
{"total_tokens": 7},
848848
)
849849

850-
@parameterized.named_parameters(
851-
[
852-
"GenerateContentResponse",
853-
generation_types.GenerateContentResponse,
854-
generation_types.AsyncGenerateContentResponse,
855-
],
856-
[
857-
"GenerativeModel.generate_response",
858-
generative_models.GenerativeModel.generate_content,
859-
generative_models.GenerativeModel.generate_content_async,
860-
],
861-
[
862-
"GenerativeModel.count_tokens",
863-
generative_models.GenerativeModel.count_tokens,
864-
generative_models.GenerativeModel.count_tokens_async,
865-
],
866-
[
867-
"ChatSession.send_message",
868-
generative_models.ChatSession.send_message,
869-
generative_models.ChatSession.send_message_async,
870-
],
871-
[
872-
"ChatSession._handle_afc",
873-
generative_models.ChatSession._handle_afc,
874-
generative_models.ChatSession._handle_afc_async,
875-
],
876-
)
877-
def test_async_code_match(self, obj, aobj):
878-
import inspect
879-
import re
880-
881-
source = inspect.getsource(obj)
882-
asource = inspect.getsource(aobj)
883-
884-
source = re.sub('""".*"""', "", source, flags=re.DOTALL)
885-
asource = re.sub('""".*"""', "", asource, flags=re.DOTALL)
886-
887-
asource = (
888-
asource.replace("anext", "next")
889-
.replace("aiter", "iter")
890-
.replace("_async", "")
891-
.replace("async ", "")
892-
.replace("await ", "")
893-
.replace("Async", "")
894-
.replace("ASYNC_", "")
895-
)
896-
897-
asource = re.sub(" *?# type: ignore", "", asource)
898-
self.assertEqual(source, asource, f"error in {obj=}")
899-
900850
def test_repr_for_unary_non_streamed_response(self):
901851
model = generative_models.GenerativeModel(model_name="gemini-pro")
902852
self.responses["generate_content"].append(simple_response("world!"))

0 commit comments

Comments
 (0)