def test_lazy_missing(): lazycall = LazyCall(("doesnt", "exist", "attribute"), ("argument",), {"key": "value"}, False) exist = AttrDict() doesnt = AttrDict(exist=exist) obj = AttrDict(doesnt=doesnt) try: lazycall.resolve(obj) except AttributeError as e: assert "doesnt.exist" in e.message assert "attribute" in e.message assert "key" in e.message assert "value" in e.message assert "argument" in e.message assert repr(obj) in e.message else: should_never_run()
def test_not_really_complex(): sentinel = object() lazycall = LazyCall((), (sentinel,), {}, True, False) def sentinel_func(): should_never_run() def target(func): assert func is sentinel try: lazycall.resolve(target, sentinel_func) except exceptions.ExceptionInCallError as e: assert "sentinel_func" in e.message assert "target" in e.message assert "NoneType" in e.message else: should_never_run()
def test_exception_in_call(): lazycall = LazyCall(("herp", "derp"), ("positional_arg",), {"keyword": "kwarg"}, False) class SentinelException(Exception): pass def target(positional_arg, keyword): assert positional_arg == "positional_arg" assert keyword == "kwarg" raise SentinelException() herp = AttrDict(derp=target) obj = AttrDict(herp=herp) try: lazycall.resolve(obj) except exceptions.ExceptionInCallError as e: assert "SentinelException" in e.message assert "target" in e.message assert "herp.derp" in e.message else: should_never_run()
def my_conflict(event): should_never_run()
def my_command(event): should_never_run()
def handler2(event): should_never_run()
def derp(event): should_never_run()
def firstmainloop(event): should_never_run()
from crow2.test.util import should_never_run; should_never_run()
def sentinel_func(): should_never_run()
def secondmainloop(event): should_never_run()
from crow2.test.util import should_never_run should_never_run()