Skip to content

Commit 784da1e

Browse files
committed
fix tests
1 parent 6f93d28 commit 784da1e

7 files changed

Lines changed: 77 additions & 186 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ jobs:
155155
- name: Run the automated tests
156156
run: |
157157
python --version
158-
poetry run pytest -n auto -s -v --log-cli-level=INFO
158+
poetry run pytest -n auto --dist loadfile -s -v --log-cli-level=INFO
159159
160160
all-tests-passed:
161161
# This allows us to have a branch protection rule for tests and deploys with matrix

tests/test_core_sdk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ def test_create_span_and_generation():
923923

924924
# Create initial span
925925
span = langfuse.start_span(name="span")
926+
sleep(0.1)
926927
# Get trace ID for later use
927928
trace_id = span.trace_id
928929
# End the span

tests/test_decorators.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from langfuse import get_client, observe
1212
from langfuse.langchain import CallbackHandler
1313
from langfuse.media import LangfuseMedia
14-
from langfuse.openai import AsyncOpenAI
1514
from tests.utils import get_api
1615

1716
mock_metadata = {"key": "metadata"}
@@ -804,6 +803,8 @@ async def main_async(**kwargs):
804803

805804
@pytest.mark.asyncio
806805
async def test_async_nested_openai_chat_stream():
806+
from langfuse.openai import AsyncOpenAI
807+
807808
mock_name = "test_async_nested_openai_chat_stream"
808809
langfuse = get_client()
809810
mock_trace_id = langfuse.create_trace_id()

tests/test_langchain_integration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .utils import create_uuid
1212

1313

14-
# to avoid the instanciation of langfuse in side langfuse.openai.
1514
def _is_streaming_response(response):
1615
return isinstance(response, types.GeneratorType) or isinstance(
1716
response, types.AsyncGeneratorType

tests/test_media.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,13 @@ def test_content_sha256_hash():
6161

6262
def test_reference_string():
6363
media = LangfuseMedia(content_bytes=SAMPLE_JPEG_BYTES, content_type="image/jpeg")
64-
# Reference string should be None initially as media_id is not set
65-
assert media._reference_string is None
6664

67-
# Set media_id
68-
media._media_id = "test-id"
65+
media._media_id = "MwoGlsMS6lW8ijWeRyZKfD"
6966
reference = media._reference_string
70-
assert reference is not None
71-
assert "test-id" in reference
72-
assert "image/jpeg" in reference
73-
assert "bytes" in reference
67+
assert (
68+
reference
69+
== "@@@langfuseMedia:type=image/jpeg|id=MwoGlsMS6lW8ijWeRyZKfD|source=bytes@@@"
70+
)
7471

7572

7673
def test_parse_reference_string():

0 commit comments

Comments
 (0)