def test_can_inspect_last_request_with_ssl(now):
"HTTPretty.last_request is recorded even when mocking 'https' (SSL)"
HTTPretty.register_uri(HTTPretty.POST, "https://secure.github.com/",
body='{"repositories": ["HTTPretty", "lettuce"]}')
request = urllib2.Request(
'https://secure.github.com',
b'{"username": "gabrielfalcao"}',
{
'content-type': 'text/json',
},
)
fd = urlopen(request)
got = fd.read()
fd.close()
expect(HTTPretty.last_request.method).to.equal('POST')
expect(HTTPretty.last_request.body).to.equal(
b'{"username": "gabrielfalcao"}',
)
expect(HTTPretty.last_request.headers['content-type']).to.equal(
'text/json',
)
expect(got).to.equal(b'{"repositories": ["HTTPretty", "lettuce"]}')
评论列表
文章目录