Skip to content

Commit

Permalink
Official Python 3.4 & 3.5 compatibility
Browse files Browse the repository at this point in the history
Added tests for Python 3.4 & 3.5
Bumped version to 1.27.1
Switch to Travis new container-based infrastructure
  • Loading branch information
ob-stripe committed Sep 22, 2015
1 parent a59a6c5 commit 97f9c8c
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/.eggs
/build
/dist
/MANIFEST
/stripe.egg-info
.python-version
*.pyc
*.egg
*.class
Expand All @@ -12,3 +14,4 @@
.cache
nosetests.xml
coverage.xml
htmlcov/
17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sudo: false
language: python
python:
- "2.6"
Expand All @@ -6,17 +7,23 @@ python:
- "3.2"
- "3.3"
- "3.4"
- "3.5"
cache:
apt: true
pip: false
env: PYCURL_SSL_LIBRARY=gnutls
before_install:
- sudo apt-get update
- sudo apt-get install libcurl4-gnutls-dev librtmp-dev
addons:
apt:
packages:
- libcurl4-gnutls-dev
- librtmp-dev
install:
- pip install unittest2 pycurl flake8 --use-mirrors
- pip install unittest2 mock==1.0.1 pycurl flake8
- python setup.py clean --all
- python setup.py install
script:
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then flake8 stripe; fi
- python -W always setup.py test
cache: apt
matrix:
allow_failures:
- python: pypy
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
=== 1.27.1 2015-09-20

* Official Python 3.4 & 3.5 compatibility

=== 1.27.0 2015-09-14

* Products, SKUs, Orders resources
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.27.0
1.27.1
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
package_data={'stripe': ['data/ca-certificates.crt', '../VERSION']},
install_requires=install_requires,
test_suite='stripe.test.all',
tests_require=['unittest2', 'mock == 1.0.1'],
use_2to3=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand All @@ -70,6 +71,8 @@
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
])
60 changes: 30 additions & 30 deletions stripe/test/test_multipart_data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@
class MultipartDataGeneratorTests(StripeTestCase):

def test_generate_simple_multipart_data(self):
test_file = open(__file__)

params = {
"key1": "value1",
"key2": "value2",
"key3": test_file
}
generator = MultipartDataGenerator()
generator.add_params(params)
post_data = generator.get_post_data()

if sys.version_info < (3, 0):
http_body = "".join([line for line in post_data])
else:
byte_array = bytearray([i for i in post_data])
http_body = byte_array.decode('utf-8')

self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key1\"", http_body))
self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key2\"", http_body))
self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key3\"; filename=\".+\"",
http_body))
self.assertTrue(re.search(
r"Content-Type: application/octet-stream", http_body))

test_file.seek(0)
file_contents = test_file.read()
self.assertNotEqual(-1, http_body.find(file_contents))
with open(__file__) as test_file:
params = {
"key1": "value1",
"key2": "value2",
"key3": test_file
}
generator = MultipartDataGenerator()
generator.add_params(params)
post_data = generator.get_post_data()

if sys.version_info < (3, 0):
http_body = "".join([line for line in post_data])
else:
byte_array = bytearray([i for i in post_data])
http_body = byte_array.decode('utf-8')

self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key1\"", http_body))
self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key2\"", http_body))
self.assertTrue(re.search(
r"Content-Disposition: form-data; name=\"key3\"; "
r"filename=\".+\"",
http_body))
self.assertTrue(re.search(
r"Content-Type: application/octet-stream", http_body))

test_file.seek(0)
file_contents = test_file.read()
self.assertNotEqual(-1, http_body.find(file_contents))
2 changes: 1 addition & 1 deletion stripe/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.27.0'
VERSION = '1.27.1'
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
# and then run "tox" from this directory.

[tox]
envlist = py26, py27, pypy, py31, py32, py33
envlist = py26, py27, pypy, py31, py32, py33, py34, py35

[testenv]
deps =
unittest2
pycurl>=7.19
requests>=0.8.8
mock==1.0.1
commands = python -W always setup.py test {posargs}
commands =
python setup.py clean --all
python -W always setup.py test {posargs}
setenv =
SKIP_PYCURL_TESTS = true

Expand All @@ -24,4 +27,5 @@ deps =
mock==1.0.1
commands =
flake8 stripe
python setup.py clean --all
python -W always setup.py test {posargs}

0 comments on commit 97f9c8c

Please sign in to comment.