Permalink
Browse files

updated unit tests and travis config for python 2.6 and 3

  • Loading branch information...
1 parent c449e3f commit 30ff4319e2325cc6aaeb8b9ad4e404e087b0cd23 @cash cash committed Jan 11, 2014
Showing with 19 additions and 20 deletions.
  1. +3 −1 .travis.yml
  2. +6 −0 tests/config.py
  3. +1 −3 tests/test_auth.py
  4. +7 −11 tests/test_core.py
  5. +1 −2 tests/test_endpoints.py
  6. +1 −3 tests/test_streaming.py
View
@@ -17,7 +17,9 @@ env:
- TEST_LIST_SLUG=team
- TEST_LIST_OWNER_SCREEN_NAME=twitterapi
- ACCESS_TOKEN_B64=U2FsdGVkX18QdBhvMNshM4PGy04tU3HLwKP+nNSoNZHKsvGLjELcWEXN2LIu/T+yngX1vGONf9lo14ElnfS4k7sfhiru8phR4+rZuBVP3bDvC2A6fXJuhuLqNhBrWqg32WQewvxLWDWBoKmnvRHg5b74GHh+IN/12tU0cBF2HK8=
-install: pip install -r requirements.txt
+install:
+ - pip install -r requirements.txt
+ - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install unittest2; fi
script: nosetests -v -w tests/ --logging-filter="twython" --with-cov --cov twython --cov-config .coveragerc --cov-report term-missing
notifications:
email: false
View
@@ -1,5 +1,11 @@
import os
+import sys
+if sys.version_info[0] == 2 and sys.version_info[1] == 6:
+ import unittest2 as unittest
+else:
+ import unittest
+
app_key = os.environ.get('APP_KEY')
app_secret = os.environ.get('APP_SECRET')
oauth_token = os.environ.get('OAUTH_TOKEN')
View
@@ -1,8 +1,6 @@
from twython import Twython, TwythonError, TwythonAuthError
-from .config import app_key, app_secret, screen_name
-
-import unittest
+from .config import app_key, app_secret, screen_name, unittest
class TwythonAuthTestCase(unittest.TestCase):
View
@@ -1,21 +1,17 @@
from twython import Twython, TwythonError, TwythonAuthError
from .config import (
- test_tweet_object, test_tweet_html
+ test_tweet_object, test_tweet_html, unittest
)
-try:
- import unittest2 as unittest
-except ImportError:
- import unittest
-
import responses
import requests
-try:
- import io.StringIO as StringIO
-except ImportError:
- import StringIO
+from twython.compat import is_py2
+if is_py2:
+ from StringIO import StringIO
+else:
+ from io import StringIO
try:
import unittest.mock as mock
@@ -141,7 +137,7 @@ def test_request_should_handle_file_as_parameter(self):
url = self.get_url(endpoint)
responses.add(responses.POST, url)
- mock_file = StringIO.StringIO("Twython test image")
+ mock_file = StringIO("Twython test image")
self.api.request(endpoint, method='POST', params={'image': mock_file})
self.assertIn('filename="image"', responses.calls[0].request.body)
View
@@ -4,11 +4,10 @@
app_key, app_secret, oauth_token, oauth_token_secret,
protected_twitter_1, protected_twitter_2, screen_name,
test_tweet_id, test_list_slug, test_list_owner_screen_name,
- access_token, test_tweet_object, test_tweet_html
+ access_token, test_tweet_object, test_tweet_html, unittest
)
import time
-import unittest
class TwythonEndpointsTestCase(unittest.TestCase):
View
@@ -1,11 +1,9 @@
from twython import TwythonStreamer, TwythonStreamError
from .config import (
- app_key, app_secret, oauth_token, oauth_token_secret
+ app_key, app_secret, oauth_token, oauth_token_secret, unittest
)
-import unittest
-
class TwythonStreamTestCase(unittest.TestCase):
def setUp(self):

0 comments on commit 30ff431

Please sign in to comment.