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 |
|---|---|---|---|---|---|---|---|---|---|
llm-workflow-engine/llm-workflow-engine | from unittest.mock import patch
import pytest
import os
from datetime import datetime
from lwe.core.util import (
introspect_commands,
command_with_leader,
merge_dicts,
underscore_to_dash,
dash_to_underscore,
list_to_completion_hash,
float_range_to_completions,
validate_int,
validat... | 5.5 | assert | numeric_literal | tests/unit/test_util.py | test_validate_float | TestClass | 112 | null |
llm-workflow-engine/llm-workflow-engine | import copy
from lwe.backends.api.database import Database
from lwe.backends.api.orm import Orm, Manager
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
from ..base import (
TEST_BASIC_MESSAGES,
TEST_TOOL_CALL_RESPONSE_MESSAGES,
)
def make_conversation_storage_manager(
... | "test" | assert | string_literal | tests/integration/test_conversation_storage_manager.py | test_store_conversation_messages_without_current_user | 95 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock
from lwe.core import constants
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
def make_conversation_storage_manager(
test_config,
tool_manager,
provider_manager,
current_user=None,
conversation_id=None,
preset_name=None,
):
... | "user" | assert | string_literal | tests/unit/test_conversation_storage_manager.py | test_add_message | 143 | null | |
llm-workflow-engine/llm-workflow-engine | import logging
from langchain_core.messages import AIMessage, HumanMessage
from ..base import (
store_conversation_threads,
fake_llm_responses,
)
from lwe import ApiBackend
from lwe.core import constants
DEBUG = False
def make_api_backend(test_config, user_id=1):
if user_id is not None:
test_co... | 5 | assert | numeric_literal | tests/system/test_api_backend.py | test_api_backend_messages_list_creates_valid_conversation_and_messages | 113 | null | |
llm-workflow-engine/llm-workflow-engine | import pytest
from lwe.core.token_manager import TokenManager
from ..base import make_provider
def make_token_manager(test_config, tool_cache, provider_manager, provider=None, model_name=None):
if not provider:
provider = make_provider(provider_manager)
if not model_name:
model_name = getattr(... | 30 | assert | numeric_literal | tests/unit/test_token_manager.py | test_get_num_tokens_from_messages | 63 | null | |
llm-workflow-engine/llm-workflow-engine | import copy
from lwe.backends.api.database import Database
from lwe.backends.api.orm import Orm, Manager
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
from ..base import (
TEST_BASIC_MESSAGES,
TEST_TOOL_CALL_RESPONSE_MESSAGES,
)
def make_conversation_storage_manager(
... | None | assert | none_literal | tests/integration/test_conversation_storage_manager.py | test_store_conversation_messages_new_messages_with_current_user | 46 | null | |
llm-workflow-engine/llm-workflow-engine | import logging
from langchain_core.messages import AIMessage, HumanMessage
from ..base import (
store_conversation_threads,
fake_llm_responses,
)
from lwe import ApiBackend
from lwe.core import constants
DEBUG = False
def make_api_backend(test_config, user_id=1):
if user_id is not None:
test_co... | True | assert | bool_literal | tests/system/test_api_backend.py | test_api_backend_with_files | 613 | null | |
llm-workflow-engine/llm-workflow-engine | import pytest
from unittest.mock import Mock
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from ..base import (
fake_llm_responses,
make_api_request,
# TEST_BASIC_MESSAGES,
# TEST_TOOL_CALL_RESPONSE_MESSAGES,
)
def test_post_response_full_tool_run(test_config, tool_manage... | None | assert | none_literal | tests/integration/test_request.py | test_post_response_full_tool_run | 234 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock
from lwe.core import constants
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
def make_conversation_storage_manager(
test_config,
tool_manager,
provider_manager,
current_user=None,
conversation_id=None,
preset_name=None,
):
... | message_mock | assert | variable | tests/unit/test_conversation_storage_manager.py | test_add_new_messages_to_conversation | 126 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock
from lwe.core import constants
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
def make_conversation_storage_manager(
test_config,
tool_manager,
provider_manager,
current_user=None,
conversation_id=None,
preset_name=None,
):
... | messages | assert | variable | tests/unit/test_conversation_storage_manager.py | test_get_conversation_token_count | 163 | null | |
llm-workflow-engine/llm-workflow-engine | import pytest
from lwe.core.token_manager import TokenManager
from ..base import make_provider
def make_token_manager(test_config, tool_cache, provider_manager, provider=None, model_name=None):
if not provider:
provider = make_provider(provider_manager)
if not model_name:
model_name = getattr(... | 381 | assert | numeric_literal | tests/unit/test_token_manager.py | test_get_num_tokens_from_messages_with_tool | 110 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import patch
import pytest
import os
from datetime import datetime
from lwe.core.util import (
introspect_commands,
command_with_leader,
merge_dicts,
underscore_to_dash,
dash_to_underscore,
list_to_completion_hash,
float_range_to_completions,
validate_int,
validat... | "123" | assert | string_literal | tests/unit/test_util.py | test_validate_str | TestClass | 120 | null |
llm-workflow-engine/llm-workflow-engine | import copy
import pytest
from unittest.mock import Mock, patch
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage, SystemMessage
from lwe.core import constants
from lwe.core import util
from lwe.core.token_manager import TokenManager
from lwe.backends.api.request import ApiRequest # noqa: ... | 3 | assert | numeric_literal | tests/unit/test_request.py | test_attach_files_multiple_files | 695 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock
from lwe.core import constants
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
def make_conversation_storage_manager(
test_config,
tool_manager,
provider_manager,
current_user=None,
conversation_id=None,
preset_name=None,
):
... | "test" | assert | string_literal | tests/unit/test_conversation_storage_manager.py | test_add_message | 144 | null | |
llm-workflow-engine/llm-workflow-engine | import logging
from langchain_core.messages import AIMessage, HumanMessage
from ..base import (
store_conversation_threads,
fake_llm_responses,
)
from lwe import ApiBackend
from lwe.core import constants
DEBUG = False
def make_api_backend(test_config, user_id=1):
if user_id is not None:
test_co... | None | assert | none_literal | tests/system/test_api_backend.py | test_api_backend_non_streaming_valid_response_no_user | 52 | null | |
llm-workflow-engine/llm-workflow-engine | import pytest
from unittest.mock import Mock
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from ..base import (
fake_llm_responses,
make_api_request,
# TEST_BASIC_MESSAGES,
# TEST_TOOL_CALL_RESPONSE_MESSAGES,
)
def test_post_response_multiple_tool_calls_in_parallel(
t... | 6 | assert | numeric_literal | tests/integration/test_request.py | test_post_response_multiple_tool_calls_in_parallel | 715 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock, patch
import os
import yaml
from jinja2 import Environment, Template
from ..base import (
make_template_file,
)
from lwe.core.template_manager import TemplateManager
def remove_template_file(template_manager, template_name):
template_dir = template_manager.user_template_dirs... | False | assert | bool_literal | tests/unit/test_template_manager.py | test_ensure_template | 45 | null | |
llm-workflow-engine/llm-workflow-engine | from unittest.mock import Mock
from lwe.core import constants
from lwe.backends.api.conversation_storage_manager import ConversationStorageManager
def make_conversation_storage_manager(
test_config,
tool_manager,
provider_manager,
current_user=None,
conversation_id=None,
preset_name=None,
):
... | test_config | assert | variable | tests/unit/test_conversation_storage_manager.py | test_init | 30 | null | |
taskiq-python/taskiq | from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo
import pytest
from taskiq.cli.scheduler.run import CronValueError, is_cron_task_now
@pytest.mark.parametrize(
"cron_value,now,offset,last_run,expected",
[
("* * * * *", datetime(2023, 1, 1, 0, 0, 30), None, None, True),
... | expected | assert | variable | tests/cli/scheduler/test_is_cron_task_now.py | test_is_cron_task_now | 72 | null | |
taskiq-python/taskiq | import asyncio
import uuid
import pytest
from taskiq import InMemoryBroker
from taskiq.events import TaskiqEvents
from taskiq.state import TaskiqState
async def test_cannot_listen() -> None:
broker = InMemoryBroker()
with pytest.raises( | RuntimeError) | pytest.raises | variable | tests/brokers/test_inmemory.py | test_cannot_listen | 28 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | repr | assert | variable | tests/test_serialization.py | test_representable | 80 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | 1 | assert | numeric_literal | tests/receiver/test_receiver.py | test_run_task_successful_async | 65 | null | |
taskiq-python/taskiq | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from freezegun import freeze_time
from taskiq.brokers.inmemory_broker import InMemoryBroker
from taskiq.cli.scheduler.args import SchedulerArgs
from taskiq.cli.scheduler.run import run_scheduler
from taskiq.schedule... | [[2], [3]] | assert | collection | tests/scheduler/test_label_based_sched.py | test_task_scheduled_at_time_runs_only_once | 118 | null | |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | SpanKind.PRODUCER) | self.assertEqual | complex_expr | tests/opentelemetry/test_tasks.py | test_task | TestTaskiqInstrumentation | 66 | null |
taskiq-python/taskiq | from typing import Any
from unittest.mock import AsyncMock
import pytest
from taskiq.exceptions import ResultIsReadyError, TaskiqResultTimeoutError
from taskiq.funcs import gather
from taskiq.task import AsyncTaskiqTask
async def test_gather_timeout() -> None:
"""Tests how gather works if timeout is reached."""
... | TaskiqResultTimeoutError) | pytest.raises | variable | tests/test_funcs.py | test_gather_timeout | 31 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | "some value" | assert | string_literal | tests/receiver/test_receiver.py | test_result | 444 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_result_raise_for_error_exc() -> None:
error = ValueError("Error")
res: TaskiqResult[None] = TaskiqResult(
is_err=True,
return_value=None,
execution_time=0,
... | res.error | assert | complex_expr | tests/test_result.py | test_result_raise_for_error_exc | 81 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | error | assert | variable | tests/test_serialization.py | test_pickle_infinite_loop | 184 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_json_serialization() -> None:
task: TaskiqResult[str] = TaskiqResult(
is_err=False,
return_value="some value",
execution_time=0,
)
data = json.loads(model_dum... | task.return_value | assert | complex_expr | tests/test_result.py | test_json_serialization | 17 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_loadb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.loadb(b"null") is | None | assert | none_literal | tests/serializers/test_json_serializer.py | test_json_loadb | 17 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | None | assert | none_literal | tests/receiver/test_receiver.py | test_run_task_exception | 107 | null | |
taskiq-python/taskiq | import json
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import BrokerMessage, TaskiqMessage
async def test_json_dumps() -> None:
fmt = JSONFormatter()
msg = TaskiqMessage(
task_id="task-id",
task_name="task.name",
labels={"label1": 1, "label2": "text"... | expected.labels | assert | complex_expr | tests/formatters/test_json_formatter.py | test_json_dumps | 30 | null | |
taskiq-python/taskiq | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from freezegun import freeze_time
from taskiq.brokers.inmemory_broker import InMemoryBroker
from taskiq.cli.scheduler.args import SchedulerArgs
from taskiq.cli.scheduler.run import run_scheduler
from taskiq.schedule... | [ ScheduledTask( schedule_id=schedule_label[0].get("schedule_id", schedules[0].schedule_id), cron=schedule_label[0].get("cron"), time=schedule_label[0].get("time"), task_name="test_task", labels=schedule_label[0].get("labels", {}), args=[], kwargs={}, ), ] | assert | collection | tests/scheduler/test_label_based_sched.py | test_label_discovery | 44 | null | |
taskiq-python/taskiq | from contextlib import suppress
from pathlib import Path
from unittest.mock import patch
from taskiq.cli.utils import import_tasks
def test_import_tasks_list_pattern() -> None:
modules = ["taskiq.tasks"]
with patch("taskiq.cli.utils.import_from_modules", autospec=True) as mock:
import_tasks(modules, [... | { "taskiq.tasks", "tests.test_utils", "tests.cli.test_utils", } | assert | collection | tests/cli/test_utils.py | test_import_tasks_list_pattern | 12 | null | |
taskiq-python/taskiq | from concurrent.futures import ThreadPoolExecutor
from typing import Any
import pytest
from pydantic import ValidationError
from taskiq import (
AsyncTaskiqDecoratedTask,
InMemoryBroker,
TaskiqDepends,
TaskiqMessage,
)
from taskiq.abc import AsyncBroker
from taskiq.depends.progress_tracker import Prog... | ValidationError) | pytest.raises | variable | tests/depends/test_progress_tracker.py | test_progress_tracker_validation_error | 114 | null | |
taskiq-python/taskiq | import json
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import BrokerMessage, TaskiqMessage
async def test_json_dumps() -> None:
fmt = JSONFormatter()
msg = TaskiqMessage(
task_id="task-id",
task_name="task.name",
labels={"label1": 1, "label2": "text"... | json.loads(expected.message) | assert | func_call | tests/formatters/test_json_formatter.py | test_json_dumps | 31 | null | |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | 2) | self.assertEqual | numeric_literal | tests/opentelemetry/test_tasks.py | test_task | TestTaskiqInstrumentation | 40 | null |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | result.return_value) | self.assertTrue | complex_expr | tests/opentelemetry/test_tasks.py | test_task_not_instrumented_does_not_raise | TestTaskiqInstrumentation | 199 | null |
taskiq-python/taskiq | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from freezegun import freeze_time
from taskiq.brokers.inmemory_broker import InMemoryBroker
from taskiq.cli.scheduler.args import SchedulerArgs
from taskiq.cli.scheduler.run import run_scheduler
from taskiq.schedule... | [] | assert | collection | tests/scheduler/test_label_based_sched.py | test_label_discovery_no_cron | 74 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | 11 | assert | numeric_literal | tests/receiver/test_receiver.py | test_custom_ctx | 388 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | "Raise Custom Message" | assert | string_literal | tests/test_serialization.py | test_exception_to_python_when_attribute_exception | 249 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_loadb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.loadb(b"null") is None
assert serizalizer.loadb(b"1") == 1
assert serizalizer.loadb(b'"a"') == "a"
assert serizalizer.loadb(b'["a"]') == ["a"... | {"a": "b"} | assert | collection | tests/serializers/test_json_serializer.py | test_json_loadb | 21 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_dumpb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.dumpb(None) == b"null"
assert serizalizer.dumpb(1) == b"1"
assert serizalizer.dumpb("a") == b'"a"'
assert serizalizer.dumpb(["a"]) == | b'["a"]' | assert | string_literal | tests/serializers/test_json_serializer.py | test_json_dumpb | 11 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | mock_span.is_recording.called) | self.assertTrue | complex_expr | tests/opentelemetry/test_helpers.py | test_set_attributes_not_recording | TestUtils | 58 | null |
taskiq-python/taskiq | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from freezegun import freeze_time
from taskiq.brokers.inmemory_broker import InMemoryBroker
from taskiq.cli.scheduler.args import SchedulerArgs
from taskiq.cli.scheduler.run import run_scheduler
from taskiq.schedule... | asyncio.TimeoutError) | pytest.raises | complex_expr | tests/scheduler/test_label_based_sched.py | test_task_scheduled_at_time_runs_only_once | 113 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | ValueError | assert | variable | tests/receiver/test_receiver.py | test_run_task_exception_middlewares | 186 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | "6") | self.assertEqual | string_literal | tests/opentelemetry/test_helpers.py | test_set_attributes_from_context | TestUtils | 35 | null |
taskiq-python/taskiq | import inspect
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.compat import model_copy
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def test_parse_params_no_signature() -> None:
"... | src_msg | assert | variable | tests/cli/worker/test_parameters_parsing.py | test_parse_params_no_signature | 38 | null | |
taskiq-python/taskiq | import datetime
import uuid
from typing import Any
import pytest
from taskiq.abc.serializer import TaskiqSerializer
from taskiq.serializers import (
CBORSerializer,
JSONSerializer,
MSGPackSerializer,
ORJSONSerializer,
PickleSerializer,
)
@pytest.mark.parametrize(
"serializer",
[
C... | now | assert | variable | tests/serializers/test_serializers.py | test_datetime_serialization | 65 | null | |
taskiq-python/taskiq | from datetime import datetime, timezone
from zoneinfo import ZoneInfo
import pytest
from taskiq.cli.scheduler.run import to_tz_aware
@pytest.mark.parametrize(
"input_time,expected_tz",
[
(datetime(2023, 1, 1), timezone.utc),
(
datetime(2023, 1, 1, tzinfo=ZoneInfo("US/Eastern")),
... | expected_tz | assert | variable | tests/cli/scheduler/test_to_tz_aware.py | test_to_tz_aware | 24 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | 2 | assert | numeric_literal | tests/receiver/test_receiver.py | test_run_timeouts | 128 | null | |
taskiq-python/taskiq | import pytest
from taskiq.scheduler.scheduled_task import ScheduledTask
def test_scheduled_task_parameters() -> None:
with pytest.raises( | ValueError) | pytest.raises | variable | tests/scheduler/test_scheduled_task.py | test_scheduled_task_parameters | 7 | null | |
taskiq-python/taskiq | from datetime import datetime, timedelta, timezone
import pytest
from taskiq.cli.scheduler.run import is_time_task_now
@pytest.mark.parametrize(
"time_value,now,last_run,expected",
[
(datetime(2023, 1, 1), datetime(2023, 1, 2), None, True),
(datetime(2023, 1, 1), datetime(2023, 1, 1), None, T... | expected | assert | variable | tests/cli/scheduler/test_is_time_task_now.py | test_is_time_task_now | 50 | null | |
taskiq-python/taskiq | import logging
import sys
from io import StringIO
from taskiq.cli.worker.log_collector import log_collector
def test_log_collector_std_success() -> None:
"""Tests that stdout and stderr calls are collected correctly."""
log = StringIO()
with log_collector(log, "%(message)s"):
print("log1") # noqa... | "log1\nlog2\n" | assert | string_literal | tests/cli/worker/test_log_collector.py | test_log_collector_std_success | 14 | null | |
taskiq-python/taskiq | import asyncio
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind, StatusCode
from taskiq import InMemoryBroker
from taskiq.instrumentation import TaskiqInstrumentor
class TestTaskiqAutoInstrumentation(TestBase):
def test_auto_instrument(self) -> None:
TaskiqInstru... | SpanKind.PRODUCER) | self.assertEqual | complex_expr | tests/opentelemetry/test_auto_instrumentation.py | test_auto_instrument | TestTaskiqAutoInstrumentation | 53 | null |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | SpanKind.CONSUMER) | self.assertEqual | complex_expr | tests/opentelemetry/test_tasks.py | test_task | TestTaskiqInstrumentation | 49 | null |
taskiq-python/taskiq | import asyncio
from datetime import datetime, timedelta, timezone
from typing import Any
import pytest
from freezegun import freeze_time
from taskiq.brokers.inmemory_broker import InMemoryBroker
from taskiq.cli.scheduler.args import SchedulerArgs
from taskiq.cli.scheduler.run import run_scheduler
from taskiq.schedule... | {"schedule": schedule_label} | assert | collection | tests/scheduler/test_label_based_sched.py | test_label_discovery | 58 | null | |
taskiq-python/taskiq | from collections.abc import AsyncGenerator
from taskiq.abc.broker import AsyncBroker
from taskiq.decor import AsyncTaskiqDecoratedTask
from taskiq.message import BrokerMessage
def test_decorator_with_name_success() -> None:
"""Test that task_name is successfully set."""
tbrok = _TestBroker()
@tbrok.task(... | "my_task" | assert | string_literal | tests/abc/test_broker.py | test_decorator_with_name_success | 48 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | "30") | self.assertEqual | string_literal | tests/opentelemetry/test_helpers.py | test_set_attributes_from_context | TestUtils | 34 | null |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | text | assert | variable | tests/test_serialization.py | test_json_context | 299 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | max_async_tasks | assert | variable | tests/receiver/test_receiver.py | test_callback_semaphore | 411 | null | |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | True | assert | bool_literal | tests/receiver/test_receiver.py | test_sync_decorator_on_async_function | 546 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | opentelemetry_middleware.attach_context(None, span, mock.Mock(), "")) | self.assertIsNone | func_call | tests/opentelemetry/test_helpers.py | test_optional_message_span_attach | TestUtils | 102 | null |
taskiq-python/taskiq | import inspect
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.compat import model_copy
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
@pytest.mark.parametrize("test_class", [_TestPydant... | None | assert | none_literal | tests/cli/worker/test_parameters_parsing.py | test_parse_params_nones | 140 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_json_error_serialization() -> None:
try:
raise ValueError("Omg", [1, 2, 3])
except Exception as exc:
error = exc
task: TaskiqResult[int] = TaskiqResult(
is_e... | args[0] | assert | complex_expr | tests/test_result.py | test_json_error_serialization | 46 | null | |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | {} | assert | collection | tests/receiver/test_params_parser.py | test_primitive_args_success | 34 | null | |
taskiq-python/taskiq | from concurrent.futures import ThreadPoolExecutor
from typing import Any
import pytest
from pydantic import ValidationError
from taskiq import (
AsyncTaskiqDecoratedTask,
InMemoryBroker,
TaskiqDepends,
TaskiqMessage,
)
from taskiq.abc import AsyncBroker
from taskiq.depends.progress_tracker import Prog... | meta | assert | variable | tests/depends/test_progress_tracker.py | test_progress_tracker_ctx_raw | 80 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | mock_span.set_status.called) | self.assertFalse | complex_expr | tests/opentelemetry/test_helpers.py | test_set_attributes_not_recording | TestUtils | 60 | null |
taskiq-python/taskiq | import uuid
from unittest.mock import AsyncMock
import pytest
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import TaskiqMessage
from taskiq.middlewares.simple_retry_middleware import SimpleRetryMiddleware
from taskiq.result import TaskiqResult
def broker() -> AsyncMock:
mocked_b... | "meme" | assert | string_literal | tests/middlewares/test_simple_retry.py | test_successful_retry | 37 | null | |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | StatusCode.UNSET) | self.assertEqual | complex_expr | tests/opentelemetry/test_tasks.py | test_task | TestTaskiqInstrumentation | 58 | null |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_json_error_serialization() -> None:
try:
raise ValueError("Omg", [1, 2, 3])
except Exception as exc:
error = exc
task: TaskiqResult[int] = TaskiqResult(
is_e... | args[1] | assert | complex_expr | tests/test_result.py | test_json_error_serialization | 47 | null | |
taskiq-python/taskiq | from datetime import datetime
from taskiq import InMemoryBroker, ScheduleSource
from taskiq.cli.scheduler.run import get_all_schedules
from taskiq.scheduler.scheduled_task import ScheduledTask
from taskiq.scheduler.scheduler import TaskiqScheduler
async def test_get_schedules_error() -> None:
"""Tests that if sou... | [ (source1, source1.schedules), (source2, []), ] | assert | collection | tests/cli/scheduler/test_updater.py | test_get_schedules_error | 79 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_dumpb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.dumpb(None) == | b"null" | assert | string_literal | tests/serializers/test_json_serializer.py | test_json_dumpb | 8 | null | |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | {"key": "value"}) | self.assertEqual | collection | tests/opentelemetry/test_tasks.py | test_baggage | TestTaskiqInstrumentation | 165 | null |
taskiq-python/taskiq | from datetime import datetime
from taskiq import InMemoryBroker, ScheduleSource
from taskiq.cli.scheduler.run import get_all_schedules
from taskiq.scheduler.scheduled_task import ScheduledTask
from taskiq.scheduler.scheduler import TaskiqScheduler
async def test_get_schedules_success() -> None:
"""Tests that sche... | [ (sources[0], schedules1), (sources[1], schedules2), ] | assert | collection | tests/cli/scheduler/test_updater.py | test_get_schedules_success | 55 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_pickle_error_serialization() -> None:
try:
raise ValueError("Omg", [1, 2, 3])
except Exception as exc:
error = exc
task: TaskiqResult[int] = TaskiqResult(
is... | task.error.args | assert | complex_expr | tests/test_result.py | test_pickle_error_serialization | 64 | null | |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | [] | assert | collection | tests/receiver/test_params_parser.py | test_kwargs_dataclasses_success | 179 | null | |
taskiq-python/taskiq | import inspect
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.compat import model_copy
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
@pytest.mark.parametrize("test_class", [_TestPydant... | "test_val" | assert | string_literal | tests/cli/worker/test_parameters_parsing.py | test_parse_params_classes | 63 | null | |
taskiq-python/taskiq | from taskiq.scheduler.merge_functions import only_unique, preserve_all
def test_only_unique() -> None:
first = [1, 2, 3]
second = [3, 4, 5]
assert only_unique(first, second) == | [1, 2, 3, 4, 5] | assert | collection | tests/scheduler/test_merge_funcs.py | test_only_unique | 13 | null | |
taskiq-python/taskiq | import asyncio
import pytest
from taskiq import InMemoryBroker, SimpleRetryMiddleware, SmartRetryMiddleware
from taskiq.exceptions import NoResultError
async def test_max_retries() -> None:
"""Tests wait_result."""
broker = InMemoryBroker().with_middlewares(
SimpleRetryMiddleware(
no_resu... | str(runs) | assert | func_call | tests/middlewares/test_task_retry.py | test_max_retries | 123 | null | |
taskiq-python/taskiq | from taskiq.state import TaskiqState
def test_state_set() -> None:
"""Tests that you can sel values as dict items."""
state = TaskiqState()
state["a"] = 1
assert state["a"] == | 1 | assert | numeric_literal | tests/test_state.py | test_state_set | 9 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
@pytest.mark.parametrize(
("ensure_ascii", "result"),
[
(True, b'"\\u043f\\u0440\\u0438\\u0432\\u0435\\u0442"'),
(False, b'"\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"'),
],
)
def test_json_dumpb_with_ensure_... | result | assert | variable | tests/serializers/test_json_serializer.py | test_json_dumpb_with_ensure_ascii | 33 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | error.__class__.__name__ | assert | complex_expr | tests/test_serialization.py | test_unpickleable_exception_wrapper | 210 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | ValidationError) | pytest.raises | variable | tests/test_serialization.py | test_impossible | 152 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | mock_span.set_attribute.called) | self.assertFalse | complex_expr | tests/opentelemetry/test_helpers.py | test_set_attributes_not_recording | TestUtils | 59 | null |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_result_raise_for_error_exc() -> None:
error = ValueError("Error")
res: TaskiqResult[None] = TaskiqResult(
is_err=True,
return_value=None,
execution_time=0,
... | ValueError) | pytest.raises | variable | tests/test_result.py | test_result_raise_for_error_exc | 78 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_loadb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.loadb(b"null") is None
assert serizalizer.loadb(b"1") == | 1 | assert | numeric_literal | tests/serializers/test_json_serializer.py | test_json_loadb | 18 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | ctx) | self.assertIsNotNone | variable | tests/opentelemetry/test_helpers.py | test_span_propagation | TestUtils | 82 | null |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_pickle_error_serialization() -> None:
try:
raise ValueError("Omg", [1, 2, 3])
except Exception as exc:
error = exc
task: TaskiqResult[int] = TaskiqResult(
is... | type(task.error) | assert | func_call | tests/test_result.py | test_pickle_error_serialization | 65 | null | |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | [{"a": "10", "b": "f3"}] | assert | collection | tests/receiver/test_params_parser.py | test_dataclasses_args_failure | 118 | null | |
taskiq-python/taskiq | import asyncio
import pytest
from taskiq import InMemoryBroker, SimpleRetryMiddleware, SmartRetryMiddleware
from taskiq.exceptions import NoResultError
async def test_wait_result() -> None:
"""Tests wait_result."""
broker = InMemoryBroker().with_middlewares(
SimpleRetryMiddleware(no_result_on_retry=T... | 1 | assert | numeric_literal | tests/middlewares/test_task_retry.py | test_wait_result | 28 | null | |
taskiq-python/taskiq | import asyncio
import uuid
import pytest
from taskiq import InMemoryBroker
from taskiq.events import TaskiqEvents
from taskiq.state import TaskiqState
async def test_inmemory_success() -> None:
broker = InMemoryBroker()
test_val = uuid.uuid4().hex
@broker.task
async def task() -> str:
return... | test_val | assert | variable | tests/brokers/test_inmemory.py | test_inmemory_success | 21 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_dumpb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.dumpb(None) == b"null"
assert serizalizer.dumpb(1) == | b"1" | assert | string_literal | tests/serializers/test_json_serializer.py | test_json_dumpb | 9 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | "TestParamException" | assert | string_literal | tests/test_serialization.py | test_exception_to_python_when_no_module | 262 | null | |
taskiq-python/taskiq | import datetime
import uuid
from typing import Any
import pytest
from taskiq.abc.serializer import TaskiqSerializer
from taskiq.serializers import (
CBORSerializer,
JSONSerializer,
MSGPackSerializer,
ORJSONSerializer,
PickleSerializer,
)
@pytest.mark.parametrize(
"serializer",
[
J... | data | assert | variable | tests/serializers/test_serializers.py | test_generic_serializer | 39 | null | |
taskiq-python/taskiq | from contextlib import suppress
from pathlib import Path
from unittest.mock import patch
from taskiq.cli.utils import import_tasks
def test_import_tasks_empty_pattern() -> None:
modules = ["taskiq.tasks"]
with patch("taskiq.cli.utils.import_from_modules", autospec=True) as mock:
import_tasks(modules, ... | ["taskiq.tasks"] | assert | collection | tests/cli/test_utils.py | test_import_tasks_empty_pattern | 36 | null | |
taskiq-python/taskiq | from taskiq import Context, InMemoryBroker, TaskiqDepends
async def test_requeue() -> None:
broker = InMemoryBroker()
runs_count = 0
@broker.task
async def task(context: Context = TaskiqDepends()) -> None:
nonlocal runs_count
runs_count += 1
if runs_count < 2:
awai... | "1" | assert | string_literal | tests/test_requeue.py | test_requeue | 18 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_dumpb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.dumpb(None) == b"null"
assert serizalizer.dumpb(1) == b"1"
assert serizalizer.dumpb("a") == b'"a"'
assert serizalizer.dumpb(["a"]) == b'["a"]... | b'{"a": "b"}' | assert | string_literal | tests/serializers/test_json_serializer.py | test_json_dumpb | 12 | null | |
taskiq-python/taskiq | from typing import Any
from unittest.mock import AsyncMock
import pytest
from taskiq.exceptions import ResultIsReadyError, TaskiqResultTimeoutError
from taskiq.funcs import gather
from taskiq.task import AsyncTaskiqTask
async def test_gather() -> None:
"""Test successful task gathering."""
rb_mock = AsyncMoc... | (1, 1) | assert | collection | tests/test_funcs.py | test_gather | 20 | null | |
taskiq-python/taskiq | import asyncio
import time
from taskiq import TaskiqScheduler
from taskiq.api import run_scheduler_task
from taskiq.schedule_sources import LabelScheduleSource
from tests.utils import AsyncQueueBroker
async def test_interval_task_performance() -> None:
broker = AsyncQueueBroker()
scheduler = TaskiqScheduler(b... | interval | assert | variable | tests/scheduler/test_interval_performance.py | test_interval_task_performance | 32 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.