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 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...
"value"
assert
string_literal
tests/test_scxml_units.py
test_removes_namespace_from_attributes
TestStripNamespaces
55
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...
"my.event"
assert
string_literal
tests/test_scxml_units.py
test_name_via_trigger_data
TestEventDataWrapperEdgeCases
653
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...
["on_validate"]
assert
collection
tests/test_transitions.py
test_statemachine_transition_callback
125
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_should_not_override_states_properties(campaign_machine): machine = cam...
str(e)
assert
func_call
tests/test_statemachine.py
test_should_not_override_states_properties
475
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...
[4, 6]
assert
collection
tests/test_async.py
test_async_order_control_machine
68
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...
dot
assert
variable
tests/test_contrib_diagram.py
test_compound_state_diagram
135
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...
True
assert
bool_literal
tests/test_transitions.py
test_any_can_be_used_as_decorator
TestTransitionFromAny
441
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 TestClassLevelListeners: def test_class_level_listener_callable_creates_per_instance(self): class MyChart(StateChart): ...
[]
assert
collection
tests/test_class_listeners.py
test_class_level_listener_callable_creates_per_instance
TestClassLevelListeners
56
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", "peril"), [ pytest.param(Aragorn(), TreacherousTerrain("Cliff fall"), id="aragorn-recovers"), ...
{sm.healed}
assert
collection
tests/test_fellowship_quest.py
test_recovery_after_wound
452
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_error_nested_dots_convention(self): """error_communication_failed -> also matches error.communicati...
{sm.lit}
assert
collection
tests/test_error_execution.py
test_error_nested_dots_convention
TestErrorConventionLOTR
602
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_receives_sm_instance(self): class IntrospectiveListener: def __in...
sm
assert
variable
tests/test_class_listeners.py
test_setup_receives_sm_instance
TestListenerSetupProtocol
316
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...
["go"]
assert
collection
tests/test_async.py
test_passing_async_condition
TestAsyncEnabledEvents
473
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestValidatorPropagation: async def test_validator_rejects_with_catch_errors_as_events_true(self, sm_runner): """With catch_errors_as_events=True (default), validator exceptions still propagate — they are NOT c...
sm.configuration_values
assert
complex_expr
tests/test_validators.py
test_validator_rejects_with_catch_errors_as_events_true
TestValidatorPropagation
144
null
fgmacedo/python-statemachine
from statemachine.io import _parse_history from statemachine.io import create_machine_class_from_definition class TestParseHistory: def test_history_with_on_only(self): """History state with 'on' events but no 'transitions' key.""" states_instances, events_definitions = _parse_history( ...
events_definitions["h1"]
assert
complex_expr
tests/test_io.py
test_history_with_on_only
TestParseHistory
22
null
fgmacedo/python-statemachine
import pytest from statemachine.event import Event from statemachine.exceptions import InvalidDefinition from statemachine import State from statemachine import StateChart def test_event_match_trailing_dot(): """Event descriptor ending with '.' matches the prefix.""" event = Event("error.") assert event....
True
assert
bool_literal
tests/test_events.py
test_event_match_trailing_dot
316
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_has_eventless_transition(): """Transit...
True
assert
bool_literal
tests/test_transition_list.py
test_has_eventless_transition
74
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import Event from statemachine import State from statemachine import StateChart def test_error_in_error_handler_no_infinite_loop(): """Error while processing error.execution should not cause infinite loop.""" sm = ErrorInErr...
{sm.s2}
assert
collection
tests/test_error_execution.py
test_error_in_error_handler_no_infinite_loop
190
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 TestFutureEdgeCases: @pytest.mark.asyncio() async def test_concurrent_sends_via_gather(self): """Two ...
"result_1"
assert
string_literal
tests/test_async_futures.py
test_concurrent_sends_via_gather
TestFutureEdgeCases
191
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 TestTransitionNotAllowedRouting: @pytest.mark.asyncio() async def test_transition_not_allowed(self): ...
"went"
assert
string_literal
tests/test_async_futures.py
test_transition_not_allowed
TestTransitionNotAllowedRouting
131
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 TestFutureEdgeCases: @pytest.mark.asyncio() async def test_initial_activation_no_future(self): """act...
sm.configuration_values
assert
complex_expr
tests/test_async_futures.py
test_initial_activation_no_future
TestFutureEdgeCases
146
null
fgmacedo/python-statemachine
import pytest from statemachine.orderedset import OrderedSet from statemachine import State from statemachine import StateChart def sm_class(): class SM(StateChart): pending = State(initial=True) waiting_approval = State() approved = State(final=True) start = pending.to(waiting_ap...
[1, 2, 3, 4, 5, 6]
assert
collection
tests/test_state.py
test_ordered_set_union
70
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 TestClassLevelListeners: def test_class_level_listener_shared_instance(self): shared = RecordingListener() cla...
shared
assert
variable
tests/test_class_listeners.py
test_class_level_listener_shared_instance
TestClassLevelListeners
75
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...
""
assert
string_literal
tests/test_contrib_diagram.py
test_multi_target_transition_diagram
343
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...
"frodo"
assert
string_literal
tests/test_statechart_donedata.py
test_donedata_callable_returns_dict
TestDoneData
44
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", "B", "activated")
assert
collection
tests/test_signature.py
test_support_for_partial
TestSignatureAdapter
163
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 TestTimeoutValidation: def test_positive_duration(self): t = timeout(5) assert isinstance(t, _...
5
assert
numeric_literal
tests/test_contrib_timeout.py
test_positive_duration
TestTimeoutValidation
17
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_model_with_custom_bool_is_not_replaced(campaign_machine): class Falsey...
model
assert
variable
tests/test_statemachine.py
test_model_with_custom_bool_is_not_replaced
542
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...
None
assert
none_literal
tests/test_async.py
test_async_engine_start_noop_when_already_initialized
455
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_machine_should_list_allowed_events_in_the_current_state(campaign_machine):...
[]
assert
collection
tests/test_statemachine.py
test_machine_should_list_allowed_events_in_the_current_state
173
null
fgmacedo/python-statemachine
import pytest from statemachine import exceptions def BaseMachine(): from statemachine import State from statemachine import StateChart class BaseMachine(StateChart): state_1 = State(initial=True) state_2 = State() trans_1_2 = state_1.to(state_2) trans_2_2 = state_2.to.its...
exceptions.InvalidDefinition)
pytest.raises
complex_expr
tests/test_statemachine_inheritance.py
test_dont_support_overriden_states
101
null
fgmacedo/python-statemachine
from collections import Counter import pytest from statemachine.contrib.weighted import _make_weighted_cond from statemachine.contrib.weighted import _WeightedGroup from statemachine.contrib.weighted import to from statemachine.contrib.weighted import weighted_transitions from statemachine import State from statemach...
sm.log
assert
complex_expr
tests/test_weighted_transitions.py
test_kwargs_forwarded_to_transition
TestWeightedTransitionsValidation
309
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...
[("s1", "s2")]
assert
collection
tests/test_transition_list.py
test_transition_list_or_operator
22
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...
{sm.error_state}
assert
collection
tests/test_async.py
test_async_catch_errors_as_events_in_condition
230
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...
expected
assert
variable
tests/test_signature.py
test_wrap_fn_single_positional_parameter
TestSignatureAdapter
157
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...
len(sm2._listeners)
assert
func_call
tests/test_copy.py
test_copy_with_listeners
111
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestMultipleValidators: async def test_second_validator_fails(self, sm_runner): """First passes, second fails.""" sm = await sm_runner.start(MultiValidator) with pytest.raises(
ValueError, match="B failed")
pytest.raises
complex_expr
tests/test_validators.py
test_second_validator_fails
TestMultipleValidators
191
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart from statemachine import exceptions def test_order_control(OrderControl): control = OrderControl() assert control.add_to_order(3) ==
3
assert
numeric_literal
tests/test_multiple_destinations.py
test_order_control
231
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...
"<scxml/>"
assert
string_literal
tests/test_scxml_units.py
test_resolve_content_from_file
TestSCXMLInvoker
427
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_name_derived_from_identifier(self): class TrafficLightMachine(StateChart): "A traffic l...
"go"
assert
string_literal
tests/test_events.py
test_name_derived_from_identifier
TestExplicitEvent
205
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestParallelStates: def war_of_the_ring_cls(self): class WarOfTheRing(StateChart): class war(State.Parallel): class frodos_quest(State.Compound): shire = State(initial=Tr...
True
assert
bool_literal
tests/test_statechart_parallel.py
test_top_level_parallel_terminates_when_all_children_final
TestParallelStates
225
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 test_list_machine_events(classic_traffic_light_machine): machine = classic_traffic_light_machine() ...
["slowdown", "stop", "go"]
assert
collection
tests/test_transitions.py
test_list_machine_events
22
null
fgmacedo/python-statemachine
import pytest from statemachine import exceptions def BaseMachine(): from statemachine import State from statemachine import StateChart class BaseMachine(StateChart): state_1 = State(initial=True) state_2 = State() trans_1_2 = state_1.to(state_2) trans_2_2 = state_2.to.its...
expected
assert
variable
tests/test_statemachine_inheritance.py
test_should_inherit_states_and_transitions
74
null
fgmacedo/python-statemachine
from dataclasses import dataclass from enum import Enum from statemachine.states import States from statemachine import State from statemachine import StateChart def main(): # type: ignore[attr-defined] # By binding the events to the User model, the events can be fired directly from the model user = User(na...
True
assert
bool_literal
tests/examples/user_machine.py
main
124
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 TrafficLightMachine(StateChart): green = State(initial=True) yellow = State() red = State() def on_cyc...
event
assert
variable
tests/test_events.py
on_cycle
TrafficLightMachine
22
null
fgmacedo/python-statemachine
from unittest import mock import pytest def django_autodiscover_modules(): auto_discover_modules = mock.MagicMock() with mock.patch("statemachine.registry.autodiscover_modules", new=auto_discover_modules): yield auto_discover_modules def test_should_register_a_state_machine(caplog, django_autodiscov...
registry._REGISTRY
assert
complex_expr
tests/test_registry.py
test_should_register_a_state_machine
29
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...
{}
assert
collection
tests/test_scxml_units.py
test_param_without_expr_or_location_skipped
TestSCXMLInvokerEvaluateParamsNoExprNoLocation
1,002
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 TestFutureEdgeCases: @pytest.mark.asyncio() async def test_allow_event_without_transition_resolves_none(self)...
None
assert
none_literal
tests/test_async_futures.py
test_allow_event_without_transition_resolves_none
TestFutureEdgeCases
157
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
assert
variable
tests/test_rtc.py
test_should_preserve_event_order
TestAsyncEngineRTC
216
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestCompoundStates: async def test_transition_within_compound(self, sm_runner): """Inner state changes while parent stays active.""" class ShireToRivendell(StateChart): class shire(State.Compound):...
sm.configuration_values
assert
complex_expr
tests/test_statechart_compound.py
test_transition_within_compound
TestCompoundStates
49
null
fgmacedo/python-statemachine
import pytest from statemachine.io.scxml.processor import SCXMLProcessor from statemachine.state import State from statemachine import StateChart MICROWAVE_SCXML = """ <scxml initial="unplugged"> <state id="unplugged"> <transition event="plug-in" target="plugged-in"/> </state> <state id="plugged-in"> <...
sm.current_state_value
assert
complex_expr
tests/scxml/test_microwave.py
test_microwave_scxml
43
null
fgmacedo/python-statemachine
import pytest from statemachine import HistoryState from statemachine import State from statemachine import StateChart class TestHistoryStates: async def test_history_values_dict_populated(self, sm_runner): """sm.history_values[history_id] has saved states after exit.""" class GollumPersonality(...
1
assert
numeric_literal
tests/test_statechart_history.py
test_history_values_dict_populated
TestHistoryStates
203
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.__name__
assert
complex_expr
tests/test_dispatcher.py
test_return_same_object_if_already_a_callable
TestEnsureCallable
63
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 TestDoneInvokeEventFormat: async def test_done_i...
1
assert
numeric_literal
tests/test_invoke.py
test_done_invoke_event_has_no_duplicate_state_id
TestDoneInvokeEventFormat
327
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart def simple_sm_cls(): class TestStateMachine(StateChart): allow_event_without_transition = True # States initial = State(initial=True) final = State(final=True, enter="do_enter_final") finish ...
True
assert
bool_literal
tests/test_callbacks_isolation.py
test_should_actions_be_isolated
TestCallbacksIsolation
62
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_ignores_unknown_kwargs(self): class MyChart(StateChart): listener...
"db"
assert
string_literal
tests/test_class_listeners.py
test_setup_ignores_unknown_kwargs
TestListenerSetupProtocol
256
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 TestClassListenerInheritance: def test_grandchild_inherits_full_chain(self): class L1: pass class ...
3
assert
numeric_literal
tests/test_class_listeners.py
test_grandchild_inherits_full_chain
TestClassListenerInheritance
209
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestCompoundStates: async def test_enter_compound_activates_initial_child(self, sm_runner): """Entering a compound activates both parent and the initial child.""" class ShireToRivendell(StateChart): ...
set(sm.configuration_values)
assert
func_call
tests/test_statechart_compound.py
test_enter_compound_activates_initial_child
TestCompoundStates
32
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart def simple_sm_cls(): class TestStateMachine(StateChart): allow_event_without_transition = True # States initial = State(initial=True) final = State(final=True, enter="do_enter_final") finish ...
("sm1", True)
assert
collection
tests/test_callbacks_isolation.py
test_should_actions_be_isolated
TestCallbacksIsolation
71
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestParallelStates: def war_of_the_ring_cls(self): class WarOfTheRing(StateChart): class war(State.Parallel): class frodos_quest(State.Compound): shire = State(initial=Tr...
sm.configuration_values
assert
complex_expr
tests/test_statechart_parallel.py
test_exit_parallel_exits_all_regions
TestParallelStates
100
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...
("ev1", "s0", "t0")
assert
collection
tests/test_signature.py
test_positional_or_keyword_prefers_kwargs_over_positional
TestCachedBindExpected
238
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 TestTransitionNotAllowedRouting: @pytest.mark.asyncio() async def test_transition_not_allowed(self): ...
sm.TransitionNotAllowed)
pytest.raises
complex_expr
tests/test_async_futures.py
test_transition_not_allowed
TestTransitionNotAllowedRouting
134
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...
func.__name__
assert
complex_expr
tests/test_signature.py
test_wrap_fn_single_positional_parameter
TestSignatureAdapter
151
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import State from statemachine import StateChart def test_conditions_algebra_any_false(): sm = AnyConditionSM() with pytest.raises(
sm.TransitionNotAllowed)
pytest.raises
complex_expr
tests/test_conditions_algebra.py
test_conditions_algebra_any_false
23
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart from statemachine import exceptions def test_check_invalid_reference_to_conditions(): class ApprovalMachine(StateChart): "A workflow" catch_errors_as_events = False requested = State(initial=True) ac...
exceptions.InvalidDefinition)
pytest.raises
complex_expr
tests/test_multiple_destinations.py
test_check_invalid_reference_to_conditions
113
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import Event from statemachine import State from statemachine import StateChart def test_error_data_available_in_error_execution_handler(): """The error object should be available in the error.execution event kwargs.""" rece...
1
assert
numeric_literal
tests/test_error_execution.py
test_error_data_available_in_error_execution_handler
224
null
fgmacedo/python-statemachine
import pytest from statemachine.orderedset import OrderedSet from statemachine import State from statemachine import StateChart def sm_class(): class SM(StateChart): pending = State(initial=True) waiting_approval = State() approved = State(final=True) start = pending.to(waiting_ap...
"Pending"
assert
string_literal
tests/test_state.py
test_name_derived_from_id
TestState
23
null
fgmacedo/python-statemachine
from statemachine.io import _parse_history from statemachine.io import create_machine_class_from_definition class TestCreateMachineWithEventNameConcat: def test_transition_with_both_parent_and_own_event_name(self): """Transition inside 'on' dict that also has its own 'event' key concatenates names.""" ...
event_ids
assert
variable
tests/test_io.py
test_transition_with_both_parent_and_own_event_name
TestCreateMachineWithEventNameConcat
45
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_explicit_id_takes_precedence(self): """Explicit id='error.execution' is preserved, convention does ...
{sm.fallen}
assert
collection
tests/test_error_execution.py
test_explicit_id_takes_precedence
TestErrorConventionLOTR
368
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...
((), {"key": "val3"})
assert
collection
tests/test_signature.py
test_empty_var_positional
TestCachedBindExpected
262
null
fgmacedo/python-statemachine
from unittest import mock import pytest def event_mock(): return mock.MagicMock() def traffic_light_machine(event_mock): # noqa: C901 from statemachine import State from statemachine import StateChart class TrafficLightMachineStateEvents(StateChart): "A traffic light machine" green...
"green"
assert
string_literal
tests/test_state_callbacks.py
assert_is_green_from_state
TestStateCallbacks
80
null
fgmacedo/python-statemachine
import pytest from statemachine.io.scxml.processor import SCXMLProcessor from statemachine.state import State from statemachine import StateChart MICROWAVE_SCXML = """ <scxml initial="unplugged"> <state id="unplugged"> <transition event="plug-in" target="plugged-in"/> </state> <state id="plugged-in"> <...
{*sm.current_state_value}
assert
collection
tests/scxml/test_microwave.py
test_microwave
TestMicrowave
112
null
fgmacedo/python-statemachine
import pytest from statemachine import HistoryState from statemachine import State from statemachine import StateChart class TestHistoryStates: async def test_history_values_dict_populated(self, sm_runner): """sm.history_values[history_id] has saved states after exit.""" class GollumPersonality(...
sm.history_values
assert
complex_expr
tests/test_statechart_history.py
test_history_values_dict_populated
TestHistoryStates
201
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart from statemachine import exceptions def test_order_control(OrderControl): control = OrderControl() assert control.add_to_order(3) == 3 assert control.add_to_order(7) == 10 control.receive_payment(4) with pytest.rais...
exceptions.TransitionNotAllowed)
pytest.raises
complex_expr
tests/test_multiple_destinations.py
test_order_control
235
null
fgmacedo/python-statemachine
from unittest import mock import pytest def event_mock(): return mock.MagicMock() def traffic_light_machine(event_mock): # noqa: C901 from statemachine import State from statemachine import StateChart class TrafficLightMachineStateEvents(StateChart): "A traffic light machine" green...
machine)
assert_*
variable
tests/test_state_callbacks.py
test_should_call_on_enter_of_specific_state
TestStateCallbacks
69
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, 2, 3)
assert
collection
tests/test_scxml_units.py
test_data_returns_tuple_for_multiple_args
TestEventDataWrapperMultipleArgs
283
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import Event from statemachine import State from statemachine import StateChart class TestErrorHandlerBehaviorLOTR: def test_error_handler_can_set_machine_attributes(self): """The `on` handler on error.execution can mod...
"flooded"
assert
string_literal
tests/test_error_execution.py
test_error_handler_can_set_machine_attributes
TestErrorHandlerBehaviorLOTR
837
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 TestFutureEdgeCases: @pytest.mark.asyncio() async def test_concurrent_sends_via_gather(self): """Two ...
"result_2"
assert
string_literal
tests/test_async_futures.py
test_concurrent_sends_via_gather
TestFutureEdgeCases
192
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_name_derived_from_identifier(self): class TrafficLightMachine(StateChart): "A traffic l...
"stop"
assert
string_literal
tests/test_events.py
test_name_derived_from_identifier
TestExplicitEvent
204
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...
expected)
pytest.raises
variable
tests/test_signature.py
test_wrap_fn_single_positional_parameter
TestSignatureAdapter
154
null
fgmacedo/python-statemachine
from collections import Counter import pytest from statemachine.contrib.weighted import _make_weighted_cond from statemachine.contrib.weighted import _WeightedGroup from statemachine.contrib.weighted import to from statemachine.contrib.weighted import weighted_transitions from statemachine import State from statemach...
(s2, 70, {})
assert
collection
tests/test_weighted_transitions.py
test_to_returns_tuple
TestWeightedTransitionsValidation
347
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") | ...
["t1", [None, None, None]]
assert
collection
tests/test_rtc.py
test_should_preserve_event_order
TestAsyncEngineRTC
215
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...
1
assert
numeric_literal
tests/test_contrib_diagram.py
test_history_state_default_transition
286
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_multiple_ids_from_the_same_event_will_be_converted_to_multiple_events(self): class TrafficLightMach...
"Go"
assert
string_literal
tests/test_events.py
test_multiple_ids_from_the_same_event_will_be_converted_to_multiple_events
TestExplicitEvent
230
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
string_literal
tests/test_events.py
test_accept_event_instance
TestExplicitEvent
45
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 TestExceptionRouting: @pytest.mark.asyncio() async def test_exception_reaches_caller(self): """When c...
ValueError, match="broken")
pytest.raises
complex_expr
tests/test_async_futures.py
test_exception_reaches_caller
TestExceptionRouting
108
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", "peril", "expect_wound"), [ pytest.param( Aragorn(), OrcAmbush("Poisoned orc blade"),...
expect_wound
assert
variable
tests/test_fellowship_quest.py
test_wound_description
342
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 class TestDecorators: @pytest.mark.parametrize(...
[expected_value]
assert
collection
tests/test_transition_list.py
test_should_assign_callback_to_transitions
TestDecorators
65
null
fgmacedo/python-statemachine
import pytest from statemachine import HistoryState from statemachine import State from statemachine import StateChart class TestHistoryStates: async def test_history_values_dict_populated(self, sm_runner): """sm.history_values[history_id] has saved states after exit.""" class GollumPersonality(...
"gollum"
assert
string_literal
tests/test_statechart_history.py
test_history_values_dict_populated
TestHistoryStates
204
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import TransitionNotAllowed from workflow.models import WorkflowSteps from workflow.statemachines import WorfklowStateMachine pytestmark = [ pytest.mark.django_db, ] def Workflow(): from workflow.models import Workflow return Workflow def User(): from djan...
WorkflowSteps.PUBLISHED
assert
complex_expr
tests/django_project/workflow/tests.py
test_should_publish
TestWorkflow
66
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 TestFutureEdgeCases: @pytest.mark.asyncio() async def test_separate_tasks_validator_exception_routing(self): ...
"noop ok"
assert
string_literal
tests/test_async_futures.py
test_separate_tasks_validator_exception_routing
TestFutureEdgeCases
322
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...
"shallow"
assert
string_literal
tests/test_io.py
test_history_without_transitions
TestParseHistory
12
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 TestInvokeNamingConvention: async def test_namin...
[True]
assert
collection
tests/test_invoke.py
test_naming_convention
TestInvokeNamingConvention
74
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestParallelStates: def war_of_the_ring_cls(self): class WarOfTheRing(StateChart): class war(State.Parallel): class frodos_quest(State.Compound): shire = State(initial=Tr...
expected
assert
variable
tests/test_statechart_parallel.py
test_current_state_value_set_comparison
TestParallelStates
133
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 test_transition_call_can_only_be_used_as_decorator(): source, dest = State("Source"), State("Destin...
TypeError)
pytest.raises
variable
tests/test_transitions.py
test_transition_call_can_only_be_used_as_decorator
68
null
fgmacedo/python-statemachine
import pytest from statemachine import Event from statemachine import State from statemachine import StateChart class TestErrorExecutionStatechart: async def test_error_recovery_exits_compound(self, sm_runner): """error.execution transition leaves compound state entirely.""" class CompoundRecove...
sm.configuration_values
assert
complex_expr
tests/test_statechart_error.py
test_error_recovery_exits_compound
TestErrorExecutionStatechart
83
null
fgmacedo/python-statemachine
import pytest from statemachine.io.scxml.processor import SCXMLProcessor from statemachine.state import State from statemachine import StateChart MICROWAVE_SCXML = """ <scxml initial="unplugged"> <state id="unplugged"> <transition event="plug-in" target="plugged-in"/> </state> <state id="plugged-in"> <...
True
assert
bool_literal
tests/scxml/test_microwave.py
test_microwave
TestMicrowave
113
null
fgmacedo/python-statemachine
import pytest from statemachine import State from statemachine import StateChart class TestCompoundStates: async def test_callbacks_inside_compound_class(self, sm_runner): """Methods defined inside the State.Compound class body are discovered.""" log = [] class CallbackDiscovery(StateCha...
["entered troubled times"]
assert
collection
tests/test_statechart_compound.py
test_callbacks_inside_compound_class
TestCompoundStates
267
null
fgmacedo/python-statemachine
import pytest from statemachine.exceptions import InvalidDefinition from statemachine import Event from statemachine import State from statemachine import StateChart def test_exception_in_on_enter_sends_error_execution(): """Exception in on_enter sends error.execution and rolls back configuration.""" sm = Err...
{sm.s1}
assert
collection
tests/test_error_execution.py
test_exception_in_on_enter_sends_error_execution
118
null
fgmacedo/python-statemachine
import pytest from statemachine import Event from statemachine import State from statemachine import StateChart class TestErrorExecutionStatechart: async def test_error_in_compound_child_onentry(self, sm_runner): """Error in on_enter of compound child fires error.execution.""" class CompoundError...
set(sm.configuration_values)
assert
func_call
tests/test_statechart_error.py
test_error_in_compound_child_onentry
TestErrorExecutionStatechart
35
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_fires_done_state_with_data(self, sm_runner): """done.state event fires and triggers a transitio...
set(sm.configuration_values)
assert
func_call
tests/test_statechart_donedata.py
test_donedata_fires_done_state_with_data
TestDoneData
64
null