Skip to content

Commit

Permalink
Merge pull request twisted#228 from yan12125/py37
Browse files Browse the repository at this point in the history
Add Python 3.7 support and enable testing
  • Loading branch information
glyph authored Aug 27, 2018
2 parents 0041d5d + 369887f commit 2d45c82
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 13 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ matrix:
env: TOXENV=py36-twisted_lowest
- python: '3.6'
env: TOXENV=py36-twisted_latest
- python: '3.7'
env: TOXENV=py37-twisted_lowest
dist: xenial
sudo: true
- python: '3.7'
env: TOXENV=py37-twisted_latest
dist: xenial
sudo: true
- python: pypy
env: TOXENV=pypy-twisted_trunk-pyopenssl_trunk
- python: '2.7'
Expand All @@ -37,6 +45,10 @@ matrix:
env: TOXENV=py35-twisted_trunk-pyopenssl_trunk
- python: '3.6'
env: TOXENV=py36-twisted_trunk-pyopenssl_trunk
- python: '3.7'
env: TOXENV=py37-twisted_trunk-pyopenssl_trunk
dist: xenial
sudo: true
- python: '2.7'
env: TOXENV=pypi-readme
- python: '2.7'
Expand All @@ -53,6 +65,7 @@ matrix:
- env: TOXENV=py34-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py35-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py36-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py37-twisted_trunk-pyopenssl_trunk

before_install:
- |
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
Expand All @@ -29,7 +31,8 @@
"incremental",
"requests >= 2.1.0",
"six",
"Twisted[tls] >= 16.4.0",
"Twisted[tls] >= 16.4.0 ; python_version < '3.7'",
"Twisted[tls] >= 18.7.0 ; python_version >= '3.7'",
"attrs",
],
extras_require={
Expand Down
17 changes: 14 additions & 3 deletions src/treq/test/test_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# See LICENSE for details.

import cgi
import sys

from io import BytesIO

Expand Down Expand Up @@ -594,9 +595,19 @@ def test_worksWithCgi(self):
)
)

form = cgi.parse_multipart(BytesIO(output), {"boundary": b"heyDavid"})
self.assertEqual(set([b'just a string\r\n', b'another string']),
set(form['cfield']))
form = cgi.parse_multipart(BytesIO(output), {
"boundary": b"heyDavid",
"CONTENT-LENGTH": str(len(output)),
})

# Since Python 3.7, the value for a non-file field is now a list
# of strings, not bytes.
if sys.version_info >= (3, 7):
self.assertEqual(set(['just a string\r\n', 'another string']),
set(form['cfield']))
else:
self.assertEqual(set([b'just a string\r\n', b'another string']),
set(form['cfield']))

self.assertEqual(set([b'my lovely bytes2']), set(form['efield']))
self.assertEqual(set([b'my lovely bytes219']), set(form['xfield']))
Expand Down
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
{pypy,py27,py34,py35,py36}-twisted_{lowest,latest},
{pypy,py27,py34,py35,py36}-twisted_trunk-pyopenssl_trunk,
{pypy,py27,py34,py35,py36,py37}-twisted_{lowest,latest},
{pypy,py27,py34,py35,py36,py37}-twisted_trunk-pyopenssl_trunk,
pypi-readme, check-manifest, flake8, docs

[testenv]
Expand All @@ -10,7 +10,8 @@ deps =
coverage
mock

twisted_lowest: Twisted==16.4.0
!py37-twisted_lowest: Twisted==16.4.0
py37-twisted_lowest: Twisted==18.7.0
twisted_latest: Twisted
twisted_trunk: https://github.com/twisted/twisted/archive/trunk.zip

Expand Down
23 changes: 17 additions & 6 deletions tox2travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@
# Don't fail on trunk versions.
allow_failures:
- env: TOXENV=pypy-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py27-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py34-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py35-twisted_trunk-pyopenssl_trunk
- env: TOXENV=py36-twisted_trunk-pyopenssl_trunk
{allow_failures}
before_install:
- |
Expand Down Expand Up @@ -81,6 +77,7 @@
line = sys.stdin.readline()

includes = []
allow_failures = []
for tox_env in tox_envs:
# Parse the Python version from the tox environment name
python_match = re.match(r'^py(?:(\d{2})|py)-', tox_env)
Expand All @@ -98,4 +95,18 @@
' env: TOXENV={0}'.format(tox_env)
])

print(travis_template.format(includes='\n '.join(includes)))
# Python 3.7 is available on sudo-enabled Xenial VMs only
# See https://github.com/travis-ci/travis-ci/issues/9815
if python == "'3.7'":
includes.extend([
' dist: xenial',
' sudo: true',
])

if 'trunk' in tox_env:
allow_failures.append('- env: TOXENV={0}'.format(tox_env))

print(travis_template.format(
allow_failures='\n '.join(allow_failures),
includes='\n '.join(includes),
))

0 comments on commit 2d45c82

Please sign in to comment.