Skip to content

Commit 0661dbf

Browse files
committed
Port to Python 3.3+
1 parent 5b76b36 commit 0661dbf

27 files changed

+3248
-125
lines changed

.gitignore

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
*.pyc
22
*.swp
3-
build/
4-
dist/
5-
tweepy.egg-info/
6-
.env/
3+
env.sh
74
.coverage
8-
htmlcov/
5+
.env
6+
.idea
7+
.pdbrc
8+
.tox
9+
build
10+
dist
11+
cassettes
12+
htmlcov
13+
tweepy.egg-info

CONTRIBUTORS

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Stuart Powers
3131
Jeff Hull (@jsh2134)
3232
Mike (mikeandmore)
3333
Kohei YOSHIDA
34-
34+
Mark Smith (@judy2k)

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include requirements.txt

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ Github and install it manually:
1818
cd tweepy
1919
python setup.py install
2020

21-
**Note** only Python 2.6 and 2.7 are supported at
22-
the moment. The Python 3 family is not yet supported.
21+
Python 2.6 and 2.7, 3.3 & 3.4 are supported.
2322

2423
Documentation
2524
-------------

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
requests>=2.0.0
2-
requests_oauthlib==0.4.0
1+
requests==2.3.0
2+
requests_oauthlib==0.4.1
3+
six==1.7.3

run_tests.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@
33
if [[ $TRAVIS_BRANCH == "production" ]]; then
44
nosetests -v --with-coverage tests.test_api tests.test_streaming tests.test_cursors tests.test_utils
55
else
6-
curl "https://dl.dropboxusercontent.com/u/231242/record.json" -o tests/record.json
7-
USE_REPLAY=1 nosetests -v tests.test_api tests.test_utils
6+
USE_REPLAY=1 nosetests -v --with-coverage tests.test_api tests.test_utils
87
fi

test_requirements.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
httreplay==0.1.4
2-
coveralls==0.2
3-
unittest2==0.5.1
1+
tox>=1.7.2
2+
vcrpy==1.0.2
43
mock==1.0.1
5-
boto==2.27
4+
unittest2 # Comment this line out if using Python 3.

tests/config.py

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
11
import os
2-
import sys
3-
from unittest2 import TestCase
42

5-
from httreplay import start_replay, stop_replay
6-
from httreplay.utils import filter_headers_key
3+
import vcr
74

85
from tweepy.auth import OAuthHandler
96
from tweepy.api import API
107

8+
import six
9+
if six.PY3:
10+
import unittest
11+
else:
12+
import unittest2 as unittest
13+
1114
username = os.environ.get('TWITTER_USERNAME', 'tweepytest')
1215
oauth_consumer_key = os.environ.get('CONSUMER_KEY', '')
1316
oauth_consumer_secret = os.environ.get('CONSUMER_SECRET', '')
1417
oauth_token = os.environ.get('ACCESS_KEY', '')
1518
oauth_token_secret = os.environ.get('ACCESS_SECRET', '')
1619
use_replay = os.environ.get('USE_REPLAY', False)
1720

18-
class TweepyTestCase(TestCase):
1921

22+
tape = vcr.VCR(
23+
cassette_library_dir='cassettes',
24+
filter_headers=['Authorization'],
25+
serializer='json',
26+
# Either use existing cassettes, or never use recordings:
27+
record_mode='new_episodes' if use_replay else 'all',
28+
)
29+
30+
31+
class TweepyTestCase(unittest.TestCase):
2032
def setUp(self):
2133
self.auth = create_auth()
2234
self.api = API(self.auth)
2335
self.api.retry_count = 2
2436
self.api.retry_delay = 5
2537

26-
if use_replay:
27-
def filter_body(data): return ''
28-
start_replay('tests/record.json',
29-
headers_key=filter_headers_key(['Authorization']),
30-
body_key=filter_body)
31-
32-
def tearDown(self):
33-
if use_replay:
34-
stop_replay()
3538

3639
def create_auth():
3740
auth = OAuthHandler(oauth_consumer_key, oauth_consumer_secret)

tests/record.json

+2,903
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)