updated unit tests and travis config for python 2.6 and 3

This commit is contained in:
cash 2014-01-11 15:52:46 -05:00
parent c449e3f8e1
commit 30ff4319e2
6 changed files with 19 additions and 20 deletions

View file

@ -17,7 +17,9 @@ env:
- TEST_LIST_SLUG=team - TEST_LIST_SLUG=team
- TEST_LIST_OWNER_SCREEN_NAME=twitterapi - TEST_LIST_OWNER_SCREEN_NAME=twitterapi
- ACCESS_TOKEN_B64=U2FsdGVkX18QdBhvMNshM4PGy04tU3HLwKP+nNSoNZHKsvGLjELcWEXN2LIu/T+yngX1vGONf9lo14ElnfS4k7sfhiru8phR4+rZuBVP3bDvC2A6fXJuhuLqNhBrWqg32WQewvxLWDWBoKmnvRHg5b74GHh+IN/12tU0cBF2HK8= - 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 script: nosetests -v -w tests/ --logging-filter="twython" --with-cov --cov twython --cov-config .coveragerc --cov-report term-missing
notifications: notifications:
email: false email: false

View file

@ -1,5 +1,11 @@
import os 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_key = os.environ.get('APP_KEY')
app_secret = os.environ.get('APP_SECRET') app_secret = os.environ.get('APP_SECRET')
oauth_token = os.environ.get('OAUTH_TOKEN') oauth_token = os.environ.get('OAUTH_TOKEN')

View file

@ -1,8 +1,6 @@
from twython import Twython, TwythonError, TwythonAuthError from twython import Twython, TwythonError, TwythonAuthError
from .config import app_key, app_secret, screen_name from .config import app_key, app_secret, screen_name, unittest
import unittest
class TwythonAuthTestCase(unittest.TestCase): class TwythonAuthTestCase(unittest.TestCase):

View file

@ -1,21 +1,17 @@
from twython import Twython, TwythonError, TwythonAuthError from twython import Twython, TwythonError, TwythonAuthError
from .config import ( 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 responses
import requests import requests
try: from twython.compat import is_py2
import io.StringIO as StringIO if is_py2:
except ImportError: from StringIO import StringIO
import StringIO else:
from io import StringIO
try: try:
import unittest.mock as mock import unittest.mock as mock
@ -141,7 +137,7 @@ class TwythonAPITestCase(unittest.TestCase):
url = self.get_url(endpoint) url = self.get_url(endpoint)
responses.add(responses.POST, url) 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.api.request(endpoint, method='POST', params={'image': mock_file})
self.assertIn('filename="image"', responses.calls[0].request.body) self.assertIn('filename="image"', responses.calls[0].request.body)

View file

@ -4,11 +4,10 @@ from .config import (
app_key, app_secret, oauth_token, oauth_token_secret, app_key, app_secret, oauth_token, oauth_token_secret,
protected_twitter_1, protected_twitter_2, screen_name, protected_twitter_1, protected_twitter_2, screen_name,
test_tweet_id, test_list_slug, test_list_owner_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 time
import unittest
class TwythonEndpointsTestCase(unittest.TestCase): class TwythonEndpointsTestCase(unittest.TestCase):

View file

@ -1,11 +1,9 @@
from twython import TwythonStreamer, TwythonStreamError from twython import TwythonStreamer, TwythonStreamError
from .config import ( 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): class TwythonStreamTestCase(unittest.TestCase):
def setUp(self): def setUp(self):