Skip to content

Commit 0e8b77d

Browse files
committed
fix tests
1 parent b9cbe01 commit 0e8b77d

4 files changed

Lines changed: 41 additions & 33 deletions

File tree

tests/test_core_sdk.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def update_generation(i, langfuse: Langfuse):
3535
generation.end()
3636

3737
# Create Langfuse client
38-
langfuse = Langfuse(debug=False)
38+
langfuse = Langfuse()
3939

4040
# Run concurrent operations
4141
await gather(*(update_generation(i, langfuse) for i in range(100)))
@@ -63,7 +63,7 @@ async def update_generation(i, langfuse: Langfuse):
6363

6464
def test_flush():
6565
# Initialize Langfuse client with debug disabled
66-
langfuse = Langfuse(debug=False)
66+
langfuse = Langfuse()
6767

6868
trace_ids = []
6969
for i in range(2):
@@ -87,7 +87,7 @@ def test_flush():
8787

8888

8989
def test_invalid_score_data_does_not_raise_exception():
90-
langfuse = Langfuse(debug=False)
90+
langfuse = Langfuse()
9191

9292
# Create a span and set trace properties
9393
with langfuse.start_as_current_span(name="test-span") as span:
@@ -118,7 +118,7 @@ def test_invalid_score_data_does_not_raise_exception():
118118

119119

120120
def test_create_numeric_score():
121-
langfuse = Langfuse(debug=False)
121+
langfuse = Langfuse()
122122
api_wrapper = LangfuseAPI()
123123

124124
# Create a span and set trace properties
@@ -164,7 +164,7 @@ def test_create_numeric_score():
164164

165165

166166
def test_create_boolean_score():
167-
langfuse = Langfuse(debug=False)
167+
langfuse = Langfuse()
168168
api_wrapper = LangfuseAPI()
169169

170170
# Create a span and set trace properties
@@ -211,7 +211,7 @@ def test_create_boolean_score():
211211

212212

213213
def test_create_categorical_score():
214-
langfuse = Langfuse(debug=False)
214+
langfuse = Langfuse()
215215
api_wrapper = LangfuseAPI()
216216

217217
# Create a span and set trace properties
@@ -257,7 +257,7 @@ def test_create_categorical_score():
257257

258258

259259
def test_create_trace():
260-
langfuse = Langfuse(debug=False)
260+
langfuse = Langfuse()
261261
trace_name = create_uuid()
262262

263263
# Create a span and update the trace properties
@@ -327,7 +327,7 @@ def test_create_update_trace():
327327

328328

329329
def test_create_generation():
330-
langfuse = Langfuse(debug=True)
330+
langfuse = Langfuse()
331331

332332
# Create a generation using OTEL approach
333333
generation = langfuse.start_generation(
@@ -427,7 +427,7 @@ def test_create_generation_complex(
427427
expected_output_cost,
428428
expected_total_cost,
429429
):
430-
langfuse = Langfuse(debug=False)
430+
langfuse = Langfuse()
431431

432432
generation = langfuse.start_generation(
433433
name="query-generation",
@@ -478,7 +478,7 @@ def test_create_generation_complex(
478478

479479

480480
def test_create_span():
481-
langfuse = Langfuse(debug=False)
481+
langfuse = Langfuse()
482482

483483
# Create span using OTEL-based client
484484
span = langfuse.start_span(
@@ -521,7 +521,7 @@ def test_create_span():
521521

522522

523523
def test_score_trace():
524-
langfuse = Langfuse(debug=False)
524+
langfuse = Langfuse()
525525
api_wrapper = LangfuseAPI()
526526

527527
trace_name = create_uuid()
@@ -560,7 +560,7 @@ def test_score_trace():
560560

561561

562562
def test_score_trace_nested_trace():
563-
langfuse = Langfuse(debug=False)
563+
langfuse = Langfuse()
564564

565565
trace_name = create_uuid()
566566

@@ -599,7 +599,7 @@ def test_score_trace_nested_trace():
599599

600600

601601
def test_score_trace_nested_observation():
602-
langfuse = Langfuse(debug=False)
602+
langfuse = Langfuse()
603603

604604
trace_name = create_uuid()
605605

@@ -644,7 +644,7 @@ def test_score_trace_nested_observation():
644644

645645

646646
def test_score_span():
647-
langfuse = Langfuse(debug=False)
647+
langfuse = Langfuse()
648648
api_wrapper = LangfuseAPI()
649649

650650
# Create a span
@@ -691,7 +691,7 @@ def test_score_span():
691691

692692

693693
def test_create_trace_and_span():
694-
langfuse = Langfuse(debug=False)
694+
langfuse = Langfuse()
695695

696696
trace_name = create_uuid()
697697

@@ -729,7 +729,7 @@ def test_create_trace_and_span():
729729

730730

731731
def test_create_trace_and_generation():
732-
langfuse = Langfuse(debug=False)
732+
langfuse = Langfuse()
733733

734734
trace_name = create_uuid()
735735

@@ -777,7 +777,7 @@ def test_create_trace_and_generation():
777777

778778

779779
def test_create_generation_and_trace():
780-
langfuse = Langfuse(debug=False)
780+
langfuse = Langfuse()
781781
api_wrapper = LangfuseAPI()
782782

783783
trace_name = create_uuid()
@@ -826,7 +826,7 @@ def test_create_generation_and_trace():
826826

827827

828828
def test_create_span_and_get_observation():
829-
langfuse = Langfuse(debug=False)
829+
langfuse = Langfuse()
830830

831831
# Create span
832832
span = langfuse.start_span(name="span")
@@ -850,7 +850,7 @@ def test_create_span_and_get_observation():
850850

851851

852852
def test_update_generation():
853-
langfuse = Langfuse(debug=False)
853+
langfuse = Langfuse()
854854

855855
# Create a generation
856856
generation = langfuse.start_generation(name="generation")
@@ -886,7 +886,7 @@ def test_update_generation():
886886

887887

888888
def test_update_span():
889-
langfuse = Langfuse(debug=False)
889+
langfuse = Langfuse()
890890

891891
# Create a span
892892
span = langfuse.start_span(name="span")
@@ -919,7 +919,7 @@ def test_update_span():
919919

920920

921921
def test_create_span_and_generation():
922-
langfuse = Langfuse(debug=False)
922+
langfuse = Langfuse()
923923

924924
# Create initial span
925925
span = langfuse.start_span(name="span")
@@ -962,7 +962,7 @@ def test_create_span_and_generation():
962962

963963

964964
def test_create_trace_with_id_and_generation():
965-
langfuse = Langfuse(debug=False)
965+
langfuse = Langfuse()
966966
api_wrapper = LangfuseAPI()
967967

968968
trace_name = create_uuid()
@@ -1247,7 +1247,7 @@ def test_end_span_with_data():
12471247

12481248

12491249
def test_get_generations():
1250-
langfuse = Langfuse(debug=False)
1250+
langfuse = Langfuse()
12511251

12521252
# Create a first generation with random name
12531253
generation1 = langfuse.start_generation(
@@ -1280,7 +1280,7 @@ def test_get_generations():
12801280

12811281

12821282
def test_get_generations_by_user():
1283-
langfuse = Langfuse(debug=False)
1283+
langfuse = Langfuse()
12841284

12851285
# Generate unique IDs for test
12861286
user_id = create_uuid()
@@ -1365,7 +1365,7 @@ def test_timezone_awareness():
13651365
assert utc_now.tzinfo is not None
13661366

13671367
# Create Langfuse client
1368-
langfuse = Langfuse(debug=False)
1368+
langfuse = Langfuse()
13691369

13701370
# Create a trace with various observation types
13711371
with langfuse.start_as_current_span(name="test") as parent_span:
@@ -1425,7 +1425,7 @@ def test_timezone_awareness_setting_timestamps():
14251425
assert utc_now.tzinfo is not None
14261426

14271427
# Create client
1428-
langfuse = Langfuse(debug=False)
1428+
langfuse = Langfuse()
14291429

14301430
# Create a trace with different observation types
14311431
with langfuse.start_as_current_span(name="test") as parent_span:
@@ -1473,7 +1473,7 @@ def test_timezone_awareness_setting_timestamps():
14731473

14741474

14751475
def test_get_trace_by_session_id():
1476-
langfuse = Langfuse(debug=False)
1476+
langfuse = Langfuse()
14771477

14781478
# Create unique IDs for test
14791479
trace_name = create_uuid()
@@ -1747,7 +1747,7 @@ def test_get_sessions():
17471747
"Flaky in concurrent environment as the global tracer provider is already configured"
17481748
)
17491749
def test_create_trace_sampling_zero():
1750-
langfuse = Langfuse(debug=True, sample_rate=0)
1750+
langfuse = Langfuse(sample_rate=0)
17511751
api_wrapper = LangfuseAPI()
17521752
trace_name = create_uuid()
17531753

@@ -1788,7 +1788,7 @@ def mask_func(data):
17881788
return "MASKED"
17891789
return data
17901790

1791-
langfuse = Langfuse(debug=True, mask=mask_func)
1791+
langfuse = Langfuse(mask=mask_func)
17921792
api_wrapper = LangfuseAPI()
17931793

17941794
# Create a root span with trace properties
@@ -1836,7 +1836,7 @@ def mask_func(data):
18361836
def faulty_mask_func(data):
18371837
raise Exception("Masking error")
18381838

1839-
langfuse = Langfuse(debug=True, mask=faulty_mask_func)
1839+
langfuse = Langfuse(mask=faulty_mask_func)
18401840

18411841
# Create a root span with trace properties
18421842
with langfuse.start_as_current_span(name="test-span") as root_span:
@@ -1857,14 +1857,14 @@ def faulty_mask_func(data):
18571857

18581858

18591859
def test_get_project_id():
1860-
langfuse = Langfuse(debug=False)
1860+
langfuse = Langfuse()
18611861
res = langfuse._get_project_id()
18621862
assert res is not None
18631863
assert res == "7a88fb47-b4e2-43b8-a06c-a5ce950dc53a"
18641864

18651865

18661866
def test_generate_trace_id():
1867-
langfuse = Langfuse(debug=False)
1867+
langfuse = Langfuse()
18681868
trace_id = langfuse.create_trace_id()
18691869

18701870
# Create a trace with the specific ID using trace_context

tests/test_datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def sorted_dependencies(
345345

346346
def test_observe_dataset_run():
347347
# Create dataset
348-
langfuse = Langfuse(debug=True)
348+
langfuse = Langfuse()
349349
dataset_name = create_uuid()
350350
langfuse.create_dataset(name=dataset_name)
351351

tests/test_logger.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ def test_via_env():
3131
def test_debug_langfuse():
3232
Langfuse(debug=True)
3333
assert langfuse_logger.level == 10
34+
35+
# Reset
36+
langfuse_logger.setLevel("WARNING")

tests/test_openai.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib
12
import os
23

34
import pytest
@@ -11,10 +12,14 @@
1112

1213
@pytest.fixture(scope="module")
1314
def openai():
15+
import openai
16+
1417
from langfuse.openai import openai as _openai
1518

1619
yield _openai
1720

21+
importlib.reload(openai)
22+
1823

1924
def test_openai_chat_completion(openai):
2025
generation_name = create_uuid()

0 commit comments

Comments
 (0)