Skip to content

Commit 4b56234

Browse files
committed
properly check for other spans
1 parent d389cd9 commit 4b56234

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ def test_text_generation(
489489
span = None
490490
for sp in transaction["spans"]:
491491
if sp["op"] == "gen_ai.generate_text":
492+
assert span is None, "there is exactly one gen_ai span"
492493
span = sp
493494
else:
494495
# there should be no other spans, just the gen_ai span
@@ -558,6 +559,7 @@ def test_text_generation_streaming(
558559
span = None
559560
for sp in transaction["spans"]:
560561
if sp["op"] == "gen_ai.generate_text":
562+
assert span is None, "there is exactly one gen_ai span"
561563
span = sp
562564
else:
563565
# there should be no other spans, just the gen_ai span
@@ -625,6 +627,7 @@ def test_chat_completion(
625627
span = None
626628
for sp in transaction["spans"]:
627629
if sp["op"] == "gen_ai.chat":
630+
assert span is None, "there is exactly one gen_ai span"
628631
span = sp
629632
else:
630633
# there should be no other spans, just the gen_ai span
@@ -698,6 +701,7 @@ def test_chat_completion_streaming(
698701
span = None
699702
for sp in transaction["spans"]:
700703
if sp["op"] == "gen_ai.chat":
704+
assert span is None, "there is exactly one gen_ai span"
701705
span = sp
702706
else:
703707
# there should be no other spans, just the gen_ai span
@@ -765,6 +769,7 @@ def test_chat_completion_api_error(
765769
span = None
766770
for sp in transaction["spans"]:
767771
if sp["op"] == "gen_ai.chat":
772+
assert span is None, "there is exactly one gen_ai span"
768773
span = sp
769774
else:
770775
# there should be no other spans, just the gen_ai span
@@ -858,6 +863,7 @@ def test_chat_completion_with_tools(
858863
span = None
859864
for sp in transaction["spans"]:
860865
if sp["op"] == "gen_ai.chat":
866+
assert span is None, "there is exactly one gen_ai span"
861867
span = sp
862868
else:
863869
# there should be no other spans, just the gen_ai span
@@ -949,6 +955,7 @@ def test_chat_completion_streaming_with_tools(
949955
span = None
950956
for sp in transaction["spans"]:
951957
if sp["op"] == "gen_ai.chat":
958+
assert span is None, "there is exactly one gen_ai span"
952959
span = sp
953960
else:
954961
# there should be no other spans, just the gen_ai span

0 commit comments

Comments
 (0)