Example #1
0
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()
Example #2
0
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()
Example #3
0
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()
Example #4
0
 def my_conflict(event):
     should_never_run()
Example #5
0
 def my_command(event):
     should_never_run()
Example #6
0
 def handler2(event):
     should_never_run()
Example #7
0
 def derp(event):
     should_never_run()
Example #8
0
 def my_conflict(event):
     should_never_run()
Example #9
0
 def my_command(event):
     should_never_run()
Example #10
0
 def firstmainloop(event):
     should_never_run()
Example #11
0
 def derp(event):
     should_never_run()
Example #12
0
from crow2.test.util import should_never_run; should_never_run()
Example #13
0
 def sentinel_func():
     should_never_run()
Example #14
0
 def secondmainloop(event):
     should_never_run()
Example #15
0
 def firstmainloop(event):
     should_never_run()
Example #16
0
 def handler2(event):
     should_never_run()
Example #17
0
 def secondmainloop(event):
     should_never_run()
Example #18
0
from crow2.test.util import should_never_run
should_never_run()