提交 6dceb64e 编写于 作者: B Ben Darnell

ci: Enable warnings-as-errors earlier

This catches import-time warnings in more modules, including a warning
about invalid escape sequences that is now an error on nightly python.
上级 f4ab48d4
......@@ -43,7 +43,8 @@ install:
#- 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.
......@@ -83,6 +84,8 @@ script:
# 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
......@@ -92,6 +95,7 @@ script:
# 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
......
......@@ -100,7 +100,7 @@ class _NormalizedHeaderCache(dict):
_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,
......
......@@ -7,6 +7,7 @@ import operator
import textwrap
import sys
import unittest
import warnings
from tornado.httpclient import AsyncHTTPClient
from tornado.httpserver import HTTPServer
......@@ -111,14 +112,11 @@ class CountingStderr(io.IOBase):
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.
......
......@@ -427,7 +427,7 @@ class AuthRedirectTest(WebTestCase):
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"],
......
......@@ -217,7 +217,7 @@ _re_unescape_pattern = re.compile(r"\\(.)", re.DOTALL)
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
......
......@@ -1956,7 +1956,7 @@ class _ApplicationRouter(ReversibleRuleRouter):
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::
......
......@@ -86,6 +86,18 @@ commands =
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册