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 |
|---|---|---|---|---|---|---|---|---|---|
fgmacedo/python-statemachine | import pytest
from statemachine.callbacks import CallbackGroup
from statemachine.callbacks import CallbackSpec
from statemachine.dispatcher import Listener
from statemachine.dispatcher import Listeners
from statemachine.dispatcher import resolver_factory_from_objects
from statemachine.exceptions import InvalidDefinitio... | "Bilbo" | assert | string_literal | tests/test_dispatcher.py | test_retrieve_callable_from_a_property_name_that_should_keep_reference | TestEnsureCallable | 101 | null |
fgmacedo/python-statemachine | import threading
import time
from statemachine.invoke import IInvoke
from statemachine.invoke import InvokeContext
from statemachine.invoke import invoke_group
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestInvokeGroup:
async def test_each_sm_instance... | [2] | assert | collection | tests/test_invoke.py | test_each_sm_instance_gets_own_group | TestInvokeGroup | 492 | null |
fgmacedo/python-statemachine | import inspect
from functools import partial
import pytest
from statemachine.dispatcher import callable_method
from statemachine.signature import SignatureAdapter
def single_positional_param(a):
return a
def single_default_keyword_param(a=42):
return a
def args_param(*args):
return args
def kwargs_para... | ((1,), {"key": "val"}) | assert | collection | tests/test_signature.py | test_empty_var_positional | TestCachedBindExpected | 254 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.mixins import MachineMixin
from tests.models import MyModel
def test_mixin_should_instantiate_a_machine(campaign_machine):
model = MyMixedModel(state="draft")
assert isinstance(model.statemachine, campaign_machine)
assert model.state == | "draft" | assert | string_literal | tests/test_mixins.py | test_mixin_should_instantiate_a_machine | 14 | null | |
fgmacedo/python-statemachine | import pytest
from statemachine.event import Event
from statemachine.exceptions import InvalidDefinition
from statemachine import State
from statemachine import StateChart
class TestExplicitEvent:
def test_accept_event_instance(self):
class StartMachine(StateChart):
created = State(initial=Tru... | ["Start"] | assert | collection | tests/test_events.py | test_accept_event_instance | TestExplicitEvent | 44 | null |
fgmacedo/python-statemachine | import threading
import pytest
from statemachine.contrib.timeout import _Timeout
from statemachine.contrib.timeout import timeout
from statemachine import State
from statemachine import StateChart
class TestTimeoutBasic:
async def test_timeout_fires_done_invoke(self, sm_runner):
class SM(StateChart):
... | sm.configuration_values | assert | complex_expr | tests/test_contrib_timeout.py | test_timeout_fires_done_invoke | TestTimeoutBasic | 47 | null |
fgmacedo/python-statemachine | import asyncio
from typing import TYPE_CHECKING
import pytest
from statemachine.spec_parser import Functions
from statemachine.spec_parser import operator_mapping
from statemachine.spec_parser import parse_boolean_expr
def variable_hook(
var_name: str,
spy: "Callable[[str], None] | None" = None,
) -> "Callabl... | True | assert | bool_literal | tests/test_spec_parser.py | test_negating_compound_false_expression | 192 | null | |
fgmacedo/python-statemachine | import inspect
import pytest
from statemachine.dispatcher import callable_method
class TestSignatureAdapter:
@pytest.mark.parametrize(
("args", "kwargs", "expected"),
[
([], {}, TypeError),
([1, 2, 3], {}, TypeError),
([1, 2], {"kw_only_param": 42}, (1, 2, 42)),... | expected) | pytest.raises | variable | tests/test_signature_positional_only.py | test_positional_only | TestSignatureAdapter | 30 | null |
fgmacedo/python-statemachine | import asyncio
import logging
import pickle
from copy import deepcopy
from enum import Enum
from enum import auto
import pytest
from statemachine.states import States
from statemachine import State
from statemachine import StateChart
logger = logging.getLogger(__name__)
def copy_pickle(obj):
return pickle.loads... | [1, 2, 3] | assert | collection | tests/test_copy.py | test_copy_with_custom_init_and_vars | 141 | null | |
fgmacedo/python-statemachine | import inspect
from functools import partial
import pytest
from statemachine.dispatcher import callable_method
from statemachine.signature import SignatureAdapter
def single_positional_param(a):
return a
def single_default_keyword_param(a=42):
return a
def args_param(*args):
return args
def kwargs_para... | ((1, 2, 3), {"key": "val"}) | assert | collection | tests/test_signature.py | test_var_positional_collected_as_tuple | TestCachedBindExpected | 209 | null |
fgmacedo/python-statemachine | import inspect
from functools import partial
import pytest
from statemachine.dispatcher import callable_method
from statemachine.signature import SignatureAdapter
def single_positional_param(a):
return a
def single_default_keyword_param(a=42):
return a
def args_param(*args):
return args
def kwargs_para... | ("A", {"target": "B"}) | assert | collection | tests/test_signature.py | test_kwargs_only_receives_unmatched_keys_with_positional | TestCachedBindExpected | 195 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestDoneData:
async def test_donedata_callable_returns_dict(self, sm_runner):
"""Handler receives donedata as kwargs."""
recei... | True | assert | bool_literal | tests/test_statechart_donedata.py | test_donedata_callable_returns_dict | TestDoneData | 43 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.callbacks import CallbacksRegistry
from statemachine.dispatcher import resolver_factory_from_objects
from statemachine.transition import Transition
from statemachine.transition_list import TransitionList
from statemachine import State
def test_transition_list_call_with_callable():
... | my_callback | assert | variable | tests/test_transition_list.py | test_transition_list_call_with_callable | 95 | null | |
fgmacedo/python-statemachine | import pytest
from statemachine import State
from statemachine import StateChart
class TestInCondition:
async def test_in_condition_true_enables_transition(self, sm_runner):
"""In('state_id') when state is active -> transition fires."""
class Fellowship(StateChart):
class positions(St... | vals | assert | variable | tests/test_statechart_in_condition.py | test_in_condition_true_enables_transition | TestInCondition | 39 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestErrorConventionLOTR:
def test_multiple_source_states_with_convention(self):
"""error_execution from multiple states using | opera... | {sm.doom} | assert | collection | tests/test_error_execution.py | test_multiple_source_states_with_convention | TestErrorConventionLOTR | 488 | null |
fgmacedo/python-statemachine | import asyncio
import logging
import pickle
from copy import deepcopy
from enum import Enum
from enum import auto
import pytest
from statemachine.states import States
from statemachine import State
from statemachine import StateChart
logger = logging.getLogger(__name__)
def copy_pickle(obj):
return pickle.loads... | sm.configuration_values | assert | complex_expr | tests/test_copy.py | test_copy_with_enum | 129 | null | |
fgmacedo/python-statemachine | import re
import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine.exceptions import InvalidStateValue
from statemachine import State
from statemachine import StateChart
def async_order_control_machine(): # noqa: C901
class OrderControl(StateChart):
allow_event_without_trans... | [] | assert | collection | tests/test_async.py | test_failing_async_condition | TestAsyncEnabledEvents | 487 | null |
fgmacedo/python-statemachine | import pytest
from statemachine import State
from statemachine import StateChart
def _state_by_name(sm, name):
return getattr(sm, name)
@pytest.mark.timeout(5)
@pytest.mark.parametrize(
("character", "first_peril", "second_peril"),
[
pytest.param(
Aragorn(),
OrcAmbush("Fir... | {sm.fallen} | assert | collection | tests/test_fellowship_quest.py | test_wounded_then_second_peril_is_fatal | 428 | null | |
fgmacedo/python-statemachine | import pytest
from statemachine import HistoryState
from statemachine import State
from statemachine import StateChart
class TestHistoryStates:
async def test_shallow_history_remembers_last_child(self, sm_runner):
"""Exit compound, re-enter via history -> restores last active child."""
class Goll... | sm.configuration_values | assert | complex_expr | tests/test_statechart_history.py | test_shallow_history_remembers_last_child | TestHistoryStates | 37 | null |
fgmacedo/python-statemachine | import inspect
import pytest
from statemachine.dispatcher import callable_method
class TestSignatureAdapter:
@pytest.mark.parametrize(
("args", "kwargs", "expected"),
[
([], {}, TypeError),
([1, 2, 3], {}, TypeError),
([1, 2], {"kw_only_param": 42}, (1, 2, 42)),... | expected | assert | variable | tests/test_signature_positional_only.py | test_positional_only | TestSignatureAdapter | 33 | null |
fgmacedo/python-statemachine | import logging
import xml.etree.ElementTree as ET
from unittest.mock import Mock
import pytest
from statemachine.io.scxml.actions import EventDataWrapper
from statemachine.io.scxml.actions import Log
from statemachine.io.scxml.actions import ParseTime
from statemachine.io.scxml.actions import create_action_callable
fr... | 1 | assert | numeric_literal | tests/test_scxml_units.py | test_state_without_id_gets_auto_generated | TestParseState | 72 | null |
fgmacedo/python-statemachine | import asyncio
import pytest
from statemachine.event import BoundEvent
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestDelayedEvents:
async def test_delayed_event_fires_after_delay(self, sm_runner):
"""Queuing a delayed event does not fire immed... | sm.configuration_values | assert | complex_expr | tests/test_statechart_delayed.py | test_delayed_event_fires_after_delay | TestDelayedEvents | 35 | null |
fgmacedo/python-statemachine | import inspect
from functools import partial
import pytest
from statemachine.dispatcher import callable_method
from statemachine.signature import SignatureAdapter
def single_positional_param(a):
return a
def single_default_keyword_param(a=42):
return a
def args_param(*args):
return args
def kwargs_para... | ("X", {"target": "Y"}) | assert | collection | tests/test_signature.py | test_kwargs_only_receives_unmatched_keys_with_positional | TestCachedBindExpected | 198 | null |
fgmacedo/python-statemachine | import inspect
from functools import partial
import pytest
from statemachine.dispatcher import callable_method
from statemachine.signature import SignatureAdapter
def single_positional_param(a):
return a
def single_default_keyword_param(a=42):
return a
def args_param(*args):
return args
def kwargs_para... | ("ev2", "s1", "t1") | assert | collection | tests/test_signature.py | test_positional_or_keyword_prefers_kwargs_over_positional | TestCachedBindExpected | 242 | null |
fgmacedo/python-statemachine | from contextlib import contextmanager
from unittest import mock
import pytest
from statemachine.contrib.diagram import DotGraphMachine
from statemachine.contrib.diagram import main
from statemachine.contrib.diagram import quickchart_write_svg
from statemachine.transition import Transition
from statemachine import His... | None | assert | none_literal | tests/test_contrib_diagram.py | test_compound_state_diagram | 133 | null | |
fgmacedo/python-statemachine | import threading
import time
from statemachine.invoke import IInvoke
from statemachine.invoke import InvokeContext
from statemachine.invoke import invoke_group
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestInvokeGroup:
async def test_each_sm_instance... | [1] | assert | collection | tests/test_invoke.py | test_each_sm_instance_gets_own_group | TestInvokeGroup | 491 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.callbacks import CallbackGroup
from statemachine.callbacks import CallbackSpec
from statemachine.dispatcher import Listener
from statemachine.dispatcher import Listeners
from statemachine.dispatcher import resolver_factory_from_objects
from statemachine.exceptions import InvalidDefinitio... | expected.__doc__ | assert | complex_expr | tests/test_dispatcher.py | test_return_same_object_if_already_a_callable | TestEnsureCallable | 64 | null |
fgmacedo/python-statemachine | from unittest import mock
import pytest
from statemachine.callbacks import CallbackGroup
from statemachine.callbacks import CallbacksExecutor
from statemachine.callbacks import CallbackSpec
from statemachine.callbacks import CallbackSpecList
from statemachine.callbacks import CallbacksRegistry
from statemachine.dispat... | [] | assert | collection | tests/test_callbacks.py | test_visit_skips_when_condition_is_false | TestVisitConditionFalse | 372 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine.transition import Transition
from statemachine import State
from statemachine import StateChart
from .models import MyModel
def transition_callback_machine(request):
if request.param == "bounded":
class ApprovalMachine... | sm.TransitionNotAllowed) | pytest.raises | complex_expr | tests/test_transitions.py | test_transition_from_any_with_cond | TestTransitionFromAny | 411 | null |
fgmacedo/python-statemachine | import asyncio
import pytest
from statemachine.engines.base import EventQueue
from statemachine.event_data import TriggerData
from statemachine import State
from statemachine import StateChart
class TestConcurrentSendsGetCorrectResults:
@pytest.mark.asyncio()
async def test_sequential_sends(self):
"... | "slowing" | assert | string_literal | tests/test_async_futures.py | test_sequential_sends | TestConcurrentSendsGetCorrectResults | 73 | null |
fgmacedo/python-statemachine | import warnings
import pytest
from statemachine import State
from statemachine import StateMachine
from statemachine import exceptions
class TestStateMachineDefaults:
def test_atomic_configuration_update(self):
assert StateMachine.atomic_configuration_update is | True | assert | bool_literal | tests/test_statemachine_compat.py | test_atomic_configuration_update | TestStateMachineDefaults | 37 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.event import Event
from statemachine.exceptions import InvalidDefinition
from statemachine import State
from statemachine import StateChart
class TestExplicitEvent:
def test_accept_event_instance(self):
class StartMachine(StateChart):
created = State(initial=Tru... | ["start"] | assert | collection | tests/test_events.py | test_accept_event_instance | TestExplicitEvent | 43 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.orderedset import OrderedSet
from statemachine import HistoryState
from statemachine import State
from statemachine import StateChart
from statemachine import exceptions
from tests.models import MyModel
def test_states_getitem():
"""States supports index access."""
class SM(St... | "s2" | assert | string_literal | tests/test_statemachine.py | test_states_getitem | 596 | null | |
fgmacedo/python-statemachine | import threading
import time
from statemachine.invoke import IInvoke
from statemachine.invoke import InvokeContext
from statemachine.invoke import invoke_group
from statemachine import Event
from statemachine import State
from statemachine import StateChart
class TestInvokeIInvokeProtocol:
async def test_each_s... | 2 | assert | numeric_literal | tests/test_invoke.py | test_each_sm_instance_gets_own_handler | TestInvokeIInvokeProtocol | 157 | null |
fgmacedo/python-statemachine | import pytest
from statemachine.orderedset import OrderedSet
from statemachine import HistoryState
from statemachine import State
from statemachine import StateChart
from statemachine import exceptions
from tests.models import MyModel
def test_abstract_sm_no_states():
"""A state machine class with no states is ab... | True | assert | bool_literal | tests/test_statemachine.py | test_abstract_sm_no_states | 555 | null | |
fgmacedo/python-statemachine | import logging
import xml.etree.ElementTree as ET
from unittest.mock import Mock
import pytest
from statemachine.io.scxml.actions import EventDataWrapper
from statemachine.io.scxml.actions import Log
from statemachine.io.scxml.actions import ParseTime
from statemachine.io.scxml.actions import create_action_callable
fr... | "first" | assert | string_literal | tests/test_scxml_units.py | test_invoke_init_idempotent | TestInvokeInitCallback | 769 | null |
fgmacedo/python-statemachine | from statemachine.io import _parse_history
from statemachine.io import create_machine_class_from_definition
class TestParseHistory:
def test_history_without_transitions(self):
"""History state with no 'on' or 'transitions' keys."""
states_instances, events_definitions = _parse_history({"h1": {"type... | {} | assert | collection | tests/test_io.py | test_history_without_transitions | TestParseHistory | 13 | null |
fgmacedo/python-statemachine | import pytest
from statemachine import State
from statemachine import StateChart
class TestEventlessTransitions:
async def test_eventless_with_in_condition(self, sm_runner):
"""Eventless transition guarded by In('state_id')."""
class CoordinatedAdvance(StateChart):
class forces(State... | vals | assert | variable | tests/test_statechart_eventless.py | test_eventless_with_in_condition | TestEventlessTransitions | 157 | null |
fgmacedo/python-statemachine | import asyncio
from typing import TYPE_CHECKING
import pytest
from statemachine.spec_parser import Functions
from statemachine.spec_parser import operator_mapping
from statemachine.spec_parser import parse_boolean_expr
def variable_hook(
var_name: str,
spy: "Callable[[str], None] | None" = None,
) -> "Callabl... | SyntaxError) | pytest.raises | variable | tests/test_spec_parser.py | test_empty_expression | 215 | null | |
fgmacedo/python-statemachine | import asyncio
import logging
import pickle
from copy import deepcopy
from enum import Enum
from enum import auto
import pytest
from statemachine.states import States
from statemachine import State
from statemachine import StateChart
logger = logging.getLogger(__name__)
def copy_pickle(obj):
return pickle.loads... | sm2.model | assert | complex_expr | tests/test_copy.py | test_copy | 90 | null | |
fgmacedo/python-statemachine | import warnings
import pytest
from statemachine import State
from statemachine import StateMachine
from statemachine import exceptions
class TestTransitionNotAllowed:
def sm(self):
class Workflow(StateMachine):
draft = State(initial=True)
published = State(final=True)
... | sm.TransitionNotAllowed) | pytest.raises | complex_expr | tests/test_statemachine_compat.py | test_condition_blocks_transition | TestTransitionNotAllowed | 117 | null |
fgmacedo/python-statemachine | import warnings
import pytest
from statemachine import State
from statemachine import StateMachine
from statemachine import exceptions
class TestCurrentStateDeprecated:
def test_current_state_with_list_value(self):
"""current_state handles list current_state_value (backward compat)."""
class SM... | config | assert | variable | tests/test_statemachine_compat.py | test_current_state_with_list_value | TestCurrentStateDeprecated | 374 | null |
fgmacedo/python-statemachine | import re
import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine.exceptions import InvalidStateValue
from statemachine import State
from statemachine import StateChart
def async_order_control_machine(): # noqa: C901
class OrderControl(StateChart):
allow_event_without_trans... | 3 | assert | numeric_literal | tests/test_async.py | test_async_order_control_machine | 57 | null | |
fgmacedo/python-statemachine | import pytest
from statemachine.callbacks import CallbacksRegistry
from statemachine.dispatcher import resolver_factory_from_objects
from statemachine.transition import Transition
from statemachine.transition_list import TransitionList
from statemachine import State
def test_transition_list_or_operator():
s1 = St... | [("s3", "s4")] | assert | collection | tests/test_transition_list.py | test_transition_list_or_operator | 24 | null | |
fgmacedo/python-statemachine | import inspect
from unittest import mock
import pytest
from statemachine import State
from statemachine import StateChart
def chained_after_sm_class(): # noqa: C901
class ChainedSM(StateChart):
a = State(initial=True)
b = State()
c = State(final=True)
t1 = a.to(b, after="t1") | ... | expected) | pytest.raises | variable | tests/test_rtc.py | test_should_preserve_event_order | TestChainedTransition | 144 | null |
fgmacedo/python-statemachine | import pickle
from functools import partial
import pytest
from statemachine.exceptions import InvalidDefinition
from statemachine import State
from statemachine import StateChart
class TestListenerSetupProtocol:
def test_setup_not_called_on_shared_instances(self):
shared = SetupListener()
class... | None | assert | none_literal | tests/test_class_listeners.py | test_setup_not_called_on_shared_instances | TestListenerSetupProtocol | 270 | null |
beartype/beartype | def test_typingpep544_superclass() -> None:
'''
Test the public :class:`beartype.typing.Protocol` superclass.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.typing import (
Protocol as ProtocolFast,
T... | ProtocolFast[_T_co] | assert | complex_expr | beartype_test/a00_unit/a30_api/typing/test_typingpep544.py | test_typingpep544_superclass | 82 | null | |
beartype/beartype | def unit_test_is_hint_pep695_subbed() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep695.is_hint_pep695_subbed`
tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.hint.pep.p... | str | int | assert | complex_expr | beartype_test/a00_unit/data/pep/pep695/data_pep695util.py | unit_test_reduce_hint_pep695_unsubbed | 280 | null | |
beartype/beartype | def test_callable_cached() -> None:
'''
Test the
:func:`beartype._util.cache.utilcachecall.callable_cached` decorator.
'''
# ..................{ IMPORTS }..................
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilCallableCach... | from_savage_men(bitter) | assert | func_call | beartype_test/a00_unit/a20_util/a20_cache/test_utilcachecall.py | test_callable_cached | 108 | null | |
beartype/beartype | def test_data_indent_level_to_code() -> None:
'''
Test the :obj:`beartype._data.code.datacodeindent.INDENT_LEVEL_TO_CODE`
dictionary singleton.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._data.code.datacodein... | ' ' | assert | string_literal | beartype_test/a00_unit/a10_data/code/test_datacodeindent.py | test_data_indent_level_to_code | 35 | null | |
beartype/beartype | def test_label_type() -> None:
'''
Test the :func:`beartype._util.text.utiltextlabel.label_type`
function.
'''
# Defer test-specific imports.
from beartype._util.text.utiltextlabel import label_type
from beartype_test.a00_unit.data.data_type import Class
# Assert this labeller returns ... | 'str' | assert | string_literal | beartype_test/a00_unit/a20_util/text/test_utiltextlabel.py | test_label_type | 156 | null | |
beartype/beartype | def test_callmetadecormin() -> None:
'''
Test the
:func:`beartype._check.metadata.call.callmetadecormin.BeartypeCallDecorMinimalMeta`
dataclass.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import BeartypeC... | conf | assert | variable | beartype_test/a00_unit/a50_check/a00_metadata/call/test_callmetadecormin.py | test_callmetadecormin | 60 | null | |
beartype/beartype | def test_get_hint_repr(hints_pep_meta) -> None:
'''
Test the :func:`beartype._util.hint.utilhintget.get_hint_repr` getter.
Parameters
----------
hints_pep_meta : List[beartype_test.a00_unit.data.hint.metadata.data_hintpithmeta.HintPepMetadata]
List of type hint metadata describing sample ty... | repr(non_hint) | assert | func_call | beartype_test/a00_unit/a20_util/hint/a90_core/test_utilhintget.py | test_get_hint_repr | 39 | null | |
beartype/beartype | import pytest
from beartype_test._util.mark.pytskip import skip_unless_package
@pytest.mark.run_in_subprocess
def test_jax_jit() -> None:
'''
Integration test validating that the :func:`beartype.beartype` decorator
successfully type-checks callables decorated by the third-party
:func:`jax.jit` decorato... | jax_numpy.array(2.0) | assert | func_call | beartype_test/a90_func/a50_external/a50_jax/test_jax.py | test_jax_jit | 167 | null | |
beartype/beartype | def test_data_indent_level_to_code() -> None:
'''
Test the :obj:`beartype._data.code.datacodeindent.INDENT_LEVEL_TO_CODE`
dictionary singleton.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._data.code.datacodein... | INDENT_LEVEL_TO_CODE[1] | assert | complex_expr | beartype_test/a00_unit/a10_data/code/test_datacodeindent.py | test_data_indent_level_to_code | 39 | null | |
beartype/beartype | def test_word_size() -> None:
'''
Test the :func:`beartype._util.py.utilpyword.WORD_SIZE` constant.
'''
# Defer test-specific imports.
from beartype._util.py.utilpyword import WORD_SIZE
# Assert the active Python interpreter to be either 32- or 64-bit.
assert WORD_SIZE in | {32, 64} | assert | collection | beartype_test/a00_unit/a20_util/py/test_utilpyword.py | test_word_size | 29 | null | |
beartype/beartype | from beartype_test._util.mark.pytskip import (
skip_if_pypy,
skip_if_python_version_less_than,
skip_if_python_version_greater_than_or_equal_to,
)
def test_pep563_class_self_reference_reloaded() -> None:
'''
Test module-scoped :pep:`563` support implemented in the
:func:`beartype.beartype` decor... | data_pep563_club.CLING | assert | complex_expr | beartype_test/a00_unit/a60_decor/a00_core/a60_pep/test_decorpep563.py | test_pep563_class_self_reference_reloaded | 81 | null | |
beartype/beartype | def test_is_hint_pep484585646_tuple_variadic_unpacked_if_needed() -> None:
'''
Test the
:func:`beartype._util.hint.pep.proposal.pep484585646.is_hint_pep484585646_tuple_variadic_unpacked_if_needed`
tester.
'''
# ....................{ IMPORTS }....................
# Def... | True | assert | bool_literal | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_pep484585646.py | test_is_hint_pep484585646_tuple_variadic_unpacked_if_needed | 49 | null | |
beartype/beartype | def test_conf_dataclass() -> None:
'''
Test the public :func:`beartype.BeartypeConf` class.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import (
BeartypeConf,
BeartypeDecorPlace,
BeartypeSt... | True | assert | bool_literal | beartype_test/a00_unit/a30_api/conf/test_confcls.py | test_conf_dataclass | 177 | null | |
beartype/beartype | from pytest import raises
from beartype.roar._roarexc import _BeartypeUtilCacheLruException
def test_lrucachestrong_two_pass() -> None:
"""
Test successful usage of the
:func:`beartype._util.cache.map.utilmaplru.CacheLruStrong` class against an
LRU cache caching at most two key-value pairs.
"""
... | lru_cache | assert | variable | beartype_test/a00_unit/a20_util/a20_cache/map/test_utilmaplru.py | test_lrucachestrong_two_pass | 102 | null | |
beartype/beartype | def attach_func_locals(**kwargs) -> 'collections.abc.Callable':
'''
Decorator attaching the local scope of the parent callable declaring the
passed callable to a new ``func_locals`` attribute of the passed callable.
Parameters
----------
This decorator forwards all passed keyword parameters as ... | Union[bool, str] | assert | complex_expr | beartype_test/a00_unit/a20_util/func/test_utilfuncscope.py | test_get_func_locals | 252 | null | |
beartype/beartype | def test_truncate_str():
'''
Test the :func:`beartype._util.text.utiltextmunge.truncate_str` function.
'''
# Defer test-specific imports.
from beartype._util.text.utiltextmunge import truncate_str
# Assert that truncating the empty string returns the empty string.
assert truncate_str(text=... | 'Se' | assert | string_literal | beartype_test/a00_unit/a20_util/text/test_utiltextmunge.py | test_truncate_str | 162 | null | |
beartype/beartype | def test_decor_noop_unhinted_sync() -> None:
'''
Test that the :func:`beartype.beartype` decorator efficiently reduces to a
noop on **unannotated synchronous callables** (i.e., callables with *no*
annotations declared with the ``def`` rather than ``async def`` keyword).
'''
# Defer test-specifi... | khorne | assert | variable | beartype_test/a00_unit/a60_decor/a00_core/test_decornoop.py | test_decor_noop_unhinted_sync | 96 | null | |
beartype/beartype | def test_api_vale_is_pass() -> None:
'''
Test successful usage of the :mod:`beartype.vale.Is` factory.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import beartype
from beartype._util.func.utilfuncmake import m... | 4 | assert | numeric_literal | beartype_test/a00_unit/a30_api/vale/_is/test_valeis.py | test_api_vale_is_pass | 170 | null | |
beartype/beartype | def test_coerce_hint_any() -> None:
'''
Test the private
:func:`beartype._check.convert._convcoerce.coerce_hint_any` coercer.
'''
# ..................{ IMPORTS }..................
# Defer test-specific imports.
from beartype._util.cache.utilcacheclear import clear... | int | assert | variable | beartype_test/a00_unit/a50_check/a40_convert/test_convcoerce.py | test_coerce_hint_any | 88 | null | |
beartype/beartype | from beartype_test._util.mark.pytskip import (
skip_if_pypy,
skip_if_python_version_less_than,
skip_if_python_version_greater_than_or_equal_to,
)
@skip_if_python_version_less_than('3.12.0')
def test_pep563_hint_pep695() -> None:
'''
Test module-scoped :pep:`563` support implemented in the
:func... | 'To' | assert | string_literal | beartype_test/a00_unit/a60_decor/a00_core/a60_pep/test_decorpep563.py | test_pep563_hint_pep695 | 455 | null | |
beartype/beartype | def test_represent_object() -> None:
'''
Test the :func:`beartype._util.text.utiltextrepr.represent_object`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.text.utiltextrepr import represent_object... | 2 | assert | numeric_literal | beartype_test/a00_unit/a20_util/text/test_utiltextrepr.py | test_represent_object | 86 | null | |
beartype/beartype | from beartype_test._util.mark.pytmark import ignore_warnings
def test_door_typehint_compare_fail() -> None:
'''
Test unsuccessful usage the rich comparison dunder methods defined by the
:class:`beartype.door.TypeHint` class.
'''
# Defer test-specific imports.
from beartype.door import TypeHint... | b | assert | variable | beartype_test/a00_unit/a30_api/door/a00_type/test_door_typehint.py | test_door_typehint_compare_fail | 222 | null | |
beartype/beartype | def test_import_typing_attr() -> None:
'''
Test the :func:`beartype._util.api.standard.utiltyping.import_typing_attr`
importer.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilMod... | Union | assert | variable | beartype_test/a00_unit/a20_util/api/standard/test_utilapityping.py | test_import_typing_attr | 40 | null | |
beartype/beartype | def test_label_object_kind() -> None:
'''
Test the :func:`beartype._util.text.utiltextlabel.label_object_kind`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.text.utiltextlabel import label_object... | kind | assert | variable | beartype_test/a00_unit/a20_util/text/test_utiltextlabel.py | test_label_object_kind | 85 | null | |
beartype/beartype | def test_represent_object() -> None:
'''
Test the :func:`beartype._util.text.utiltextrepr.represent_object`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.text.utiltextrepr import represent_object... | '""' | assert | string_literal | beartype_test/a00_unit/a20_util/text/test_utiltextrepr.py | test_represent_object | 62 | null | |
beartype/beartype | def test_add_func_scope_type() -> None:
'''
Test the
:func:`beartype._check.code.codescope.add_func_scope_type` adder.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar import BeartypeDecorHintPep3119Exception
... | cls | assert | variable | beartype_test/a00_unit/a50_check/a80_code/test_codescope.py | test_add_func_scope_type | 57 | null | |
beartype/beartype | def test_get_func_arg_names() -> None:
'''
Test the
:func:`beartype._util.func.arg.utilfuncargget.get_func_arg_names`
getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilC... | () | assert | collection | beartype_test/a00_unit/a20_util/func/arg/test_utilfuncargget.py | test_get_func_arg_names | 82 | null | |
beartype/beartype | from enum import Enum
import re
from beartype_test._util.mark.pytskip import (
skip_if_pypy,
skip_unless_package,
)
from collections import deque
from collections.abc import Iterable
def _we_were_dreamers_dreaming_greatly_in_the_man_stifled_town(): pass
def _we_yearned_beyond_the_sky_line_where_the_strange_ro... | () | assert | collection | beartype_test/a00_unit/a30_api/test_api_cave.py | test_api_cave_tuple_core | 534 | null | |
beartype/beartype | def test_reissue_warnings_placeholder() -> None:
'''
Test the
:func:`beartype._util.error.utilerrwarn.reissue_warnings_placeholder`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.error.utilerr... | 4 | assert | numeric_literal | beartype_test/a00_unit/a20_util/error/test_utilerrwarn.py | test_reissue_warnings_placeholder | 130 | null | |
beartype/beartype | def test_get_func_args_len_flexible() -> None:
'''
Test the
:func:`beartype._util.func.arg.utilfuncarglen.get_func_args_flexible_len`
getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar._roarexc impor... | 2 | assert | numeric_literal | beartype_test/a00_unit/a20_util/func/arg/test_utilfuncarglen.py | test_get_func_args_len_flexible | 58 | null | |
beartype/beartype | def test_typehinttypefactory() -> None:
'''
Test the :func:`beartype._util.hint.utilhintfactory.TypeHintTypeFactory`
class.
'''
# Defer test-specific imports.
from beartype._util.hint.utilhintfactory import TypeHintTypeFactory
# Arbitrary instance of this factory.
bool_factory = TypeHi... | bool | assert | variable | beartype_test/a00_unit/a20_util/hint/a90_core/test_utilhintfactory.py | test_typehinttypefactory | 37 | null | |
beartype/beartype | def test_truncate_str():
'''
Test the :func:`beartype._util.text.utiltextmunge.truncate_str` function.
'''
# Defer test-specific imports.
from beartype._util.text.utiltextmunge import truncate_str
# Assert that truncating the empty string returns the empty string.
assert truncate_str(text=... | 'S' | assert | string_literal | beartype_test/a00_unit/a20_util/text/test_utiltextmunge.py | test_truncate_str | 161 | null | |
beartype/beartype | def test_represent_func() -> None:
'''
Test the :func:`beartype._util.text.utiltextrepr.represent_func`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.text.utiltextrepr import represent_func
f... | repr(function_partial) | assert | func_call | beartype_test/a00_unit/a20_util/text/test_utiltextrepr.py | test_represent_func | 120 | null | |
beartype/beartype | def test_is_hint_pep646_tuple_unpacked_prefix() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep646692.is_hint_pep646_tuple_unpacked_prefix`
tester.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
fr... | True | assert | bool_literal | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_pep646692.py | test_is_hint_pep646_tuple_unpacked_prefix | 45 | null | |
beartype/beartype | AND_SEE_THE_GREAT_ACHILLES = 'whom we knew'
def test_make_func(capsys) -> None:
'''
Test the :func:`beartype._util.func.utilfuncmake.make_func` function.
Parameters
----------
capsys
:mod:`pytest` fixture enabling standard output and error to be reliably
captured and tested against... | odyssey | assert | variable | beartype_test/a00_unit/a20_util/func/test_utilfuncmake.py | test_make_func | 113 | null | |
beartype/beartype | def test_get_node_attr_basename_first() -> None:
'''
Test the :func:`beartype._util.ast.utilastget.get_node_attr_basename_first`
factory.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.ast.utilastget import... | 'his_ample' | assert | string_literal | beartype_test/a00_unit/a20_util/ast/test_utilastget.py | test_get_node_attr_basename_first | 48 | null | |
beartype/beartype | def test_decor_noop_redecorated_sync() -> None:
'''
Test that the :func:`beartype.beartype` decorator efficiently reduces to a
noop on **synchronous wrappers** (i.e., wrapper functions declared with the
``def`` rather than ``async def`` keyword) generated by prior calls to this
decorator.
'''
... | beartype(xenos) | assert | func_call | beartype_test/a00_unit/a60_decor/a00_core/test_decornoop.py | test_decor_noop_redecorated_sync | 123 | null | |
beartype/beartype | def test_make_hint_pep484604_union() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep484604.make_hint_pep484604_union`
factory.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar impo... | int | list[str] | None | assert | complex_expr | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_pep484604.py | test_make_hint_pep484604_union | 63 | null | |
beartype/beartype | def test_get_hint_pep484585_generic_args_full() -> None:
'''
Test the
:func:`beartype._util.hint.pep.proposal.pep484585.pep484585generic.get_hint_pep484585_generic_args_full`
getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific impor... | trg_args | assert | variable | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/pep484585/generic/test_pep484585genget.py | test_get_hint_pep484585_generic_args_full | 123 | null | |
beartype/beartype | def test_get_func_contextlib_contextmanager_or_none() -> None:
'''
Test the
:func:`beartype._util.api.standard.utilcontextlib.get_func_contextlib_contextmanager_or_none`
getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
... | None | assert | none_literal | beartype_test/a00_unit/a20_util/api/standard/test_utilapicontextlib.py | test_get_func_contextlib_contextmanager_or_none | 64 | null | |
beartype/beartype | def test_get_name_error_attr_name() -> None:
'''
Test the
:func:`beartype._util.error.utilerrget.get_name_error_attr_name` getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.error.utilerrget import get_... | 'FreeAttr' | assert | string_literal | beartype_test/a00_unit/a20_util/error/test_utilerrget.py | test_get_name_error_attr_name | 49 | null | |
beartype/beartype | def test_get_hint_repr(hints_pep_meta) -> None:
'''
Test the :func:`beartype._util.hint.utilhintget.get_hint_repr` getter.
Parameters
----------
hints_pep_meta : List[beartype_test.a00_unit.data.hint.metadata.data_hintpithmeta.HintPepMetadata]
List of type hint metadata describing sample ty... | repr(hint_pep) | assert | func_call | beartype_test/a00_unit/a20_util/hint/a90_core/test_utilhintget.py | test_get_hint_repr | 74 | null | |
beartype/beartype | def test_get_hint_pep557_initvar_arg() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep557.get_hint_pep557_initvar_arg`
getter.
'''
# Defer test-specific imports.
from beartype.roar import BeartypeDecorHintPep557Exception
from beartype._util.hint.pep.proposal.pep... | str | assert | variable | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_pep557.py | test_get_hint_pep557_initvar_arg | 35 | null | |
beartype/beartype | def test_get_func_functools_partial_args() -> None:
'''
Test the
:func:`beartype._util.api.standard.utilfunctools.get_func_functools_partial_args`
getter.
'''
# Defer test-specific imports.
from beartype._util.api.standard.utilfunctools import (
get_func_functools_partial_args)
... | ((2,), {}) | assert | collection | beartype_test/a00_unit/a20_util/api/standard/test_utilapifunctools.py | test_get_func_functools_partial_args | 91 | null | |
beartype/beartype | def test_get_frame() -> None:
'''
Test the
:func:`beartype._util.func.utilfuncframe.get_frame` getter.
'''
# Defer test-specific imports.
from beartype._util.func.utilfuncframe import get_frame
# Assert this attribute is a callable under both CPython and PyPy.
assert callable(get_fram... | True | assert | bool_literal | beartype_test/a00_unit/a20_util/func/test_utilfuncframe.py | test_get_frame | 113 | null | |
beartype/beartype | def test_unwrap_func_functools_partial_once() -> None:
'''
Test the
:func:`beartype._util.api.standard.utilfunctools.unwrap_func_functools_partial_once`
unwrapper.
'''
# Defer test-specific imports.
from beartype._util.api.standard.utilfunctools import (
unwrap_func_functools_partia... | divmod | assert | variable | beartype_test/a00_unit/a20_util/api/standard/test_utilapifunctools.py | test_unwrap_func_functools_partial_once | 120 | null | |
beartype/beartype | from beartype_test._util.mark.pytskip import (
skip_if_pypy,
skip_if_python_version_less_than,
skip_if_python_version_greater_than_or_equal_to,
)
def test_pep563_class_self_reference_override() -> None:
'''
Test module-scoped :pep:`563` support implemented in the
:func:`beartype.beartype` decor... | DREAMS | assert | variable | beartype_test/a00_unit/a60_decor/a00_core/a60_pep/test_decorpep563.py | test_pep563_class_self_reference_override | 128 | null | |
beartype/beartype | def test_suffix_str_unless_suffixed():
'''
Test the
:func:`beartype._util.text.utiltextmunge.suffix_str_unless_suffixed`
function.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype._util.text.utiltextmunge impor... | "somefile.py" | assert | string_literal | beartype_test/a00_unit/a20_util/text/test_utiltextmunge.py | test_suffix_str_unless_suffixed | 130 | null | |
beartype/beartype | def test_api_vale_is_pass() -> None:
'''
Test successful usage of the :mod:`beartype.vale.Is` factory.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype import beartype
from beartype._util.func.utilfuncmake import m... | 2 | assert | numeric_literal | beartype_test/a00_unit/a30_api/vale/_is/test_valeis.py | test_api_vale_is_pass | 171 | null | |
beartype/beartype | from pytest import raises
from beartype.roar._roarexc import _BeartypeUtilCacheLruException
def test_lrucachestrong_one_pass() -> None:
"""
Test successful usage of the
:func:`beartype._util.cache.map.utilmaplru.CacheLruStrong` class against an
LRU cache caching at most one key-value pair.
"""
... | 0 | assert | numeric_literal | beartype_test/a00_unit/a20_util/a20_cache/map/test_utilmaplru.py | test_lrucachestrong_one_pass | 41 | null | |
beartype/beartype | def test_api_typing() -> None:
'''
Test the public API of the :mod:`beartype.meta` submodule.
This test exercises that there exists a one-to-one mapping between public
attributes exported by the :mod:`beartype.typing` and :mod:`typing`
submodules. See the class docstring for relevant commentary.
... | set() | assert | func_call | beartype_test/a00_unit/a00_core/test_a90_typing.py | test_api_typing | 266 | null | |
beartype/beartype | def test_get_hint_pep484612646_typearg_packed_name() -> None:
'''
Test the private
:mod:`beartype._util.hint.pep.proposal.pep484612646.get_hint_pep484612646_typearg_packed_name`
getter.
'''
# ....................{ IMPORTS }....................
# Defer test-specific im... | 'Ts' | assert | string_literal | beartype_test/a00_unit/a20_util/hint/a00_pep/proposal/test_pep484612646.py | test_get_hint_pep484612646_typearg_packed_name | 55 | null | |
beartype/beartype | def test_get_hint_repr(hints_pep_meta) -> None:
'''
Test the :func:`beartype._util.hint.utilhintget.get_hint_repr` getter.
Parameters
----------
hints_pep_meta : List[beartype_test.a00_unit.data.hint.metadata.data_hintpithmeta.HintPepMetadata]
List of type hint metadata describing sample ty... | repr(nonhint_pep) | assert | func_call | beartype_test/a00_unit/a20_util/hint/a90_core/test_utilhintget.py | test_get_hint_repr | 44 | null | |
beartype/beartype | def test_iter_func_args() -> None:
'''
Test the
:func:`beartype._util.func.arg.utilfuncargtest.iter_func_args` generator.
'''
# ....................{ IMPORTS }....................
# Defer test-specific imports.
from beartype.roar._roarexc import _BeartypeUtilCallableE... | 0 | assert | numeric_literal | beartype_test/a00_unit/a20_util/func/arg/test_utilfuncargiter.py | test_iter_func_args | 60 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.