Skip to content

Commit

Permalink
python 2.7 comp. - Mock() only for py3k
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoepp committed Feb 15, 2015
1 parent 619a831 commit 2e7c100
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test_ts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from TwitterSearch import *

import unittest
from unittest.mock import Mock
import httpretty

class TwitterSearchTest(unittest.TestCase):
Expand Down Expand Up @@ -129,6 +128,10 @@ def test_TS_search_usertimeline_iterable(self):
def test_TS_search_tweets_iterable_callback(self):
""" Tests TwitterSearch.search_tweets_iterable(callback) by using TwitterSearchOrder class """

import sys
if sys.version_info[0] < 3:
self.assertTrue(True) # Dummy test for py2 doesn't have Mock class

httpretty.register_uri(httpretty.GET, self.search_url,
responses=[
httpretty.Response(streaming=True, status=200, content_type='text/json', body=self.apiAnsweringMachine('tests/mock-data/search/0.log')),
Expand All @@ -143,6 +146,8 @@ def test_TS_search_tweets_iterable_callback(self):
tso.set_count(4)
ts = self.createTS()

from unittest.mock import Mock

mock = Mock()
for tweet in ts.search_tweets_iterable(tso, callback=mock):
mock.assert_called_with(ts)
Expand Down

0 comments on commit 2e7c100

Please sign in to comment.