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_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 file

@ -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 file

@ -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 file

@ -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 @@ class TwythonAPITestCase(unittest.TestCase):
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 file

@ -4,11 +4,10 @@ from .config import (
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 file

@ -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):