How to use the pdbpp.rebind_globals function in pdbpp

To help you get started, we’ve selected a few pdbpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pdbpp / pdbpp / testing / test_pdb.py View on Github external
def test_rebind_globals_with_partial():
    import functools

    global test_global
    test_global = 0

    def func(a, b):
        global test_global
        return a + b + test_global

    pfunc = functools.partial(func)
    assert pfunc(0, 0) == 0

    newglobals = globals().copy()
    newglobals['test_global'] = 1
    new = pdbpp.rebind_globals(pfunc, newglobals)
    assert new(1, 40) == 42
github pdbpp / pdbpp / testing / test_pdb.py View on Github external
def test_rebind_globals_annotations():
    exec("def func(ann: str = None): pass", globals())
    func = globals()["func"]

    sig = str(inspect.signature(func))
    if sys.version_info < (3, 5):
        assert sig == "(ann:str=None)"
    else:
        assert sig in (
             "(ann: str = None)",
             "(ann:str=None)",
        )
    new = pdbpp.rebind_globals(func, globals())
    assert str(inspect.signature(new)) == sig
github pdbpp / pdbpp / testing / test_pdb.py View on Github external
def test_hidden_pytest_frames():
    def s():
        __tracebackhide__ = True  # Ignored for set_trace in here.
        set_trace()
        return 'foo'

    def g(s=s):
        __tracebackhide__ = True
        return s()

    def k(g=g):
        return g()
    k = pdbpp.rebind_globals(k, {'__tracebackhide__': True})

    def fn():
        k()
        return 1

    check(fn, r"""
[NUM] > .*s()
github pdbpp / pdbpp / testing / test_pdb.py View on Github external
def test_rebind_globals_kwonly():
    exec("def func(*args, header=None): pass", globals())
    func = globals()["func"]

    sig = str(inspect.signature(func))
    assert sig == "(*args, header=None)"
    new = pdbpp.rebind_globals(func, globals())
    assert str(inspect.signature(new)) == sig
github pdbpp / pdbpp / testing / test_pdb.py View on Github external
def test_hidden_unittest_frames():

    def s(set_trace=set_trace):
        set_trace()
        return 'foo'

    def g(s=s):
        return s()
    g = pdbpp.rebind_globals(g, {'__unittest': True})

    def fn():
        return g()

    check(fn, r"""
[NUM] > .*s()