Skip to content

Instantly share code, notes, and snippets.

@tomviner
Last active August 29, 2015 14:13
Show Gist options
  • Save tomviner/2f526511273f8a660585 to your computer and use it in GitHub Desktop.
Save tomviner/2f526511273f8a660585 to your computer and use it in GitHub Desktop.
import pytest
import httpretty
@pytest.yield_fixture
def mock_out_devpi():
httpretty.reset()
httpretty.enable()
# prevent all other urls, except those registered
httpretty.HTTPretty.allow_net_connect = False
hosts = ('pypi.local', 'pypi-zonza.company.local')
vidisdk_getjson_fixture = open('tests/package-getjson-fixture.json').read()
for host in hosts:
httpretty.register_uri(
httpretty.GET,
"http://{}/company/test/vidisdk".format(host),
body=vidisdk_getjson_fixture,
content_type="application/json")
yield
# clean-up phase
httpretty.disable()
httpretty.reset()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment