How to use the pook.disable function in pook

To help you get started, we’ve selected a few pook 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 h2non / pook / tests / integration / engines / pytest_suite.py View on Github external
def test_enable_engine():
    pook.get('server.com/foo').reply(204)
    res = requests.get('http://server.com/foo')
    assert res.status_code == 204
    pook.disable()
github h2non / pook / examples / pytest_example.py View on Github external
def test_enable_engine():
    pook.get('server.com/foo').reply(204)
    res = requests.get('http://server.com/foo')
    assert res.status_code == 204
    pook.disable()
github h2non / pook / examples / basic.py View on Github external
m = pook.get('http://httpbin.org/ip?foo=bar')
    m.type('application/json')
    m.type('application/xml')
    m.reply(404).json({'error': 'not found'})

    # Testing
    pook.activate()

    res = requests.get('http://httpbin.org/ip?foo=bar&baz=foo')
    print('Status:', res.status_code)
    print('Headers:', res.headers)
    print('Body:', res.text)

    # res = requests.get('http://httpbin.org/ip?foo=bar')
    print('Mock:', m)
    pook.disable()
    # res = requests.get('http://httpbin.org/ip')