66import unittest
77import twitter
88
9- from apikey import (CONSUMER_KEY ,
10- CONSUMER_SECRET ,
11- ACCESS_TOKEN_KEY ,
12- ACCESS_TOKEN_SECRET )
9+ from . apikey import (CONSUMER_KEY ,
10+ CONSUMER_SECRET ,
11+ ACCESS_TOKEN_KEY ,
12+ ACCESS_TOKEN_SECRET )
1313
1414
1515@unittest .skipIf (not CONSUMER_KEY and not CONSUMER_SECRET , "No tokens provided" )
@@ -24,7 +24,7 @@ def setUp(self):
2424 cache = None )
2525 api .SetUrllib (self ._urllib )
2626 self ._api = api
27- print "Testing the API class. This test is time controlled"
27+ print ( "Testing the API class. This test is time controlled" )
2828
2929 def testTwitterError (self ):
3030 '''Test that twitter responses containing an error message are wrapped.'''
@@ -33,7 +33,7 @@ def testTwitterError(self):
3333 # Manually try/catch so we can check the exception's value
3434 try :
3535 self ._api .GetUserTimeline ()
36- except twitter .TwitterError , error :
36+ except twitter .TwitterError as error :
3737 # If the error message matches, the test passes
3838 self .assertEqual ('test error' , error .message )
3939 else :
@@ -42,7 +42,7 @@ def testTwitterError(self):
4242 def testGetUserTimeline (self ):
4343 '''Test the twitter.Api GetUserTimeline method'''
4444 time .sleep (8 )
45- print 'Testing GetUserTimeline'
45+ print ( 'Testing GetUserTimeline' )
4646 self ._AddHandler ('https://api.twitter.com/1.1/statuses/user_timeline.json?count=1&screen_name=kesuke' ,
4747 curry (self ._OpenTestData , 'user_timeline-kesuke.json' ))
4848 statuses = self ._api .GetUserTimeline (screen_name = 'kesuke' , count = 1 )
@@ -62,7 +62,7 @@ def testGetUserTimeline(self):
6262 def testGetStatus (self ):
6363 '''Test the twitter.Api GetStatus method'''
6464 time .sleep (8 )
65- print 'Testing GetStatus'
65+ print ( 'Testing GetStatus' )
6666 self ._AddHandler ('https://api.twitter.com/1.1/statuses/show.json?include_my_retweet=1&id=89512102' ,
6767 curry (self ._OpenTestData , 'show-89512102.json' ))
6868 status = self ._api .GetStatus (89512102 )
@@ -72,7 +72,7 @@ def testGetStatus(self):
7272 def testDestroyStatus (self ):
7373 '''Test the twitter.Api DestroyStatus method'''
7474 time .sleep (8 )
75- print 'Testing DestroyStatus'
75+ print ( 'Testing DestroyStatus' )
7676 self ._AddHandler ('https://api.twitter.com/1.1/statuses/destroy/103208352.json' ,
7777 curry (self ._OpenTestData , 'status-destroy.json' ))
7878 status = self ._api .DestroyStatus (103208352 )
@@ -81,7 +81,7 @@ def testDestroyStatus(self):
8181 def testPostUpdate (self ):
8282 '''Test the twitter.Api PostUpdate method'''
8383 time .sleep (8 )
84- print 'Testing PostUpdate'
84+ print ( 'Testing PostUpdate' )
8585 self ._AddHandler ('https://api.twitter.com/1.1/statuses/update.json' ,
8686 curry (self ._OpenTestData , 'update.json' ))
8787 status = self ._api .PostUpdate (u'Моё судно на воздушной подушке полно угрей' .encode ('utf8' ))
@@ -91,7 +91,7 @@ def testPostUpdate(self):
9191 def testPostRetweet (self ):
9292 '''Test the twitter.Api PostRetweet method'''
9393 time .sleep (8 )
94- print 'Testing PostRetweet'
94+ print ( 'Testing PostRetweet' )
9595 self ._AddHandler ('https://api.twitter.com/1.1/statuses/retweet/89512102.json' ,
9696 curry (self ._OpenTestData , 'retweet.json' ))
9797 status = self ._api .PostRetweet (89512102 )
@@ -100,7 +100,7 @@ def testPostRetweet(self):
100100 def testPostUpdateLatLon (self ):
101101 '''Test the twitter.Api PostUpdate method, when used in conjunction with latitude and longitude'''
102102 time .sleep (8 )
103- print 'Testing PostUpdateLatLon'
103+ print ( 'Testing PostUpdateLatLon' )
104104 self ._AddHandler ('https://api.twitter.com/1.1/statuses/update.json' ,
105105 curry (self ._OpenTestData , 'update_latlong.json' ))
106106 # test another update with geo parameters, again test somewhat arbitrary
@@ -114,7 +114,7 @@ def testPostUpdateLatLon(self):
114114 def testGetReplies (self ):
115115 '''Test the twitter.Api GetReplies method'''
116116 time .sleep (8 )
117- print 'Testing GetReplies'
117+ print ( 'Testing GetReplies' )
118118 self ._AddHandler ('https://api.twitter.com/1.1/statuses/user_timeline.json' ,
119119 curry (self ._OpenTestData , 'replies.json' ))
120120 statuses = self ._api .GetReplies ()
@@ -123,7 +123,7 @@ def testGetReplies(self):
123123 def testGetRetweetsOfMe (self ):
124124 '''Test the twitter.API GetRetweetsOfMe method'''
125125 time .sleep (8 )
126- print 'Testing GetRetweetsOfMe'
126+ print ( 'Testing GetRetweetsOfMe' )
127127 self ._AddHandler ('https://api.twitter.com/1.1/statuses/retweets_of_me.json' ,
128128 curry (self ._OpenTestData , 'retweets_of_me.json' ))
129129 retweets = self ._api .GetRetweetsOfMe ()
@@ -132,7 +132,7 @@ def testGetRetweetsOfMe(self):
132132 def testGetFriends (self ):
133133 '''Test the twitter.Api GetFriends method'''
134134 time .sleep (8 )
135- print 'Testing GetFriends'
135+ print ( 'Testing GetFriends' )
136136 self ._AddHandler ('https://api.twitter.com/1.1/friends/list.json?cursor=123' ,
137137 curry (self ._OpenTestData , 'friends.json' ))
138138 users = self ._api .GetFriends (cursor = 123 )
@@ -142,7 +142,7 @@ def testGetFriends(self):
142142 def testGetFollowers (self ):
143143 '''Test the twitter.Api GetFollowers method'''
144144 time .sleep (8 )
145- print 'Testing GetFollowers'
145+ print ( 'Testing GetFollowers' )
146146 self ._AddHandler ('https://api.twitter.com/1.1/followers/list.json?cursor=-1' ,
147147 curry (self ._OpenTestData , 'followers.json' ))
148148 users = self ._api .GetFollowers ()
@@ -162,7 +162,7 @@ def testGetFollowers(self):
162162 def testGetDirectMessages (self ):
163163 '''Test the twitter.Api GetDirectMessages method'''
164164 time .sleep (8 )
165- print 'Testing GetDirectMessages'
165+ print ( 'Testing GetDirectMessages' )
166166 self ._AddHandler ('https://api.twitter.com/1.1/direct_messages.json' ,
167167 curry (self ._OpenTestData , 'direct_messages.json' ))
168168 statuses = self ._api .GetDirectMessages ()
@@ -171,7 +171,7 @@ def testGetDirectMessages(self):
171171 def testPostDirectMessage (self ):
172172 '''Test the twitter.Api PostDirectMessage method'''
173173 time .sleep (8 )
174- print 'Testing PostDirectMessage'
174+ print ( 'Testing PostDirectMessage' )
175175 self ._AddHandler ('https://api.twitter.com/1.1/direct_messages/new.json' ,
176176 curry (self ._OpenTestData , 'direct_messages-new.json' ))
177177 status = self ._api .PostDirectMessage ('test' , u'Моё судно на воздушной подушке полно угрей' .encode ('utf8' ))
@@ -181,7 +181,7 @@ def testPostDirectMessage(self):
181181 def testDestroyDirectMessage (self ):
182182 '''Test the twitter.Api DestroyDirectMessage method'''
183183 time .sleep (8 )
184- print 'Testing DestroyDirectMessage'
184+ print ( 'Testing DestroyDirectMessage' )
185185 self ._AddHandler ('https://api.twitter.com/1.1/direct_messages/destroy.json' ,
186186 curry (self ._OpenTestData , 'direct_message-destroy.json' ))
187187 status = self ._api .DestroyDirectMessage (3496342 )
@@ -191,7 +191,7 @@ def testDestroyDirectMessage(self):
191191 def testCreateFriendship (self ):
192192 '''Test the twitter.Api CreateFriendship method'''
193193 time .sleep (8 )
194- print 'Testing CreateFriendship'
194+ print ( 'Testing CreateFriendship' )
195195 self ._AddHandler ('https://api.twitter.com/1.1/friendships/create.json' ,
196196 curry (self ._OpenTestData , 'friendship-create.json' ))
197197 user = self ._api .CreateFriendship ('dewitt' )
@@ -201,7 +201,7 @@ def testCreateFriendship(self):
201201 def testDestroyFriendship (self ):
202202 '''Test the twitter.Api DestroyFriendship method'''
203203 time .sleep (8 )
204- print 'Testing Destroy Friendship'
204+ print ( 'Testing Destroy Friendship' )
205205 self ._AddHandler ('https://api.twitter.com/1.1/friendships/destroy.json' ,
206206 curry (self ._OpenTestData , 'friendship-destroy.json' ))
207207 user = self ._api .DestroyFriendship ('dewitt' )
@@ -211,7 +211,7 @@ def testDestroyFriendship(self):
211211 def testGetUser (self ):
212212 '''Test the twitter.Api GetUser method'''
213213 time .sleep (8 )
214- print 'Testing GetUser'
214+ print ( 'Testing GetUser' )
215215 self ._AddHandler ('https://api.twitter.com/1.1/users/show.json?user_id=dewitt' ,
216216 curry (self ._OpenTestData , 'show-dewitt.json' ))
217217 user = self ._api .GetUser ('dewitt' )
@@ -287,8 +287,8 @@ def open(self, url, data=None):
287287 self ._opened = True
288288 return self ._handlers [url ]()
289289 else :
290- print url
291- print self ._handlers
290+ print ( url )
291+ print ( self ._handlers )
292292
293293 raise Exception ('Unexpected URL %s (Checked: %s)' % (url , self ._handlers ))
294294
0 commit comments