diff --git a/.travis.yml b/.travis.yml index ffc67dc4..79874a20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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' @@ -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' @@ -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: - | diff --git a/setup.py b/setup.py index 139eeec0..ad21d795 100644 --- a/setup.py +++ b/setup.py @@ -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", ] @@ -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={ diff --git a/src/treq/test/test_multipart.py b/src/treq/test/test_multipart.py index 4aece220..e0d81a29 100644 --- a/src/treq/test/test_multipart.py +++ b/src/treq/test/test_multipart.py @@ -3,6 +3,7 @@ # See LICENSE for details. import cgi +import sys from io import BytesIO @@ -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'])) diff --git a/tox.ini b/tox.ini index fbcd4248..13ca50ec 100644 --- a/tox.ini +++ b/tox.ini @@ -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] @@ -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 diff --git a/tox2travis.py b/tox2travis.py index 28dd3397..28bd5280 100755 --- a/tox2travis.py +++ b/tox2travis.py @@ -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: - | @@ -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) @@ -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), + ))