repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
apragacz/django-rest-registration | import pytest
from django.conf import settings
from django.test.utils import override_settings
from rest_registration.api.views.register_email import RegisterEmailSigner
from tests.helpers.views import ViewProvider
VERIFICATION_URL = "/accounts/verify-email/"
SUCCESS_URL = "/accounts/verify-email/success/"
FAILURE_UR... | 302 | assert | numeric_literal | tests/unit_tests/contrib/verification_redirects/test_register_email.py | test_ok | 23 | null | |
apragacz/django-rest-registration | from django.contrib.auth import get_user_model
def shallow_merge_dicts(dictionary, *other_dicts):
result = {}
result.update(dictionary)
for other_dict in other_dicts:
result.update(other_dict)
return result
def create_test_user(**kwargs):
password = kwargs.pop('password', None)
user_m... | expected_len | assert | variable | tests/helpers/common.py | assert_len_equals | 39 | null | |
apragacz/django-rest-registration | import pytest
from rest_registration.exceptions import UserNotFound
from rest_registration.utils.users import (
authenticate_by_login_data,
get_user_field_names,
get_user_public_field_names,
)
from tests.helpers.constants import USER_PASSWORD, USERNAME
from tests.helpers.settings import override_rest_regis... | expected_fields | assert | variable | tests/unit_tests/utils/test_users.py | test_get_user_field_names | 35 | null | |
apragacz/django-rest-registration | import pytest
from django.conf import settings
from django.test.utils import override_settings
from rest_registration.api.views.reset_password import ResetPasswordSigner
from tests.helpers.views import ViewProvider
VERIFICATION_URL = "/accounts/reset-password/"
SUCCESS_URL = "/accounts/reset-password/success/"
FAILUR... | SUCCESS_URL | assert | variable | tests/unit_tests/contrib/verification_redirects/test_reset_password.py | test_ok | 25 | null | |
apragacz/django-rest-registration | import datetime
import time
from unittest.mock import patch
from urllib.parse import urlencode
import pytest
from django.core.signing import BadSignature, SignatureExpired
from rest_registration.utils.signers import DataSigner, URLParamsSigner
def test_get_url(unsigned_data, unsigned_data_email):
signer_cls = Ex... | url | assert | variable | tests/unit_tests/utils/test_signers.py | test_get_url | 113 | null | |
apragacz/django-rest-registration | from django.apps import apps
from django.core.checks.registry import registry
from django.test.utils import override_settings
from rest_registration.auth_token_managers import AbstractAuthTokenManager
from rest_registration.checks import ErrorCode, WarningCode
from rest_registration.settings import DEFAULTS
from tests... | [ ErrorCode.NO_TOKEN_AUTH_CONFIG, ]) | assert_* | collection | tests/unit_tests/test_checks.py | test_checks_missing_token_auth_config | 79 | null | |
apragacz/django-rest-registration | from django.apps import apps
from django.core.checks.registry import registry
from django.test.utils import override_settings
from rest_registration.auth_token_managers import AbstractAuthTokenManager
from rest_registration.checks import ErrorCode, WarningCode
from rest_registration.settings import DEFAULTS
from tests... | [ ErrorCode.NO_AUTH_INSTALLED, ]) | assert_* | collection | tests/unit_tests/test_checks.py | test_checks_missing_auth_installed | 103 | null | |
apragacz/django-rest-registration | import pytest
from rest_framework.authtoken.models import Token
from rest_registration.auth_token_managers import RestFrameworkAuthTokenManager
from rest_registration.exceptions import AuthTokenError
def auth_token_manager():
return RestFrameworkAuthTokenManager()
def test_when_no_token_then_revoke_token_fails(
... | AuthTokenError) | pytest.raises | variable | tests/unit_tests/auth_token_managers/test_rest_framework.py | test_when_no_token_then_revoke_token_fails | 21 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
@pytest.mark.asyncio
async def test_run_async_context_thread_isolation(self):
"""Test that threaded execution is properly isolated."""
# Set a... | "isolated" | assert | string_literal | tests/test_utils.py | test_run_async_context_thread_isolation | TestRunAsyncSafely | 82 | null |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
def test_tool_calls_preservation_in_message_placeholder():
"""Test t... | "" | assert | string_literal | tests/test_prompt_compilation.py | test_tool_calls_preservation_in_message_placeholder | 920 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | "2.0" | assert | string_literal | tests/test_propagate_attributes.py | test_baggage_is_set_when_as_baggage_true | TestPropagateAttributesBaggage | 1,604 | null |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_uuid():
uuid = UUID("123e4567-e... | '"123e4567-e89b-12d3-a456-426614174000"' | assert | string_literal | tests/test_serializer.py | test_uuid | 51 | null | |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_preserves_all_settings():
"""Test that get_client() preserves environment and all client settings."""
with LangfuseResourceManager._lock:
... | settings["environment"] | assert | complex_expr | tests/test_resource_manager.py | test_get_client_preserves_all_settings | 29 | null | |
langfuse/langfuse-python | import httpx
from langfuse._client.client import Langfuse
class TestAdditionalHeadersSimple:
def teardown_method(self):
"""Clean up after each test to avoid singleton interference."""
from langfuse._client.resource_manager import LangfuseResourceManager
LangfuseResourceManager.reset()
... | "existing-value" | assert | string_literal | tests/test_additional_headers_simple.py | test_custom_httpx_client_with_additional_headers_ignores_additional_headers | TestAdditionalHeadersSimple | 71 | null |
langfuse/langfuse-python | import httpx
from langfuse._client.client import Langfuse
class TestAdditionalHeadersSimple:
def teardown_method(self):
"""Clean up after each test to avoid singleton interference."""
from langfuse._client.resource_manager import LangfuseResourceManager
LangfuseResourceManager.reset()
... | "trace-value" | assert | string_literal | tests/test_additional_headers_simple.py | test_span_processor_has_additional_headers_in_otel_exporter | TestAdditionalHeadersSimple | 169 | null |
langfuse/langfuse-python | import random
import string
import time
from time import sleep
from typing import Any, Dict, Literal
import pytest
from langchain.messages import HumanMessage, SystemMessage
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langchain_co... | 6 | assert | numeric_literal | tests/test_langchain.py | test_link_langfuse_prompts_batch | 642 | null | |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
def test_basic_replacement():
template = "Hello, {{ name }}!"
ex... | expected | assert | variable | tests/test_prompt_compilation.py | test_basic_replacement | 17 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_enum():
serializer = EventSeria... | "1" | assert | string_literal | tests/test_serializer.py | test_enum | 45 | null | |
langfuse/langfuse-python | import types
import pytest
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langchain_openai import ChatOpenAI, OpenAI
from langfuse import Langfuse
from langfuse.langchain import CallbackHandler
from tests.utils import get_api
from ... | 2 | assert | numeric_literal | tests/test_langchain_integration.py | test_stream_chat_models | 58 | null | |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_multiple_clients_preserve_different_settings():
"""Test that get_client() preserves different settings for multiple clients."""
def should_... | settings_a["timeout"] | assert | complex_expr | tests/test_resource_manager.py | test_get_client_multiple_clients_preserve_different_settings | 85 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_event_loop_detection_mock(self):
"""Test event loop detection logic with mocking."""
async def simple_coro():
return "mocked... | "asyncio_run_called" | assert | string_literal | tests/test_utils.py | test_event_loop_detection_mock | TestRunAsyncSafely | 147 | null |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_exception_types_preserved(self):
"""Test that different exception types are properly preserved."""
async def custom_exception_coro():
... | Exception) | pytest.raises | variable | tests/test_utils.py | test_exception_types_preserved | TestRunAsyncSafely | 203 | null |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_tuple_set_frozenset():
data = (... | "[1, 2, 3]" | assert | string_literal | tests/test_serializer.py | test_tuple_set_frozenset | 81 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_not_serializable():
class NotSe... | '{"lock": "<lock>"}' | assert | string_literal | tests/test_serializer.py | test_not_serializable | 153 | null | |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
class TestLangchainPromptCompilation:
def test_chat_prompt_with_jso... | 2 | assert | numeric_literal | tests/test_prompt_compilation.py | test_chat_prompt_with_json_variables | TestLangchainPromptCompilation | 732 | null |
langfuse/langfuse-python | import random
import string
import time
from time import sleep
from typing import Any, Dict, Literal
import pytest
from langchain.messages import HumanMessage, SystemMessage
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langchain_co... | 0 | assert | numeric_literal | tests/test_langchain.py | test_callback_generated_from_trace_chat | 63 | null | |
langfuse/langfuse-python | import logging
import pytest
from langfuse._utils.error_logging import (
auto_decorate_methods_with,
catch_and_log_errors,
)
def function_that_raises():
raise ValueError("This is a test error.")
def test_catch_and_log_errors_logs_error_silently(caplog):
function_that_raises()
assert len(caplog... | 1 | assert | numeric_literal | tests/test_error_logging.py | test_catch_and_log_errors_logs_error_silently | 20 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_return_types_preserved(self):
"""Test that various return types are properly preserved."""
async def dict_coro():
await asyn... | {"key": "value", "number": 42} | assert | collection | tests/test_utils.py | test_return_types_preserved | TestRunAsyncSafely | 225 | null |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_multiple_clients_preserve_different_settings():
"""Test that get_client() preserves different settings for multiple clients."""
def should_... | settings_b["timeout"] | assert | complex_expr | tests/test_resource_manager.py | test_get_client_multiple_clients_preserve_different_settings | 86 | null | |
langfuse/langfuse-python | import time
from datetime import timedelta
from langfuse import Langfuse
from langfuse.api import DatasetStatus
from tests.utils import create_uuid
def test_get_dataset_with_version():
"""Test that get_dataset correctly filters items by version timestamp."""
langfuse = Langfuse(debug=False)
# Create dat... | 2 | assert | numeric_literal | tests/test_datasets.py | test_get_dataset_with_version | 208 | null | |
langfuse/langfuse-python | import time
from typing import Any, Dict, List
import pytest
from langfuse import get_client
from langfuse.experiment import (
Evaluation,
ExperimentData,
ExperimentItem,
ExperimentItemResult,
)
from tests.utils import create_uuid, get_api
def sample_dataset():
"""Sample dataset for experiments."... | 0 | assert | numeric_literal | tests/test_experiments.py | test_task_failures_handled_gracefully | 338 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://env-host.com" | assert | string_literal | tests/test_initialization.py | test_env_host_fallback | TestClientInitialization | 101 | null |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://base-url.com" | assert | string_literal | tests/test_initialization.py | test_both_base_url_and_host_params | TestClientInitialization | 223 | null |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_multiple_clients_preserve_different_settings():
"""Test that get_client() preserves different settings for multiple clients."""
def should_... | should_export_b | assert | variable | tests/test_resource_manager.py | test_get_client_multiple_clients_preserve_different_settings | 92 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_concurrent_calls_sync_context(self):
"""Test concurrent calls in sync context using threading."""
async def slow_coro(value):
... | [1, 4, 9] | assert | collection | tests/test_utils.py | test_concurrent_calls_sync_context | TestRunAsyncSafely | 131 | null |
langfuse/langfuse-python | import builtins
import importlib
import json
import uuid
from dataclasses import dataclass
from datetime import date, datetime, timezone
from unittest.mock import patch
import pytest
from langchain.messages import HumanMessage
from pydantic import BaseModel
import langfuse
from langfuse._utils.serializer import Event... | '{"foo": "bar", "bar": "2021-01-01T00:00:00Z"}' | assert | string_literal | tests/test_json.py | test_json_decoder_pydantic | 43 | null | |
langfuse/langfuse-python | import base64
import re
from types import SimpleNamespace
from unittest.mock import Mock
from uuid import uuid4
import pytest
from langfuse._client.client import Langfuse
from langfuse.media import LangfuseMedia
from tests.utils import get_api
SAMPLE_JPEG_BYTES = b"\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00H\x... | "image/jpeg" | assert | string_literal | tests/test_media.py | test_init_with_base64_data_uri | 23 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | test_url | assert | variable | tests/test_initialization.py | test_url_used_in_api_client | TestClientInitialization | 196 | null |
langfuse/langfuse-python | from time import sleep
from unittest.mock import Mock, patch
import openai
import pytest
from langfuse._client.client import Langfuse
from langfuse._utils.prompt_cache import (
DEFAULT_PROMPT_CACHE_TTL_SECONDS,
PromptCache,
PromptCacheItem,
)
from langfuse.api import NotFoundError, Prompt_Chat, Prompt_Tex... | 2 | assert | numeric_literal | tests/test_prompt.py | test_get_prompt_by_version_or_label | 622 | null | |
langfuse/langfuse-python | import time
from datetime import timedelta
from langfuse import Langfuse
from langfuse.api import DatasetStatus
from tests.utils import create_uuid
def test_create_and_get_dataset():
langfuse = Langfuse(debug=False)
name = "Text with spaces " + create_uuid()[:5]
langfuse.create_dataset(name=name)
dat... | name | assert | variable | tests/test_datasets.py | test_create_and_get_dataset | 15 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://localhost:3000" | assert | string_literal | tests/test_initialization.py | test_localhost_urls | TestClientInitialization | 245 | null |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://test-host.com" | assert | string_literal | tests/test_initialization.py | test_host_env_var | TestClientInitialization | 132 | null |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_multiple_clients_preserve_different_settings():
"""Test that get_client() preserves different settings for multiple clients."""
def should_... | should_export_a | assert | variable | tests/test_resource_manager.py | test_get_client_multiple_clients_preserve_different_settings | 91 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://env-base-url.com" | assert | string_literal | tests/test_initialization.py | test_env_base_url_takes_precedence_over_host_param | TestClientInitialization | 80 | null |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_circular_reference():
class Nod... | {"next": {"next": "Node"}} | assert | collection | tests/test_serializer.py | test_circular_reference | 139 | null | |
langfuse/langfuse-python | import subprocess
import pytest
@pytest.mark.timeout(10)
def test_prompts_atexit():
python_code = """
import time
import logging
from langfuse.logger import langfuse_logger
from langfuse._utils.prompt_cache import PromptCache
langfuse_logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
handler.setL... | 1 | assert | numeric_literal | tests/test_prompt_atexit.py | test_prompts_atexit | 53 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_date():
d = date(2023, 1, 1)
... | '"2023-01-01"' | assert | string_literal | tests/test_serializer.py | test_date | 40 | null | |
langfuse/langfuse-python | import subprocess
import pytest
@pytest.mark.timeout(10)
def test_prompts_atexit_async():
python_code = """
import time
import asyncio
import logging
from langfuse.logger import langfuse_logger
from langfuse._utils.prompt_cache import PromptCache
langfuse_logger.setLevel(logging.DEBUG)
handler = logging.StreamH... | 3 | assert | numeric_literal | tests/test_prompt_atexit.py | test_prompts_atexit_async | 117 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_run_sync_context_simple(self):
"""Test run_async_safely in sync context with simple coroutine."""
async def simple_coro():
a... | "hello" | assert | string_literal | tests/test_utils.py | test_run_sync_context_simple | TestRunAsyncSafely | 23 | null |
langfuse/langfuse-python | import asyncio
import os
import sys
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Optional
import pytest
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from opentelemetry import trace
from ... | 2 | assert | numeric_literal | tests/test_decorators.py | test_decorators_langchain | 406 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
@pytest.mark.asyncio
async def test_nested_async_calls(self):
"""Test that nested calls to run_async_safely work correctly."""
async def inne... | 11 | assert | numeric_literal | tests/test_utils.py | test_nested_async_calls | TestRunAsyncSafely | 190 | null |
langfuse/langfuse-python | from time import sleep
from unittest.mock import Mock, patch
import openai
import pytest
from langfuse._client.client import Langfuse
from langfuse._utils.prompt_cache import (
DEFAULT_PROMPT_CACHE_TTL_SECONDS,
PromptCache,
PromptCacheItem,
)
from langfuse.api import NotFoundError, Prompt_Chat, Prompt_Tex... | 1 | assert | numeric_literal | tests/test_prompt.py | test_get_prompt_by_version_or_label | 627 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | attributes | assert | variable | tests/test_propagate_attributes.py | verify_missing_attribute | TestPropagateAttributesBase | 74 | null |
langfuse/langfuse-python | import os
import time
from asyncio import gather
from datetime import datetime, timedelta, timezone
from time import sleep
import pytest
from langfuse import Langfuse, propagate_attributes
from langfuse._client.resource_manager import LangfuseResourceManager
from langfuse._utils import _get_timestamp
from tests.api_w... | 1 | assert | numeric_literal | tests/test_core_sdk.py | test_create_numeric_score | 167 | null | |
langfuse/langfuse-python | import os
from langfuse import Langfuse
from langfuse.logger import langfuse_logger
def test_via_env():
os.environ["LANGFUSE_DEBUG"] = "True"
Langfuse()
assert langfuse_logger.level == | 10 | assert | numeric_literal | tests/test_logger.py | test_via_env | 26 | null | |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_preserves_all_settings():
"""Test that get_client() preserves environment and all client settings."""
with LangfuseResourceManager._lock:
... | should_export | assert | variable | tests/test_resource_manager.py | test_get_client_preserves_all_settings | 36 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_return_types_preserved(self):
"""Test that various return types are properly preserved."""
async def dict_coro():
await asyn... | [1, 2, 3, "string"] | assert | collection | tests/test_utils.py | test_return_types_preserved | TestRunAsyncSafely | 229 | null |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_complex_coroutine(self):
"""Test with a more complex coroutine that does actual async work."""
async def complex_coro():
# S... | [0, 1, 4, 0, 10] | assert | collection | tests/test_utils.py | test_complex_coroutine | TestRunAsyncSafely | 172 | null |
langfuse/langfuse-python | import importlib
import os
from time import sleep
import pytest
from pydantic import BaseModel
from langfuse._client.client import Langfuse
from tests.utils import create_uuid, encode_file_to_base64, get_api
langfuse = Langfuse()
def openai():
import openai
from langfuse.openai import openai as _openai
... | 0 | assert | numeric_literal | tests/test_openai.py | test_openai_chat_completion | 46 | null | |
langfuse/langfuse-python | import builtins
import importlib
import json
import uuid
from dataclasses import dataclass
from datetime import date, datetime, timezone
from unittest.mock import patch
import pytest
from langchain.messages import HumanMessage
from pydantic import BaseModel
import langfuse
from langfuse._utils.serializer import Event... | result | assert | variable | tests/test_json.py | test_json_encoder | 35 | null | |
langfuse/langfuse-python | import asyncio
import os
import sys
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Optional
import pytest
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from opentelemetry import trace
from ... | 1 | assert | numeric_literal | tests/test_decorators.py | test_scoring_observations | 530 | null | |
langfuse/langfuse-python | import logging
import pytest
from langfuse._utils.error_logging import (
auto_decorate_methods_with,
catch_and_log_errors,
)
def function_that_raises():
raise ValueError("This is a test error.")
def test_auto_decorate_class_methods(caplog):
test_obj = TestClass()
# Test the instance method
... | ValueError, match="Error in instance method.") | pytest.raises | complex_expr | tests/test_error_logging.py | test_auto_decorate_class_methods | 66 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_dataclass():
dc = TestDataclass... | {"field": "test"} | assert | collection | tests/test_serializer.py | test_dataclass | 63 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://test-base-url.com" | assert | string_literal | tests/test_initialization.py | test_base_url_env_var | TestClientInitialization | 121 | null |
langfuse/langfuse-python | from queue import Queue
from types import SimpleNamespace
from unittest.mock import Mock
import httpx
import pytest
from langfuse._task_manager.media_manager import MediaManager
def _upload_response(status_code: int, text: str = "") -> httpx.Response:
request = httpx.Request("PUT", "https://example.com/upload")
... | 200 | assert | numeric_literal | tests/test_media_manager.py | test_media_upload_retries_on_retryable_http_status | 54 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
@pytest.mark.asyncio
async def test_multiple_calls_async_context(self):
"""Test multiple sequential calls in async context (each uses threading)."""
... | [0, 3, 6] | assert | collection | tests/test_utils.py | test_multiple_calls_async_context | TestRunAsyncSafely | 111 | null |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_preserves_all_settings():
"""Test that get_client() preserves environment and all client settings."""
with LangfuseResourceManager._lock:
... | None | assert | none_literal | tests/test_resource_manager.py | test_get_client_preserves_all_settings | 31 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_path():
path = Path("/tmp/test.... | '"/tmp/test.txt"' | assert | string_literal | tests/test_serializer.py | test_path | 75 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
@pytest.mark.asyncio
async def test_run_async_context_simple(self):
"""Test run_async_safely from within async context (uses threading)."""
a... | "from_thread" | assert | string_literal | tests/test_utils.py | test_run_async_context_simple | TestRunAsyncSafely | 55 | null |
langfuse/langfuse-python | import builtins
import importlib
import json
import uuid
from dataclasses import dataclass
from datetime import date, datetime, timezone
from unittest.mock import patch
import pytest
from langchain.messages import HumanMessage
from pydantic import BaseModel
import langfuse
from langfuse._utils.serializer import Event... | '"ERROR"' | assert | string_literal | tests/test_json.py | test_observation_level | 131 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | 0 | assert | numeric_literal | tests/test_propagate_attributes.py | get_span_by_name | TestPropagateAttributesBase | 60 | null |
langfuse/langfuse-python | from langfuse import Langfuse
from langfuse._client.get_client import get_client
from langfuse._client.resource_manager import LangfuseResourceManager
def test_get_client_multiple_clients_preserve_different_settings():
"""Test that get_client() preserves different settings for multiple clients."""
def should_... | settings_a["release"] | assert | complex_expr | tests/test_resource_manager.py | test_get_client_multiple_clients_preserve_different_settings | 89 | null | |
langfuse/langfuse-python | import os
import time
from asyncio import gather
from datetime import datetime, timedelta, timezone
from time import sleep
import pytest
from langfuse import Langfuse, propagate_attributes
from langfuse._client.resource_manager import LangfuseResourceManager
from langfuse._utils import _get_timestamp
from tests.api_w... | 2 | assert | numeric_literal | tests/test_core_sdk.py | test_create_trace_and_span | 835 | null | |
langfuse/langfuse-python | from types import SimpleNamespace
from typing import Any, Optional
from langfuse.span_filter import (
is_default_export_span,
is_genai_span,
is_known_llm_instrumentor,
is_langfuse_span,
)
def _make_span(
*,
scope_name: Optional[str] = None,
attributes: Optional[dict[Any, Any]] = None,
):
... | False | assert | bool_literal | tests/test_span_filter.py | test_is_langfuse_span_false | 30 | null | |
langfuse/langfuse-python | import asyncio
import time
import pytest
from langfuse import get_client, propagate_attributes
from langfuse.batch_evaluation import (
BatchEvaluationResult,
BatchEvaluationResumeToken,
EvaluatorInputs,
EvaluatorStats,
)
from langfuse.experiment import Evaluation
from tests.utils import create_uuid
d... | 0 | assert | numeric_literal | tests/test_batch_evaluation.py | test_run_batched_evaluation_on_observations_basic | 82 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_none():
serializer = EventSeria... | "null" | assert | string_literal | tests/test_serializer.py | test_none | 164 | null | |
langfuse/langfuse-python | import builtins
import importlib
import json
import uuid
from dataclasses import dataclass
from datetime import date, datetime, timezone
from unittest.mock import patch
import pytest
from langchain.messages import HumanMessage
from pydantic import BaseModel
import langfuse
from langfuse._utils.serializer import Event... | default | assert | variable | tests/test_json.py | test_json_decoder_without_langchain_serializer_with_none | 101 | null | |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
def test_tool_calls_preservation_in_message_placeholder():
"""Test t... | "tool" | assert | string_literal | tests/test_prompt_compilation.py | test_tool_calls_preservation_in_message_placeholder | 927 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
@pytest.mark.asyncio
async def test_run_async_context_with_exception(self):
"""Test run_async_safely properly propagates exceptions from thread."""
... | RuntimeError, match="Thread error") | pytest.raises | complex_expr | tests/test_utils.py | test_run_async_context_with_exception | TestRunAsyncSafely | 65 | null |
langfuse/langfuse-python | import importlib
import os
from time import sleep
import pytest
from pydantic import BaseModel
from langfuse._client.client import Langfuse
from tests.utils import create_uuid, encode_file_to_base64, get_api
langfuse = Langfuse()
def openai():
import openai
from langfuse.openai import openai as _openai
... | 2 | assert | numeric_literal | tests/test_openai.py | test_openai_chat_completion_stream | 123 | null | |
langfuse/langfuse-python | import os
import pytest
from langfuse import Langfuse
from langfuse._client.resource_manager import LangfuseResourceManager
class TestClientInitialization:
def cleanup_env_vars(self):
"""Fixture to clean up environment variables and singleton cache before and after each test."""
# Store original... | "http://test.com/api/v1" | assert | string_literal | tests/test_initialization.py | test_urls_with_paths | TestClientInitialization | 281 | null |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
def test_tool_calls_preservation_in_message_placeholder():
"""Test t... | 5 | assert | numeric_literal | tests/test_prompt_compilation.py | test_tool_calls_preservation_in_message_placeholder | 908 | null | |
langfuse/langfuse-python | import time
from datetime import timedelta
from langfuse import Langfuse
from langfuse.api import DatasetStatus
from tests.utils import create_uuid
def test_get_all_items():
langfuse = Langfuse(debug=False)
name = create_uuid()
langfuse.create_dataset(name=name)
input = {"input": "Hello World"}
f... | 99 | assert | numeric_literal | tests/test_datasets.py | test_get_all_items | 82 | null | |
langfuse/langfuse-python | import builtins
import importlib
import json
import uuid
from dataclasses import dataclass
from datetime import date, datetime, timezone
from unittest.mock import patch
import pytest
from langchain.messages import HumanMessage
from pydantic import BaseModel
import langfuse
from langfuse._utils.serializer import Event... | ImportError) | pytest.raises | variable | tests/test_json.py | test_json_decoder_without_langchain_serializer_with_langchain_message | 77 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | 2 | assert | numeric_literal | tests/test_propagate_attributes.py | test_experiment_attributes_propagate_without_dataset | TestPropagateAttributesExperiment | 2,398 | null |
langfuse/langfuse-python | import asyncio
import os
import sys
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Optional
import pytest
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from opentelemetry import trace
from ... | 4 | assert | numeric_literal | tests/test_decorators.py | test_decorated_class_and_instance_methods | 665 | null | |
langfuse/langfuse-python | import asyncio
import os
import sys
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Optional
import pytest
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from opentelemetry import trace
from ... | 3 | assert | numeric_literal | tests/test_decorators.py | test_nested_observations | 79 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | "v3" | assert | string_literal | tests/test_propagate_attributes.py | test_multiple_metadata_keys_independent | TestPropagateAttributesFormat | 932 | null |
langfuse/langfuse-python | import asyncio
import time
import pytest
from langfuse import get_client, propagate_attributes
from langfuse.batch_evaluation import (
BatchEvaluationResult,
BatchEvaluationResumeToken,
EvaluatorInputs,
EvaluatorStats,
)
from langfuse.experiment import Evaluation
from tests.utils import create_uuid
d... | 1 | assert | numeric_literal | tests/test_batch_evaluation.py | test_run_batched_evaluation_on_observations_basic | 90 | null | |
langfuse/langfuse-python | import json
from datetime import datetime
from hashlib import sha256
from typing import List, Sequence
import pytest
from opentelemetry import trace as trace_api
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import ReadableSpan, TracerProvider
from opentelemetry.sdk.trace.export import ... | 0 | assert | numeric_literal | tests/test_otel.py | test_update_current_span_name | TestBasicSpans | 339 | null |
langfuse/langfuse-python | import pytest
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langfuse.api import ChatMessage, Prompt_Chat
from langfuse.model import (
ChatPromptClient,
Prompt_Text,
TemplateParser,
TextPromptClient,
)
def test_tool_calls_preservation_in_message_placeholder():
"""Test t... | "user" | assert | string_literal | tests/test_prompt_compilation.py | test_tool_calls_preservation_in_message_placeholder | 915 | null | |
langfuse/langfuse-python | import concurrent.futures
import time
from datetime import datetime
import pytest
from opentelemetry.instrumentation.threading import ThreadingInstrumentor
from langfuse import propagate_attributes
from langfuse._client.attributes import LangfuseOtelSpanAttributes, _serialize
from langfuse._client.constants import LA... | "session_abc" | assert | string_literal | tests/test_propagate_attributes.py | test_session_id_uses_correct_attribute_name | TestPropagateAttributesFormat | 892 | null |
langfuse/langfuse-python | import os
import time
from asyncio import gather
from datetime import datetime, timedelta, timezone
from time import sleep
import pytest
from langfuse import Langfuse, propagate_attributes
from langfuse._client.resource_manager import LangfuseResourceManager
from langfuse._utils import _get_timestamp
from tests.api_w... | 0 | assert | numeric_literal | tests/test_core_sdk.py | test_create_categorical_score | 277 | null | |
langfuse/langfuse-python | import httpx
from langfuse._client.client import Langfuse
class TestAdditionalHeadersSimple:
def teardown_method(self):
"""Clean up after each test to avoid singleton interference."""
from langfuse._client.resource_manager import LangfuseResourceManager
LangfuseResourceManager.reset()
... | "custom-value" | assert | string_literal | tests/test_additional_headers_simple.py | test_httpx_client_has_additional_headers_when_none_provided | TestAdditionalHeadersSimple | 36 | null |
langfuse/langfuse-python | import types
import pytest
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
from langchain_openai import ChatOpenAI, OpenAI
from langfuse import Langfuse
from langfuse.langchain import CallbackHandler
from tests.utils import get_api
from ... | 3 | assert | numeric_literal | tests/test_langchain_integration.py | test_batch_in_completions_models | 263 | null | |
langfuse/langfuse-python | import time
from typing import Any, Dict, List
import pytest
from langfuse import get_client
from langfuse.experiment import (
Evaluation,
ExperimentData,
ExperimentItem,
ExperimentItemResult,
)
from tests.utils import create_uuid, get_api
def sample_dataset():
"""Sample dataset for experiments."... | 2 | assert | numeric_literal | tests/test_experiments.py | test_run_experiment_on_local_dataset | 89 | null | |
langfuse/langfuse-python | import json
import threading
from dataclasses import dataclass
from datetime import date, datetime, timezone
from enum import Enum
from pathlib import Path
from uuid import UUID
from pydantic import BaseModel
from langfuse._utils.serializer import (
EventSerializer,
)
def test_bytes():
b = b"hello"
seria... | '"hello"' | assert | string_literal | tests/test_serializer.py | test_bytes | 57 | null | |
langfuse/langfuse-python | import asyncio
import threading
from unittest import mock
import pytest
from langfuse._client.utils import run_async_safely
class TestRunAsyncSafely:
def test_exception_types_preserved(self):
"""Test that different exception types are properly preserved."""
async def custom_exception_coro():
... | str(exc_info.value) | assert | func_call | tests/test_utils.py | test_exception_types_preserved | TestRunAsyncSafely | 207 | null |
langfuse/langfuse-python | import asyncio
import os
import sys
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from time import sleep
from typing import Optional
import pytest
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from opentelemetry import trace
from ... | 0 | assert | numeric_literal | tests/test_decorators.py | test_nested_observations | 111 | null | |
langfuse/langfuse-python | import time
from datetime import timedelta
from langfuse import Langfuse
from langfuse.api import DatasetStatus
from tests.utils import create_uuid
def test_create_dataset_item():
langfuse = Langfuse(debug=False)
name = create_uuid()
langfuse.create_dataset(name=name)
generation = langfuse.start_obse... | None | assert | none_literal | tests/test_datasets.py | test_create_dataset_item | 54 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.