#- if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then travis_retry pip install pycares; fi
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then travis_retry pip install pycurl; fi
# Twisted is flaky on pypy (TODO: still? this note is quite old)
- - if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then travis_retry pip install Twisted; fi
+ # It also sometimes has problems on nightly.
+ - if [[ $TRAVIS_PYTHON_VERSION != 'pypy'* && $TRAVIS_PYTHON_VERSION != 'nightly' ]]; then travis_retry pip install Twisted; fi
# Ideally we'd run the lint stuff on the latest Python
# version supported. But Python 3.7 requires slower-to-start VMs,
# so we run it on 3.6 to minimize total CI run time.
# run it with nightly cpython. Coverage is very slow on pypy.
- if [[ $TRAVIS_PYTHON_VERSION != nightly && $TRAVIS_PYTHON_VERSION != 'pypy'* ]]; then export RUN_COVERAGE=1; fi
- if [[ "$RUN_COVERAGE" == 1 ]]; then export TARGET="-m coverage run $TARGET"; fi
+ # See comments in tox.ini
+ - export PYTHONWARNINGS=error,ignore:::site
- python -bb $TARGET
- python -O $TARGET
- LANG=C python $TARGET
# make coverage reports for Codecov to find
- if [[ "$RUN_COVERAGE" == 1 ]]; then coverage xml; fi
- export TORNADO_EXTENSION=0
+ - unset PYTHONWARNINGS
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then (cd ../docs && mkdir sphinx-out && sphinx-build -E -n -W -b html . sphinx-out); fi
- if [[ $TRAVIS_PYTHON_VERSION == 3.7 ]]; then (cd ../docs && mkdir sphinx-doctest-out && sphinx-build -E -n -b doctest . sphinx-out); fi
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then (cd .. && flake8); fi
_normalized_headers = _NormalizedHeaderCache(1000)
-class HTTPHeaders(collections.MutableMapping):
+class HTTPHeaders(collections.abc.MutableMapping):
"""A dictionary that maintains ``Http-Header-Case`` for all keys.
Supports multiple values per key via a pair of new methods,
import textwrap
import sys
import unittest
+import warnings
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
def main():
- # The -W command-line option does not work in a virtualenv with
- # python 3 (as of virtualenv 1.7), so configure warnings
- # programmatically instead.
- import warnings
-
- # Be strict about most warnings. This also turns on warnings that are
- # ignored by default, including DeprecationWarnings and
- # python 3.2's ResourceWarnings.
+ # Be strict about most warnings (This is set in our test running
+ # scripts to catch import-time warnings, but set it again here to
+ # be sure). This also turns on warnings that are ignored by
+ # default, including DeprecationWarnings and python 3.2's
+ # ResourceWarnings.
warnings.filterwarnings("error")
# setuptools sometimes gives ImportWarnings about things that are on
# sys.path even if they're not being used.
self.assertEqual(response.code, 302)
self.assertTrue(
re.match(
- "http://example.com/login\?next=http%3A%2F%2F127.0.0.1%3A[0-9]+%2Fabsolute",
+ r"http://example.com/login\?next=http%3A%2F%2F127.0.0.1%3A[0-9]+%2Fabsolute",
response.headers["Location"],
),
response.headers["Location"],
def re_unescape(s: str) -> str:
- """Unescape a string escaped by `re.escape`.
+ r"""Unescape a string escaped by `re.escape`.
May raise ``ValueError`` for regular expressions which could not
have been produced by `re.escape` (for example, strings containing
class Application(ReversibleRouter):
- """A collection of request handlers that make up a web application.
+ r"""A collection of request handlers that make up a web application.
Instances of this class are callable and can be passed directly to
HTTPServer to serve the application::
# py3*: -b turns on an extra warning when calling
# str(bytes), and -bb makes it an error.
-bb \
+ # Treat warnings as errors by default. We have a whitelist of
+ # allowed warnings in runtests.py, but we want to be strict
+ # about any import-time warnings before that setup code is
+ # reached. Note that syntax warnings are only reported in
+ # -opt builds because regular builds reuse pycs created
+ # during sdist installation (and it doesn't seem to be
+ # possible to set environment variables during that phase of
+ # tox).
+ "-Werror" \
+ # Virtualenv hits a deprecation warning very early which we must
+ # suppress here.
+ "-Wignore:::site" \
# Python's optimized mode disables the assert statement, so
# run the tests in this mode to ensure we haven't fallen into
# the trap of relying on an assertion's side effects or using