コード例 #1
0
def dummy_function_eof():
    return get_frameinfo()
コード例 #2
0
    def test_current(self):
        frameinfo = get_frameinfo()

        assert frameinfo.function == 'test_current'
コード例 #3
0
def dummy_function_multiline():  # Used for TestGetCallContext
    return get_frameinfo(
        depth=0
    )
コード例 #4
0
 def test_no_current_frame(self, mocked_currentframe):
     mocked_currentframe.side_effect = [None]
     with pytest.raises(ValueError):
         get_frameinfo(1)
コード例 #5
0
 def test_no_last_frame(self):
     # TODO: remove magic index
     # How to make sure that the last call to frame.f_back returns None?
     with pytest.raises(ValueError):
         get_frameinfo(37)
コード例 #6
0
    def test_future(self):
        frameinfo = get_frameinfo(-1)

        assert frameinfo.function == 'test_future'
コード例 #7
0
    def test_deep(self):
        frameinfo = get_frameinfo(6)

        assert frameinfo.function == 'runtest'
コード例 #8
0
 def dummy_staticmethod():
     return get_frameinfo()
コード例 #9
0
 def dummy_func(depth):
     return get_frameinfo(depth)
コード例 #10
0
 def dummy_classmethod(cls):
     return get_frameinfo()
コード例 #11
0
 def dummy_method(self):
     return get_frameinfo()
コード例 #12
0
 def _nested_function():
     return get_frameinfo()
コード例 #13
0
 def _closure():
     return get_frameinfo()
コード例 #14
0

class DummyClass():
    def dummy_method(self):
        return get_frameinfo()

    @classmethod
    def dummy_classmethod(cls):
        return get_frameinfo()

    @staticmethod
    def dummy_staticmethod():
        return get_frameinfo()


dummy_lambda = lambda: get_frameinfo()  # pylint: disable=unnecessary-lambda


class TestGetCallable:
    def test_function(self):
        frameinfo = dummy_function()

        callable_instance = get_callable(frameinfo)

        assert callable_instance.__name__ == 'dummy_function'

    def test_closure(self):
        frameinfo = dummy_closure()()

        callable_instance = get_callable(frameinfo)