Repository navigation
Expand file tree
/
Copy pathtox.ini
More file actions
171 lines (159 loc) · 7.46 KB
/
Copy pathtox.ini
File metadata and controls
171 lines (159 loc) · 7.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Tox (https://tox.readthedocs.io) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the tornado
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
#
# This configuration requires tox 1.8 or higher.
#
# Installation tips:
# When building pycurl on my macports-based setup, I need to either set the
# environment variable ARCHFLAGS='-arch x86_64' or use
# 'port install curl +universal' to get both 32- and 64-bit versions of
# libcurl.
[tox]
envlist =
# Basic configurations: Run the tests for each python version.
# [[[cog
# versions = [f"py3{m}" for m in range(int(min_python_minor), int(max_python_minor) + 1)]
# versions += ["pypy3"]
# cog.outl(','.join(versions))
# ]]]
py311,py312,py313,py314,py315,py316,pypy3
# [[[end]]]
# Build and test the docs with sphinx.
docs
# Run the linters.
lint
[testenv]
basepython =
# In theory, it doesn't matter which python version is used here.
# In practice, things like changes to the ast module can alter
# the outputs of the tools (especially where exactly the
# linter warning-suppression comments go), so we specify a
# python version for these builds.
# These versions must be synced with the versions in .github/workflows/test.yml
# [[[cog
# cog.outl(f"docs: python3.{default_python_minor}")
# cog.outl(f"lint: python3.{default_python_minor}")
# ]]]
docs: python3.13
lint: python3.13
# [[[end]]]
deps =
full: pycurl
full: twisted
full: hypothesis
# Pycares 5 has some backwards-incompatible changes that we don't support.
# And since CaresResolver is deprecated, I do not expect to fix it, so just
# pin the previous version. (This should really be in requirements.{in,txt} instead)
full: pycares<5
docs: -r{toxinidir}/requirements.txt
lint: -r{toxinidir}/requirements.txt
setenv =
# Treat the extension as mandatory in testing (but not on pypy)
# [[[cog
# versions = [f"py3{m}" for m in range(int(min_python_minor), int(max_python_minor) + 1)]
# versions.insert(0, "py3")
# cog.outl(f"{{{",".join(versions)}}}: TORNADO_EXTENSION=1")
# ]]]
{py3,py311,py312,py313,py314,py315,py316}: TORNADO_EXTENSION=1
# [[[end]]]
# CI workers are often overloaded and can cause our tests to exceed
# the default timeout of 5s.
ASYNC_TEST_TIMEOUT=25
# 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).
PYTHONWARNINGS=error:::tornado
# Warn if we try to open a file with an unspecified encoding.
# (New in python 3.10, becomes obsolete when utf8 becomes the
# default in 3.15)
PYTHONWARNDEFAULTENCODING=1
# Allow shell commands in tests
allowlist_externals = sh
# Tox filters line-by-line based on the environment name.
commands =
# py3*: -b turns on an extra warning when calling
# str(bytes), and -bb makes it an error.
python -bb -m tornado.test {posargs:}
# 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
# them for things that should be runtime errors.
full: python -O -m tornado.test
# Note that httpclient_test is always run with both client
# implementations; this flag controls which client all the
# other tests use.
full: python -m tornado.test --httpclient=tornado.curl_httpclient.CurlAsyncHTTPClient
full: python -m tornado.test --resolver=tornado.platform.caresresolver.CaresResolver
# python will import relative to the current working directory by default,
# so cd into the tox working directory to avoid picking up the working
# copy of the files (especially important for the speedups module).
changedir = {toxworkdir}
[testenv:coverage]
# Measure test coverage, combining the default run with the alternate
# http client run from the -full configuration (and any subprocesses
# started by the tests; see .coveragerc). The CaresResolver run is left
# out since that module is deprecated (see .coveragerc).
# [[[cog cog.outl(f"basepython = python3.{default_python_minor}")]]]
basepython = python3.13
# [[[end]]]
deps =
pycurl
twisted
hypothesis
coverage
-c{toxinidir}/requirements.txt
setenv =
{[testenv]setenv}
COVERAGE_RCFILE={toxinidir}/.coveragerc
COVERAGE_FILE={toxworkdir}/coverage-data/.coverage
# The property tests run with their full number of examples in the
# -full configurations; here a few examples are enough to measure
# coverage, and this keeps the coverage job fast.
HYPOTHESIS_PROFILE=tornado-quick
commands =
python -c "import shutil; shutil.rmtree(r'{toxworkdir}/coverage-data', ignore_errors=True)"
coverage run -m tornado.test {posargs:}
coverage run -m tornado.test --httpclient=tornado.curl_httpclient.CurlAsyncHTTPClient
# Run combine and the reports from the repo root so that paths
# (and the html output) are relative to the source tree.
sh -c 'cd {toxinidir} && coverage combine -q && coverage html -q -d {toxworkdir}/coverage-data/html && coverage report --fail-under=86'
[testenv:docs]
changedir = docs
# For some reason the extension fails to load in this configuration,
# but it's not really needed for docs anyway.
setenv = TORNADO_EXTENSION=0
commands =
# Build the docs
sphinx-build -q -E -n -W -b html . {envtmpdir}/html
# Ensure that everything documented is in the API snapshot
python -m tornado.test.api_test --check-docs {envtmpdir}/html/objects.inv
# Ensure that everything is either documented or ignored in conf.py
sphinx-build -q -E -n -W -b coverage . {envtmpdir}/coverage
# Run the doctests
sphinx-build -q -E -n -W -b doctest . {envtmpdir}/doctest
[testenv:lint]
commands =
flake8 {posargs:}
black --check --diff {posargs:tornado demos}
# Many syscalls are defined differently on linux and windows,
# so we have to typecheck both.
mypy --platform linux {posargs:tornado}
mypy --platform windows {posargs:tornado}
# We mainly lint on the oldest version of Python we support, since
# we're more likely to catch problems of accidentally depending on
# something new than of depending on something old and deprecated.
# But sometimes something we depend on gets removed so we should also
# test the newest version.
# [[[cog cog.outl(f"mypy --platform linux --python-version 3.{default_python_minor} {{posargs:tornado}}")]]]
mypy --platform linux --python-version 3.13 {posargs:tornado}
# [[[end]]]
# Check that applications can type-check against the installed package.
python maint/test/mypy/check.py
changedir = {toxinidir}