Fixes #302 simplifies json decoding and handling of errors. Adds tests. #308
No reviewers
Labels
No labels
Bug
Enhancement
Feature Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: code/twython#308
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "add_error_tests"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This fixes the odd logic in the json decoding. I pushed the decoding burden onto the requests library.
I also cleaned up the logic for processing errors.
Unit tests added for the changes.
Coverage increased (+1.21%) when pulling
1e627f9fb1on cash:add_error_tests intoeed37be5d1on ryanmcgrath:master.Just so you know, this is on my radar, I've just had a hectic couple of weeks!
@cash Sorry it's taken me so long to get to this (I've been super busy with work.. a lot going on ;P)
Anyways, this looks good to go, except -- as far as decoding goes. Does retrieving Japanese characters (or any foreign characters for that matter) work? The decode was for if someone was say.. searching a Twitter term of foreign, non-english, characters (@ryanmcgrath could probably give you an example, he's more familiar with the whole decoding/character stuff)
That's my only concern about this pull request. :) Again, good work, thanks!
I don't have a working unit test for utf-8 yet. Here is an example I ran on this branch:
Results:
Link to tweet: https://twitter.com/tunecan/status/435789394440499200
This works because of the requests library.
json() method: https://github.com/kennethreitz/requests/blob/master/requests/models.py#L739
text() method: https://github.com/kennethreitz/requests/blob/master/requests/models.py#L702
Requests uses chardet to detect the encoding. If you wanted to force 'utf-8', it just takes a single line after getting the response back:
I don't think it is required because Twitter sets the charset in the header, but it also wouldn't hurt adding it.
Ah! Solid, thanks!