python requests モジュールを使用してアプリケーションのドキュメントテストを行う際に問題があり、今まで取得できませんでした。応答本文が欠落している場合があります。しかし、ngrep でネットワーク リクエスト/レスポンスを見ると、レスポンス ボディが見えます。そのため、Pythonモジュールによって無視されているようです。これにより、私のドキュメントテストが非常に不安定になり、役に立たなくなります。
>>> response = requests.get('/api/v1/profile/%s/affiliations' % urllib.quote(profileId1))
>>> affiliations = response.json
>>> pprint(affiliations)
[{u'name': u'Affiliation A'},
{u'name': u'Affiliation B'}]
Failed example:
pprint(affiliations)
Differences (ndiff with -expected +actual):
+ None
- [{u'name': u'Affiliation A'},
- {u'name': u'Affiliation B'}]
ngrep トレースは次のようになります。
###########
T 127.0.0.1:62252 -> 127.0.0.1:9000 [AP]
GET /api/v1/profile/4fde28e80364cb830f649ee1/affiliations HTTP/1.1.
Host: localhost:9000.
Connection: close.
Accept-Encoding: identity, deflate, compress, gzip.
Accept: application/json.
User-Agent: python-requests/0.13.0.
.
##
T 127.0.0.1:9000 -> 127.0.0.1:62252 [AP]
HTTP/1.1 200 OK.
Content-Type: application/json; charset=utf-8.
Content-Length: 63.
.
[{"name":"Affiliation A"},{"name":"Affiliation B"}]
###########