def test_httpretty_bypasses_when_disabled(context):
"httpretty should bypass all requests by disabling it"
httpretty.register_uri(
httpretty.GET, "http://localhost:{0}/go-for-bubbles/".format(context.http_port),
body="glub glub")
httpretty.disable()
fd = urllib2.urlopen('http://localhost:{0}/go-for-bubbles/'.format(context.http_port))
got1 = fd.read()
fd.close()
expect(got1).to.equal(
b'. o O 0 O o . o O 0 O o . o O 0 O o . o O 0 O o . o O 0 O o .')
fd = urllib2.urlopen('http://localhost:{0}/come-again/'.format(context.http_port))
got2 = fd.read()
fd.close()
expect(got2).to.equal(b'<- HELLO WORLD ->')
httpretty.enable()
fd = urllib2.urlopen('http://localhost:{0}/go-for-bubbles/'.format(context.http_port))
got3 = fd.read()
fd.close()
expect(got3).to.equal(b'glub glub')
core.POTENTIAL_HTTP_PORTS.remove(context.http_port)
评论列表
文章目录