8000 Merge pull request #90 from gbin/python3 · alexcchan/twilio-python@3a9b213 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a9b213

Browse files
committed
Merge pull request twilio#90 from gbin/python3
Python3 porting effort
2 parents 23c26f6 + ab61071 commit 3a9b213

33 files changed

+201
-2800
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ pip-log.txt
2626
docs/tmp
2727
docs/_build
2828
cover
29+
30+
# tools
31+
.idea

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ python:
33
- "2.5"
44
- "2.6"
55
- "2.7"
6+
- "3.2"
67
install:
78
- pip install . --use-mirrors
89
- pip install -r requirements.txt --use-mirrors

requirements.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
1-
sphinx
2-
mock==0.8.0
1+
six
32
httplib2
4-
nose
5-
pyjwt
6-
simplejson
7-
unittest2
8-
coverage
9-
nosexcover

setup.py

100644100755
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from twilio import __version__
23
from setuptools import setup, find_packages
34

@@ -8,6 +9,14 @@
89
#
910
# You need to have the setuptools module installed. Try reading the setuptools
1011
# documentation: http://pypi.python.org/pypi/setuptools
12+
REQUIRES = ["httplib2 >= 0.7", "six"]
13+
14+
if sys.version_info < (2, 6):
15+
REQUIRES.append('simplejson')
16+
if sys.version_info >= (3,0):
17+
REQUIRES.append('unittest2py3k')
18+
else:
19+
REQUIRES.append('unittest2')
1120

1221
setup(
1322
name = "twilio",
@@ -17,7 +26,7 @@
1726
author_email = "help@twilio.com",
1827
url = "http://github.com/twilio/twilio-python/",
1928
keywords = ["twilio","twiml"],
20-
install_requires = ["httplib2 >= 0.7, < 0.8", "pyjwt==0.1.2"],
29+
install_requires = REQUIRES,
2130
packages = find_packages(),
2231
classifiers = [
2332
"Development Status :: 5 - Production/Stable",
@@ -28,6 +37,7 @@
2837
"Programming Language :: Python :: 2.5",
2938
"Programming Language :: Python :: 2.6",
3039
"Programming Language :: Python :: 2.7",
40+
"Programming Language :: Python :: 3.2",
3141
"Topic :: Software Development :: Libraries :: Python Modules",
3242
"Topic :: Communications :: Telephony",
3343
],

tests/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sphinx
2+
mock==0.8.0
3+
nose
4+
simplejson
5+
unittest2
6+
coverage
7+
nosexcover

tests/test_applications.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import sys
2-
if sys.version_info < (2, 7):
3-
import unittest2 as unittest
4-
else:
1+
import six
2+
if six.PY3:
53
import unittest
4+
else:
5+
import unittest2 as unittest
66

77
from mock import Mock
8-
#from twilio import TwilioException
9-
#from twilio.rest.resources import Application
108
from twilio.rest.resources import Applications
119

1210

1311
class ApplicationsTest(unittest.TestCase):
14-
1512
def setUp(self):
1613
self.parent = Mock()
1714
self.resource = Applications("http://api.twilio.com", ("user", "pass"))

tests/test_authorized_connect_apps.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import with_statement
2-
import sys
3-
if sys.version_info < (2, 7):
4-
import unittest2 as unittest
5-
else:
2+
import six
3+
if six.PY3:
64
import unittest
5+
else:
6+
import unittest2 as unittest
77

88
from mock import Mock, patch
99
from twilio.rest.resources import AuthorizedConnectApps

tests/test_available_phonenumber.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import with_statement
2-
import sys
3-
if sys.version_info < (2, 7):
4-
import unittest2 as unittest
5-
else:
2+
3+
import six
4+
if six.PY3:
65
import unittest
6+
else:
7+
import unittest2 as unittest
8+
79
from mock import Mock
810
from twilio import TwilioException
911
from twilio.rest.resources import AvailablePhoneNumber

tests/test_base_resource.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import with_statement
3-
import sys
4-
5-
if sys.version_info < (2, 7):
6-
import unittest2 as unittest
7-
else:
3+
import six
4+
if six.PY3:
85
import unittest
6+
else:
7+
import unittest2 as unittest
98

109
from mock import Mock, patch
1110
from nose.tools import assert_equals
1211
from nose.tools import raises
1312
from twilio.rest.resources import Resource
1413
from twilio.rest.resources import ListResource
1514
from twilio.rest.resources import InstanceResource
15+
from six import advance_iterator
1616

1717
base_uri = "https://api.twilio.com/2010-04-01"
1818
account_sid = "AC123"
@@ -51,30 +51,30 @@ def testIterNoKey(self):
5151
self.r.request.return_value = Mock(), {}
5252

5353
with self.assertRaises(StopIteration):
54-
self.r.iter().next()
54+
advance_iterator(self.r.iter())
5555

5656
def testRequest(self):
5757
self.r.request = Mock()
5858
self.r.request.return_value = Mock(), {self.r.key: [{'sid': 'foo'}]}
59-
self.r.iter().next()
59+
advance_iterator(self.r.iter())
6060
self.r.request.assert_called_with("GET", "https://api.twilio.com/2010-04-01/Resources", params={})
6161

6262
def testIterOneItem(self):
6363
self.r.request = Mock()
6464
self.r.request.return_value = Mock(), {self.r.key: [{'sid': 'foo'}]}
6565

6666
items = self.r.iter()
67-
items.next()
67+
advance_iterator(items)
6868

6969
with self.assertRaises(StopIteration):
70-
items.next()
70+
advance_iterator(items)
7171

7272
def testIterNoNextPage(self):
7373
self.r.request = Mock()
7474
self.r.request.return_value = Mock(), {self.r.key: []}
7575

7676
with self.assertRaises(StopIteration):
77-
self.r.iter().next()
77+
advance_iterator(self.r.iter())
7878

7979
def testKeyValue(self):
8080
self.r.key = "Hey"

tests/test_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import sys
2-
if sys.version_info < (2, 7):
3-
import unittest2 as unittest
4-
else:
1+
import six
2+
if six.PY3:
53
import unittest
4+
else:
5+
import unittest2 as unittest
66

77
from twilio.rest import TwilioRestClient, resources
88
from mock import patch, Mock

0 commit comments

Comments
 (0)
0