Skip to content

Commit 6245947

Browse files
committed
update huggingface tests. migrate over to ANY in the other tests
1 parent 7404b69 commit 6245947

8 files changed

Lines changed: 52 additions & 26 deletions

File tree

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,8 @@ def test_text_generation(
521521
"gen_ai.response.finish_reasons": "length",
522522
"gen_ai.response.streaming": False,
523523
"gen_ai.usage.total_tokens": 10,
524+
"process.runtime.name": mock.ANY,
525+
"process.runtime.version": mock.ANY,
524526
"sentry.environment": "production",
525527
"sentry.op": "gen_ai.text_completion",
526528
"sentry.origin": "auto.ai.huggingface_hub",
@@ -658,6 +660,8 @@ def test_text_generation_streaming(
658660
"gen_ai.response.finish_reasons": "length",
659661
"gen_ai.response.streaming": True,
660662
"gen_ai.usage.total_tokens": 10,
663+
"process.runtime.name": mock.ANY,
664+
"process.runtime.version": mock.ANY,
661665
"sentry.environment": "production",
662666
"sentry.op": "gen_ai.text_completion",
663667
"sentry.origin": "auto.ai.huggingface_hub",
@@ -799,6 +803,8 @@ def test_chat_completion(
799803
"gen_ai.usage.input_tokens": 10,
800804
"gen_ai.usage.output_tokens": 8,
801805
"gen_ai.usage.total_tokens": 18,
806+
"process.runtime.name": mock.ANY,
807+
"process.runtime.version": mock.ANY,
802808
"sentry.environment": "production",
803809
"sentry.op": "gen_ai.chat",
804810
"sentry.origin": "auto.ai.huggingface_hub",
@@ -948,6 +954,8 @@ def test_chat_completion_streaming(
948954
"gen_ai.response.finish_reasons": "stop",
949955
"gen_ai.response.model": "test-model-123",
950956
"gen_ai.response.streaming": True,
957+
"process.runtime.name": mock.ANY,
958+
"process.runtime.version": mock.ANY,
951959
"sentry.environment": "production",
952960
"sentry.op": "gen_ai.chat",
953961
"sentry.origin": "auto.ai.huggingface_hub",
@@ -1095,6 +1103,8 @@ def test_chat_completion_api_error(
10951103
expected_data = {
10961104
"gen_ai.operation.name": "chat",
10971105
"gen_ai.request.model": "test-model",
1106+
"process.runtime.name": mock.ANY,
1107+
"process.runtime.version": mock.ANY,
10981108
"sentry.environment": "production",
10991109
"sentry.op": "gen_ai.chat",
11001110
"sentry.origin": "auto.ai.huggingface_hub",
@@ -1294,6 +1304,8 @@ def test_chat_completion_with_tools(
12941304
"gen_ai.usage.input_tokens": 10,
12951305
"gen_ai.usage.output_tokens": 8,
12961306
"gen_ai.usage.total_tokens": 18,
1307+
"process.runtime.name": mock.ANY,
1308+
"process.runtime.version": mock.ANY,
12971309
"sentry.environment": "production",
12981310
"sentry.op": "gen_ai.chat",
12991311
"sentry.origin": "auto.ai.huggingface_hub",
@@ -1454,6 +1466,8 @@ def test_chat_completion_streaming_with_tools(
14541466
"gen_ai.response.finish_reasons": "tool_calls",
14551467
"gen_ai.response.model": "test-model-123",
14561468
"gen_ai.response.streaming": True,
1469+
"process.runtime.name": mock.ANY,
1470+
"process.runtime.version": mock.ANY,
14571471
"sentry.environment": "production",
14581472
"sentry.op": "gen_ai.chat",
14591473
"sentry.origin": "auto.ai.huggingface_hub",

tests/integrations/logging/test_logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ def test_logger_with_all_attributes(sentry_init, capture_items):
539539
"logger.name": "test-logger",
540540
"sentry.origin": "auto.log.stdlib",
541541
"sentry.message.template": "log #%d",
542-
"process.runtime.name": platform.python_implementation(),
543-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
542+
"process.runtime.name": mock.ANY,
543+
"process.runtime.version": mock.ANY,
544544
"sentry.message.parameter.0": 1,
545545
"sentry.environment": "production",
546546
"sentry.sdk.version": VERSION,

tests/integrations/loguru/test_loguru.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ def test_logger_with_all_attributes(
468468
"logger.name": "tests.integrations.loguru.test_loguru",
469469
"sentry.origin": "auto.log.loguru",
470470
"sentry.environment": "production",
471-
"process.runtime.name": platform.python_implementation(),
472-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
471+
"process.runtime.name": mock.ANY,
472+
"process.runtime.version": mock.ANY,
473473
"sentry.sdk.version": VERSION,
474474
"sentry.severity_number": 13,
475475
"sentry.severity_text": "warn",

tests/integrations/openai/test_openai.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,8 +3834,8 @@ def test_ai_client_span_responses_api_no_pii(
38343834
"gen_ai.usage.output_tokens": 10,
38353835
"gen_ai.usage.output_tokens.reasoning": 8,
38363836
"gen_ai.usage.total_tokens": 30,
3837-
"process.runtime.name": platform.python_implementation(),
3838-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
3837+
"process.runtime.name": mock.ANY,
3838+
"process.runtime.version": mock.ANY,
38393839
"sentry.environment": "production",
38403840
"sentry.op": "gen_ai.responses",
38413841
"sentry.origin": "auto.ai.openai",
@@ -3882,8 +3882,8 @@ def test_ai_client_span_responses_api_no_pii(
38823882
"gen_ai.usage.output_tokens": 10,
38833883
"gen_ai.usage.output_tokens.reasoning": 8,
38843884
"gen_ai.usage.total_tokens": 30,
3885-
"process.runtime.name": platform.python_implementation(),
3886-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
3885+
"process.runtime.name": mock.ANY,
3886+
"process.runtime.version": mock.ANY,
38873887
"sentry.environment": "production",
38883888
"sentry.op": "gen_ai.responses",
38893889
"sentry.origin": "auto.ai.openai",
@@ -4145,8 +4145,8 @@ def test_ai_client_span_responses_api(
41454145
"gen_ai.request.messages": safe_serialize(expected_request_messages),
41464146
"gen_ai.request.model": "gpt-4o",
41474147
"gen_ai.response.text": "the model response",
4148-
"process.runtime.name": platform.python_implementation(),
4149-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
4148+
"process.runtime.name": mock.ANY,
4149+
"process.runtime.version": mock.ANY,
41504150
"sentry.environment": "production",
41514151
"sentry.op": "gen_ai.responses",
41524152
"sentry.origin": "auto.ai.openai",
@@ -4199,8 +4199,8 @@ def test_ai_client_span_responses_api(
41994199
"gen_ai.request.messages": safe_serialize(expected_request_messages),
42004200
"gen_ai.request.model": "gpt-4o",
42014201
"gen_ai.response.text": "the model response",
4202-
"process.runtime.name": platform.python_implementation(),
4203-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
4202+
"process.runtime.name": mock.ANY,
4203+
"process.runtime.version": mock.ANY,
42044204
"sentry.environment": "production",
42054205
"sentry.op": "gen_ai.responses",
42064206
"sentry.origin": "auto.ai.openai",
@@ -4636,8 +4636,8 @@ async def test_ai_client_span_responses_async_api(
46364636
"gen_ai.usage.output_tokens.reasoning": 8,
46374637
"gen_ai.usage.total_tokens": 30,
46384638
"gen_ai.response.text": "the model response",
4639-
"process.runtime.name": platform.python_implementation(),
4640-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
4639+
"process.runtime.name": mock.ANY,
4640+
"process.runtime.version": mock.ANY,
46414641
"sentry.environment": "production",
46424642
"sentry.op": "gen_ai.responses",
46434643
"sentry.origin": "auto.ai.openai",
@@ -4690,8 +4690,8 @@ async def test_ai_client_span_responses_async_api(
46904690
"gen_ai.usage.output_tokens.reasoning": 8,
46914691
"gen_ai.usage.total_tokens": 30,
46924692
"gen_ai.response.text": "the model response",
4693-
"process.runtime.name": platform.python_implementation(),
4694-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
4693+
"process.runtime.name": mock.ANY,
4694+
"process.runtime.version": mock.ANY,
46954695
"sentry.environment": "production",
46964696
"sentry.op": "gen_ai.responses",
46974697
"sentry.origin": "auto.ai.openai",
@@ -4989,8 +4989,8 @@ async def test_ai_client_span_streaming_responses_async_api(
49894989
"sentry.environment": "production",
49904990
"sentry.op": "gen_ai.responses",
49914991
"sentry.origin": "auto.ai.openai",
4992-
"process.runtime.name": platform.python_implementation(),
4993-
"process.runtime.version": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
4992+
"process.runtime.name": mock.ANY,
4993+
"process.runtime.version": mock.ANY,
49944994
"sentry.release": mock.ANY,
49954995
"sentry.sdk.name": "sentry.python",
49964996
"sentry.sdk.version": mock.ANY,

tests/test_logs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ def test_transport_format(sentry_init, capture_envelopes):
498498
},
499499
"process.runtime.name": {
500500
"type": "string",
501-
"value": platform.python_implementation(),
501+
"value": mock.ANY,
502502
},
503503
"process.runtime.version": {
504504
"type": "string",
505-
"value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
505+
"value": mock.ANY,
506506
},
507507
"sentry.severity_text": {
508508
"type": "string",
@@ -585,11 +585,11 @@ def record_lost_event(reason, data_category=None, item=None, *, quantity=1):
585585
},
586586
"process.runtime.name": {
587587
"type": "string",
588-
"value": platform.python_implementation(),
588+
"value": mock.ANY,
589589
},
590590
"process.runtime.version": {
591591
"type": "string",
592-
"value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
592+
"value": mock.ANY,
593593
},
594594
"sentry.severity_text": {
595595
"type": "string",

tests/test_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,11 @@ def test_transport_format(sentry_init, capture_envelopes):
287287
},
288288
"process.runtime.name": {
289289
"type": "string",
290-
"value": platform.python_implementation(),
290+
"value": mock.ANY,
291291
},
292292
"process.runtime.version": {
293293
"type": "string",
294-
"value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
294+
"value": mock.ANY,
295295
},
296296
"sentry.sdk.name": {
297297
"type": "string",

tests/tracing/test_decorator.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def my_agent():
187187
assert agent_span["attributes"] == {
188188
"gen_ai.agent.name": "test_decorator.test_span_templates_ai_dicts.<locals>.my_agent",
189189
"gen_ai.operation.name": "invoke_agent",
190+
"process.runtime.name": mock.ANY,
191+
"process.runtime.version": mock.ANY,
190192
"sentry.environment": "production",
191193
"sentry.op": "gen_ai.invoke_agent",
192194
"sentry.origin": "manual",
@@ -210,6 +212,8 @@ def my_agent():
210212
"gen_ai.usage.input_tokens": 10,
211213
"gen_ai.usage.output_tokens": 20,
212214
"gen_ai.usage.total_tokens": 30,
215+
"process.runtime.name": mock.ANY,
216+
"process.runtime.version": mock.ANY,
213217
"sentry.environment": "production",
214218
"sentry.op": "gen_ai.execute_tool",
215219
"sentry.origin": "manual",
@@ -239,6 +243,8 @@ def my_agent():
239243
"gen_ai.usage.input_tokens": 11,
240244
"gen_ai.usage.output_tokens": 22,
241245
"gen_ai.usage.total_tokens": 33,
246+
"process.runtime.name": mock.ANY,
247+
"process.runtime.version": mock.ANY,
242248
"sentry.environment": "production",
243249
"sentry.op": "gen_ai.chat",
244250
"sentry.origin": "manual",
@@ -384,6 +390,8 @@ def my_agent():
384390
assert agent_span["attributes"] == {
385391
"gen_ai.agent.name": "test_decorator.test_span_templates_ai_objects.<locals>.my_agent",
386392
"gen_ai.operation.name": "invoke_agent",
393+
"process.runtime.name": mock.ANY,
394+
"process.runtime.version": mock.ANY,
387395
"sentry.environment": "production",
388396
"sentry.op": "gen_ai.invoke_agent",
389397
"sentry.origin": "manual",
@@ -408,6 +416,8 @@ def my_agent():
408416
"gen_ai.usage.input_tokens": 10,
409417
"gen_ai.usage.output_tokens": 20,
410418
"gen_ai.usage.total_tokens": 30,
419+
"process.runtime.name": mock.ANY,
420+
"process.runtime.version": mock.ANY,
411421
"sentry.environment": "production",
412422
"sentry.op": "gen_ai.execute_tool",
413423
"sentry.origin": "manual",
@@ -436,6 +446,8 @@ def my_agent():
436446
"gen_ai.usage.input_tokens": 11,
437447
"gen_ai.usage.output_tokens": 22,
438448
"gen_ai.usage.total_tokens": 33,
449+
"process.runtime.name": mock.ANY,
450+
"process.runtime.version": mock.ANY,
439451
"sentry.environment": "production",
440452
"sentry.op": "gen_ai.chat",
441453
"sentry.origin": "manual",

tests/tracing/test_span_streaming.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1725,10 +1725,10 @@ def test_default_attributes(sentry_init, capture_envelopes):
17251725
"sentry.sdk.integrations": {"value": mock.ANY, "type": "array"},
17261726
"process.runtime.name": {
17271727
"type": "string",
1728-
"value": platform.python_implementation(),
1728+
"value": mock.ANY,
17291729
},
17301730
"process.runtime.version": {
17311731
"type": "string",
1732-
"value": f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}",
1732+
"value": mock.ANY,
17331733
},
17341734
}

0 commit comments

Comments
 (0)