Exemplo n.º 1
0
 def test_bug_1210(self):
     # Under pyarmor (an obfuscator), a function can have a "self" argument,
     # but then not have a "self" local.
     co = mock.Mock(co_name="a_co_name",
                    co_argcount=1,
                    co_varnames=["self"])
     frame = mock.Mock(f_code=co, f_locals={})
     assert qualname_from_frame(frame) == "unittest.mock.a_co_name"
Exemplo n.º 2
0
def get_qualname():
    """Helper to return qualname_from_frame for the caller."""
    stack = inspect.stack()[1:]
    if any(sinfo[0].f_code.co_name == "get_qualname" for sinfo in stack):
        # We're calling outselves recursively, maybe because we're testing
        # properties. Return an int to try to get back on track.
        return 17
    caller_frame = stack[0][0]
    return qualname_from_frame(caller_frame)
Exemplo n.º 3
0
def get_qualname():
    """Helper to return qualname_from_frame for the caller."""
    stack = inspect.stack()[1:]
    if any(sinfo[0].f_code.co_name == "get_qualname" for sinfo in stack):
        # We're calling outselves recursively, maybe because we're testing
        # properties. Return an int to try to get back on track.
        return 17
    caller_frame = stack[0][0]
    return qualname_from_frame(caller_frame)