Here are the examples of the python api sqlalchemy.testing.mock.call taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
96 Examples
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_exec_once(self):
m1 = Mock()
event.listen(self.Target, "event_one", m1)
t1 = self.Target()
t2 = self.Target()
t1.dispatch.event_one.for_modify(t1.dispatch).exec_once(5, 6)
t1.dispatch.event_one.for_modify(t1.dispatch).exec_once(7, 8)
t2.dispatch.event_one.for_modify(t2.dispatch).exec_once(9, 10)
eq_(m1.mock_calls, [call(5, 6), call(9, 10)])
def test_exec_once_exception(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_accept(self):
TargetOne = self._fixture()
canary = Mock()
@event.listens_for(TargetOne, "event_one", named=True)
def handler1(**kw):
canary(kw)
TargetOne().dispatch.event_one(4, 5)
eq_(canary.mock_calls, [call({"x": 4, "y": 5})])
def test_kw_accept_wrapped(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_accept_wrapped(self):
TargetOne = self._wrapped_fixture()
canary = Mock()
@event.listens_for(TargetOne, "event_one", named=True)
def handler1(**kw):
canary(kw)
TargetOne().dispatch.event_one(4, 5)
eq_(canary.mock_calls, [call({"y": "adapted 5", "x": "adapted 4"})])
def test_partial_kw_accept(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_partial_kw_accept(self):
TargetOne = self._fixture()
canary = Mock()
@event.listens_for(TargetOne, "event_five", named=True)
def handler1(z, y, **kw):
canary(z, y, kw)
TargetOne().dispatch.event_five(4, 5, 6, 7)
eq_(canary.mock_calls, [call(6, 5, {"x": 4, "q": 7})])
def test_partial_kw_accept_wrapped(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_accept_plus_kw(self):
TargetOne = self._fixture()
canary = Mock()
@event.listens_for(TargetOne, "event_two", named=True)
def handler1(**kw):
canary(kw)
TargetOne().dispatch.event_two(4, 5, z=8, q=5)
eq_(canary.mock_calls, [call({"x": 4, "y": 5, "z": 8, "q": 5})])
class LegacySignatureTest(fixtures.TestBase):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_legacy_accept(self):
canary = Mock()
@event.listens_for(self.TargetOne, "event_three")
def handler1(x, y):
canary(x, y)
self.TargetOne().dispatch.event_three(4, 5, 6, 7)
eq_(canary.mock_calls, [call(4, 5)])
def test_legacy_accept_kw_cls(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_legacy_accept_partial(self):
canary = Mock()
def evt(a, x, y, **kw):
canary(a, x, y, **kw)
from functools import partial
evt_partial = partial(evt, 5)
target = self.TargetOne()
event.listen(target, "event_four", evt_partial)
# can't do legacy accept on a partial; we can't inspect it
assert_raises(
TypeError, target.dispatch.event_four, 4, 5, 6, 7, foo="bar"
)
target.dispatch.event_four(4, 5, foo="bar")
eq_(canary.mock_calls, [call(5, 4, 5, foo="bar")])
def _test_legacy_accept_kw(self, target, canary):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def _test_legacy_accept_kw(self, target, canary):
target.dispatch.event_four(4, 5, 6, 7, foo="bar")
eq_(canary.mock_calls, [call(4, 5, {"foo": "bar"})])
def test_complex_legacy_accept(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_complex_legacy_accept(self):
canary = Mock()
@event.listens_for(self.TargetOne, "event_six")
def handler1(x, y, z, q):
canary(x, y, z, q)
self.TargetOne().dispatch.event_six(4, 5)
eq_(canary.mock_calls, [call(4, 5, 9, 20)])
def test_legacy_accept_from_method(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_legacy_accept_from_method(self):
canary = Mock()
class MyClass(object):
def handler1(self, x, y):
canary(x, y)
event.listen(self.TargetOne, "event_three", MyClass().handler1)
self.TargetOne().dispatch.event_three(4, 5, 6, 7)
eq_(canary.mock_calls, [call(4, 5)])
def test_standard_accept_has_legacies(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_standard_accept_has_legacies(self):
canary = Mock()
event.listen(self.TargetOne, "event_three", canary)
self.TargetOne().dispatch.event_three(4, 5)
eq_(canary.mock_calls, [call(4, 5)])
def test_kw_accept_has_legacies(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_accept_has_legacies(self):
canary = Mock()
@event.listens_for(self.TargetOne, "event_three", named=True)
def handler1(**kw):
canary(kw)
self.TargetOne().dispatch.event_three(4, 5, 6, 7)
eq_(canary.mock_calls, [call({"x": 4, "y": 5, "z": 6, "q": 7})])
def test_kw_accept_plus_kw_has_legacies(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_accept_plus_kw_has_legacies(self):
canary = Mock()
@event.listens_for(self.TargetOne, "event_four", named=True)
def handler1(**kw):
canary(kw)
self.TargetOne().dispatch.event_four(4, 5, 6, 7, foo="bar")
eq_(
canary.mock_calls,
[call({"x": 4, "y": 5, "z": 6, "q": 7, "foo": "bar"})],
)
class ClsLevelListenTest(fixtures.TestBase):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_listen_override(self):
listen_one = Mock()
listen_two = Mock()
event.listen(self.Target, "event_one", listen_one, add=True)
event.listen(self.Target, "event_one", listen_two)
t1 = self.Target()
t1.dispatch.event_one(5, 7)
t1.dispatch.event_one(10, 5)
eq_(listen_one.mock_calls, [call(12), call(15)])
eq_(listen_two.mock_calls, [call(5, 7), call(10, 5)])
def test_remove_clslevel(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_remove_clslevel(self):
listen_one = Mock()
event.listen(self.Target, "event_one", listen_one, add=True)
t1 = self.Target()
t1.dispatch.event_one(5, 7)
eq_(listen_one.mock_calls, [call(12)])
event.remove(self.Target, "event_one", listen_one)
t1.dispatch.event_one(10, 5)
eq_(listen_one.mock_calls, [call(12)])
def test_remove_instancelevel(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_remove_instancelevel(self):
listen_one = Mock()
t1 = self.Target()
event.listen(t1, "event_one", listen_one, add=True)
t1.dispatch.event_one(5, 7)
eq_(listen_one.mock_calls, [call(12)])
event.remove(t1, "event_one", listen_one)
t1.dispatch.event_one(10, 5)
eq_(listen_one.mock_calls, [call(12)])
class PropagateTest(fixtures.TestBase):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_kw_ok(self):
l1 = Mock()
def listen(**kw):
l1(kw)
event.listen(self.TargetFactory, "event_one", listen, named=True)
element = self.TargetFactory().create()
element.run_event(1)
element.run_event(2)
eq_(
l1.mock_calls,
[
call({"target": element, "arg": 1}),
call({"target": element, "arg": 2}),
],
)
def test_parent_class_only(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_class_only(self):
l1 = Mock()
event.listen(self.TargetFactory, "event_one", l1)
element = self.TargetFactory().create()
element.run_event(1)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
def test_parent_class_child_class(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_events_child_no_events(self):
l1 = Mock()
factory = self.TargetFactory()
event.listen(self.TargetElement, "event_one", l1)
element = factory.create()
element.run_event(1)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
class DisableClsPropagateTest(fixtures.TestBase):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_clslevel(self):
Target = self._fixture()
m1 = Mock()
event.listen(Target, "event_two", m1)
t1 = Target()
t1.dispatch.event_two("x")
event.remove(Target, "event_two", m1)
t1.dispatch.event_two("y")
eq_(m1.mock_calls, [call("x")])
def test_clslevel_subclass(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_remove_plain_named(self):
Target = self._fixture()
listen_one = Mock()
t1 = Target()
event.listen(t1, "event_one", listen_one, named=True)
t1.dispatch.event_one("t1")
eq_(listen_one.mock_calls, [call(x="t1")])
event.remove(t1, "event_one", listen_one)
t1.dispatch.event_one("t2")
eq_(listen_one.mock_calls, [call(x="t1")])
def test_remove_wrapped_named(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_remove_wrapped_named(self):
Target = self._wrapped_fixture()
listen_one = Mock()
t1 = Target()
event.listen(t1, "event_one", listen_one, named=True)
t1.dispatch.event_one("t1")
eq_(listen_one.mock_calls, [call(x="adapted t1")])
event.remove(t1, "event_one", listen_one)
t1.dispatch.event_one("t2")
eq_(listen_one.mock_calls, [call(x="adapted t1")])
def test_double_event_nonwrapped(self):
3
Source : test_firebird.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def _assert_retaining(self, engine, flag):
conn = engine.connect()
trans = conn.begin()
trans.commit()
eq_(
engine.dialect.dbapi.connect.return_value.commit.mock_calls,
[call(flag)],
)
trans = conn.begin()
trans.rollback()
eq_(
engine.dialect.dbapi.connect.return_value.rollback.mock_calls,
[call(flag)],
)
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_transaction_engine_ctx_begin_fails(self):
engine = engines.testing_engine()
mock_connection = Mock(
return_value=Mock(begin=Mock(side_effect=Exception("boom")))
)
engine._connection_cls = mock_connection
assert_raises(Exception, engine.begin)
eq_(mock_connection.return_value.close.mock_calls, [call()])
def test_transaction_engine_ctx_rollback(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dialect_conn_options(self):
engine = testing_engine("sqlite://", options=dict(_initialize=False))
engine.dialect = Mock()
conn = engine.connect()
c2 = conn.execution_options(foo="bar")
eq_(
engine.dialect.set_connection_execution_options.mock_calls,
[call(c2, {"foo": "bar"})],
)
def test_dialect_engine_options(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dialect_engine_options(self):
engine = testing_engine("sqlite://")
engine.dialect = Mock()
e2 = engine.execution_options(foo="bar")
eq_(
engine.dialect.set_engine_execution_options.mock_calls,
[call(e2, {"foo": "bar"})],
)
def test_dialect_engine_construction_options(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dialect_engine_construction_options(self):
dialect = Mock()
engine = Engine(
Mock(), dialect, Mock(), execution_options={"foo": "bar"}
)
eq_(
dialect.set_engine_execution_options.mock_calls,
[call(engine, {"foo": "bar"})],
)
def test_propagate_engine_to_connection(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_dispose_event(self):
canary = Mock()
eng = create_engine(testing.db.url)
event.listen(eng, "engine_disposed", canary)
conn = eng.connect()
conn.close()
eng.dispose()
conn = eng.connect()
conn.close()
eq_(canary.mock_calls, [call(eng)])
eng.dispose()
eq_(canary.mock_calls, [call(eng), call(eng)])
def test_retval_flag(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_engine_connect(self):
engine = engines.testing_engine()
tracker = Mock()
event.listen(engine, "engine_connect", tracker)
c1 = engine.connect()
c2 = c1._branch()
c1.close()
eq_(tracker.mock_calls, [call(c1, False), call(c2, True)])
def test_execution_options(self):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def _test_do_execute(self, retval):
with self._run_test(retval) as (conn, m1):
result = conn.execute("insert into table foo", {"foo": "bar"})
self._assert(
retval,
m1.do_execute,
m1.real_do_execute,
[
call(
result.context.cursor,
"insert into table foo",
{"foo": "bar"},
result.context,
)
],
)
def _test_do_executemany(self, retval):
3
Source : test_execute.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def _test_do_execute_no_params(self, retval):
with self._run_test(retval) as (conn, m1):
result = conn.execution_options(no_parameters=True).execute(
"insert into table foo"
)
self._assert(
retval,
m1.do_execute_no_params,
m1.real_do_execute_no_params,
[
call(
result.context.cursor,
"insert into table foo",
result.context,
)
],
)
def _test_cursor_execute(self, retval):
3
Source : test_pool.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_close(self):
p, canary = self._close_event_fixture()
c1 = p.connect()
connection = c1.connection
rec = c1._connection_record
c1.close()
eq_(canary.mock_calls, [])
p.dispose()
eq_(canary.mock_calls, [call(connection, rec)])
def test_detach(self):
3
Source : test_pool.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_detach(self):
p, canary = self._detach_event_fixture()
c1 = p.connect()
connection = c1.connection
rec = c1._connection_record
c1.detach()
eq_(canary.mock_calls, [call(connection, rec)])
def test_detach_close(self):
3
Source : test_pool.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_detach_close(self):
p, canary = self._close_detached_event_fixture()
c1 = p.connect()
connection = c1.connection
c1.detach()
c1.close()
eq_(canary.mock_calls, [call(connection)])
def test_first_connect_event(self):
3
Source : test_pool.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_detach(self):
dbapi, p = self._queuepool_dbapi_fixture(pool_size=1, max_overflow=0)
c1 = p.connect()
c1.detach()
c2 = p.connect() # noqa
eq_(dbapi.connect.mock_calls, [call("foo.db"), call("foo.db")])
c1_con = c1.connection
assert c1_con is not None
eq_(c1_con.close.call_count, 0)
c1.close()
eq_(c1_con.close.call_count, 1)
def test_detach_via_invalidate(self):
3
Source : test_pool.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_reconnect(self):
dbapi = MockDBAPI()
p = pool.NullPool(creator=lambda: dbapi.connect("foo.db"))
c1 = p.connect()
c1.close()
c1 = None
c1 = p.connect()
c1.invalidate()
c1 = None
c1 = p.connect()
dbapi.connect.assert_has_calls(
[call("foo.db"), call("foo.db")], any_order=True
)
class StaticPoolTest(PoolTestBase):
3
Source : test_reconnect.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def setup(self):
self.dbapi = MockDBAPI()
self.db = testing_engine(
"postgresql://foo:bar@localhost/test",
options=dict(module=self.dbapi, _initialize=False),
)
self.mock_connect = call(
host="localhost", password="bar", user="foo", database="test"
)
# monkeypatch disconnect checker
self.db.dialect.is_disconnect = lambda e, conn, cursor: isinstance(
e, MockDisconnect
)
def teardown(self):
3
Source : test_reconnect.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cursor_explode(self):
db = self._fixture(False, False)
conn = db.connect()
result = conn.execute("select foo")
result.close()
conn.close()
eq_(
db.pool.logger.error.mock_calls,
[call("Error closing cursor", exc_info=True)],
)
def test_cursor_shutdown_in_initialize(self):
3
Source : test_reconnect.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cursor_shutdown_in_initialize(self):
db = self._fixture(True, True)
assert_raises_message_context_ok(
exc.SAWarning, "Exception attempting to detect", db.connect
)
eq_(
db.pool.logger.error.mock_calls,
[call("Error closing cursor", exc_info=True)],
)
def _assert_invalidated(fn, *args):
3
Source : test_baked.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_cache_ok_for_event(self, modify_query_fixture):
m1 = modify_query_fixture(True)
User, Address = self._o2m_fixture()
sess = Session()
u1 = sess.query(User).filter(User.id == 7).first()
u1.addresses
eq_(m1.mock_calls, [mock.call(User), mock.call(Address)])
sess.expire(u1, ["addresses"])
u1.addresses
eq_(m1.mock_calls, [mock.call(User), mock.call(Address)])
def test_unsafe_unbound_option_cancels_bake(self):
3
Source : test_attributes.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_flag_modified(self):
canary = Mock()
class Foo(object):
pass
instrumentation.register_class(Foo)
attributes.register_attribute(Foo, "bar")
event.listen(Foo.bar, "modified", canary)
f1 = Foo()
f1.bar = "hi"
attributes.flag_modified(f1, "bar")
eq_(
canary.mock_calls,
[call(f1, attributes.Event(Foo.bar.impl, attributes.OP_MODIFIED))],
)
def test_none_init_scalar(self):
3
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_before_after_configured(self):
User, users = self.classes.User, self.tables.users
m1 = Mock()
m2 = Mock()
mapper(User, users)
event.listen(mapper, "before_configured", m1)
event.listen(mapper, "after_configured", m2)
s = Session()
s.query(User)
eq_(m1.mock_calls, [call()])
eq_(m2.mock_calls, [call()])
def test_instrument_event(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_exec_once_exception(self):
m1 = Mock()
m1.side_effect = ValueError
event.listen(self.Target, "event_one", m1)
t1 = self.Target()
assert_raises(
ValueError,
t1.dispatch.event_one.for_modify(t1.dispatch).exec_once,
5,
6,
)
t1.dispatch.event_one.for_modify(t1.dispatch).exec_once(7, 8)
eq_(m1.mock_calls, [call(5, 6)])
def test_exec_once_unless_exception(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_exec_once_unless_exception(self):
m1 = Mock()
m1.side_effect = ValueError
event.listen(self.Target, "event_one", m1)
t1 = self.Target()
assert_raises(
ValueError,
t1.dispatch.event_one.for_modify(
t1.dispatch
).exec_once_unless_exception,
5,
6,
)
assert_raises(
ValueError,
t1.dispatch.event_one.for_modify(
t1.dispatch
).exec_once_unless_exception,
7,
8,
)
m1.side_effect = None
t1.dispatch.event_one.for_modify(
t1.dispatch
).exec_once_unless_exception(9, 10)
t1.dispatch.event_one.for_modify(
t1.dispatch
).exec_once_unless_exception(11, 12)
eq_(m1.mock_calls, [call(5, 6), call(7, 8), call(9, 10)])
def test_immutable_methods(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_partial_kw_accept_wrapped(self):
TargetOne = self._wrapped_fixture()
canary = Mock()
@event.listens_for(TargetOne, "event_five", named=True)
def handler1(z, y, **kw):
canary(z, y, kw)
TargetOne().dispatch.event_five(4, 5, 6, 7)
eq_(
canary.mock_calls,
[
call(
"adapted 6",
"adapted 5",
{"q": "adapted 7", "x": "adapted 4"},
)
],
)
def test_kw_accept_plus_kw(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_propagate(self):
listen_one = Mock()
listen_two = Mock()
t1 = self.Target()
event.listen(t1, "event_one", listen_one, propagate=True)
event.listen(t1, "event_two", listen_two)
t2 = self.Target()
t2.dispatch._update(t1.dispatch)
t2.dispatch.event_one(t2, 1)
t2.dispatch.event_two(t2, 2)
eq_(listen_one.mock_calls, [call(t2, 1)])
eq_(listen_two.mock_calls, [])
class JoinTest(fixtures.TestBase):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_class_child_class(self):
l1 = Mock()
l2 = Mock()
event.listen(self.TargetFactory, "event_one", l1)
event.listen(self.TargetElement, "event_one", l2)
element = self.TargetFactory().create()
element.run_event(1)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
eq_(
l2.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
def test_parent_class_child_instance_apply_after(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_class_child_instance_apply_after(self):
l1 = Mock()
l2 = Mock()
event.listen(self.TargetFactory, "event_one", l1)
element = self.TargetFactory().create()
element.run_event(1)
event.listen(element, "event_one", l2)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
eq_(l2.mock_calls, [call(element, 2), call(element, 3)])
def test_parent_class_child_instance_apply_before(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_class_child_instance_apply_before(self):
l1 = Mock()
l2 = Mock()
event.listen(self.TargetFactory, "event_one", l1)
element = self.TargetFactory().create()
event.listen(element, "event_one", l2)
element.run_event(1)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
eq_(
l2.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
def test_parent_instance_child_class_apply_before(self):
0
Source : test_events.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_parent_instance_child_class_apply_before(self):
l1 = Mock()
l2 = Mock()
event.listen(self.TargetElement, "event_one", l2)
factory = self.TargetFactory()
event.listen(factory, "event_one", l1)
element = factory.create()
element.run_event(1)
element.run_event(2)
element.run_event(3)
eq_(
l1.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
eq_(
l2.mock_calls,
[call(element, 1), call(element, 2), call(element, 3)],
)
def test_parent_instance_child_class_apply_after(self):
See More Examples