8000 python 2.5 compatibility · Stackdriver/twilio-python@1a07f51 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 1, 2018. It is now read-only.

Commit 1a07f51

Browse files
committed
python 2.5 compatibility
1 parent e9e280e commit 1a07f51

File tree

6 files changed

+13
- 10000 9
lines changed

6 files changed

+13
-9
lines changed

.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

tests/test_make_request.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
except ImportError:
99
import simplejson as json
1010

11+
1112
import twilio
1213
from nose.tools import raises
1314
from mock import patch, Mock

tests/test_twiml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import with_statement
3-
from __future__ import unicode_literals
3+
44
import re
55
from six import u, text_type
66
import twilio
@@ -64,7 +64,7 @@ def testSayHelloWorld(self):
6464
def testSayFrench(self):
6565
"""should say hello monkey"""
6666
r = Response()
67-
r.append(twiml.Say("nécessaire et d'autres")) # it works on python 2.6 with the from __future__ import unicode_literal
67+
r.append(twiml.Say(u("n\xe9cessaire et d'autres"))) # it works on python 2.6 with the from __future__ import unicode_literal
6868
self.assertEquals(text_type(r),
6969
'<?xml version="1.0" encoding="UTF-8"?><Response><Say>n&#233;cessaire et d\'autres</Say></Response>')
7070

tests/test_unicode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import unicode_literals
32
from mock import patch, Mock
43
from six import u
54
from twilio.rest import resources
@@ -43,7 +42,7 @@ def test_double_encoding(resp_mock, mock):
4342
http = mock.return_value
4443
http.request.return_value = (Mock(), Mock())
4544

46-
body = "Chloéñ" # I can do that with the from future import
45+
body = u('Chlo\xe9\xf1')
4746

4847
data = {
4948
"body": body.encode('utf-8'),
@@ -62,7 +61,7 @@ def test_paging(resp_mock, mock):
6261
http.request.return_value = (Mock(), Mock())
6362

6463
data = {
65-
"body": "Chloéñ", # I can do that with the from future import
64+
"body": u('Chlo\xe9\xf1'),
6665
}
6766

6867
resources.make_request("GET", "http://www.example.com", data=data)

tests/test_validation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# -*- coding: utf-8 -*-
22
import os
33
import sys
4+
from six import b
5+
46
if sys.version_info < (2, 7):
57
import unittest2 as unittest
68
else:
@@ -44,7 +46,7 @@ def test_validation(self):
4446
"ToZip": "94612",
4547
}
4648

47-
expected = b"fF+xx6dTinOaCdZ0aIeNkHr/ZAA="
49+
expected = b("fF+xx6dTinOaCdZ0aIeNkHr/ZAA=")
4850

4951
self.assertEquals(validator.compute_signature(uri, params), expected)
5052
self.assertTrue(validator.validate(uri, params, expected))

twilio/jwt/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import base64
77
import hashlib
88
import hmac
9-
from six import text_type, binary_type
9+
from six import text_type, binary_type, b
1010

1111
# default text to binary representation conversion
1212
def binary(txt):
@@ -15,7 +15,8 @@ def binary(txt):
1515
import json
1616
except ImportError:
1717
import simplejson as json
18-
18+
19+
1920
__all__ = ['encode', 'decode', 'DecodeError']
2021

2122
class DecodeError(Exception): pass
@@ -27,7 +28,7 @@ class DecodeError(Exception): pass
2728
}
2829

2930
def base64url_decode(input):
30-
input += b'=' * (4 - (len(input) % 4))
31+
input += b('=') * (4 - (len(input) % 4))
3132
return base64.urlsafe_b64decode(input)
3233

3334
def base64url_encode(input):

0 commit comments

Comments
 (0)
0