Skip to content

Commit 66761b9

Browse files
committed
Tone: Improve test for content type
1 parent ba3067f commit 66761b9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

watson_developer_cloud/tone_analyzer_v3.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ def tone(self, text, tones=None, sentences=None, content_type='text/plain'):
7474
method='POST', headers=headers, url='/v3/tone', params=params,
7575
json=text, accept_json=True)
7676

77-
if content_type == 'text/html':
77+
# Use the equivalent of an 'else' rather than checking for explicit
78+
# 'text/html' so that the call is made and returns a meaningful error
79+
# for an invalid content type.
80+
if content_type != 'application/json':
7881
return self.request(
7982
method='POST', headers=headers, url='/v3/tone', params=params,
8083
data=text, accept_json=True)

0 commit comments

Comments
 (0)