def test_patch_all_calls(capsys): p = Patcher() p.loads(""" def x(*args): pass x(1) def foo(**kwargs): pass foo(bar=2) """) p.patch(handler=pyintercept.print_) p.run() out, _err = capsys.readouterr() assert out == "(1,)\n{}\n()\n{'bar': 2}\n"
def test_patch_all_calls(capsys): p = Patcher() p.loads(""" def x(*args): pass x(1) def foo(**kwargs): pass foo(bar=2) """) p.patch(handler=pyintercept.print_) p.run() out, _err = capsys.readouterr() assert out == "(1,)\n{}\n()\n{'bar': 2}\n"
def test_not_patched(): p = Patcher() with pytest.raises(AssertionError): p.run() with pytest.raises(AssertionError): p.save('x.pyc')
def test_not_patched(): p = Patcher() with pytest.raises(AssertionError): p.run() with pytest.raises(AssertionError): p.save('x.pyc')