Skip to content

Commit

Permalink
Merge pull request #3394 from bdarnell/python-versions
Browse files Browse the repository at this point in the history
Add python 3.13 betas to test configs
  • Loading branch information
bdarnell authored Jun 8, 2024
2 parents 74e7c98 + 6d1f091 commit 62e89cc
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ jobs:
tox_env: py311-full
- python: '3.11.0'
tox_env: py311-full
- python: '3.12.0-beta.3 - 3.12'
- python: '3.12.0'
tox_env: py312-full
- python: '3.13.0-beta.1 - 3.13'
# Some optional dependencies don't seem to work on 3.13 yet
tox_env: py313
- python: 'pypy-3.8'
# Pypy is a lot slower due to jit warmup costs, so don't run the
# "full" test config there.
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def get_tag(self):
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
Expand Down
21 changes: 11 additions & 10 deletions tornado/test/process_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from tornado.httpclient import HTTPClient, HTTPError
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.log import gen_log
from tornado.process import fork_processes, task_id, Subprocess
from tornado.simple_httpclient import SimpleAsyncHTTPClient
Expand Down Expand Up @@ -141,20 +140,19 @@ def term_and_wait(self, subproc):

@gen_test
def test_subprocess(self):
if IOLoop.configured_class().__name__.endswith("LayeredTwistedIOLoop"):
# This test fails non-deterministically with LayeredTwistedIOLoop.
# (the read_until('\n') returns '\n' instead of 'hello\n')
# This probably indicates a problem with either TornadoReactor
# or TwistedIOLoop, but I haven't been able to track it down
# and for now this is just causing spurious travis-ci failures.
raise unittest.SkipTest(
"Subprocess tests not compatible with " "LayeredTwistedIOLoop"
)
# In Python 3.13.0b1, the new repl logs an error on exit if terminfo
# doesn't exist, the -i flag is used, and stdin is not a tty. This bug may
# have been fixed in beta 2, so for now we disable the new repl in this test
# and the next. Once we've tested with beta 2 we can either remove this env var
# or file a bug upstream if it still exists.
env = dict(os.environ)
env["PYTHON_BASIC_REPL"] = "1"
subproc = Subprocess(
[sys.executable, "-u", "-i"],
stdin=Subprocess.STREAM,
stdout=Subprocess.STREAM,
stderr=subprocess.STDOUT,
env=env,
)
self.addCleanup(lambda: self.term_and_wait(subproc))
self.addCleanup(subproc.stdout.close)
Expand All @@ -172,11 +170,14 @@ def test_subprocess(self):
@gen_test
def test_close_stdin(self):
# Close the parent's stdin handle and see that the child recognizes it.
env = dict(os.environ)
env["PYTHON_BASIC_REPL"] = "1"
subproc = Subprocess(
[sys.executable, "-u", "-i"],
stdin=Subprocess.STREAM,
stdout=Subprocess.STREAM,
stderr=subprocess.STDOUT,
env=env,
)
self.addCleanup(lambda: self.term_and_wait(subproc))
yield subproc.stdout.read_until(b">>> ")
Expand Down
6 changes: 0 additions & 6 deletions tornado/test/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
timedelta_to_seconds,
import_object,
re_unescape,
is_finalizing,
)

import typing
Expand Down Expand Up @@ -301,8 +300,3 @@ def test_re_unescape_raises_error_on_invalid_input(self):
re_unescape("\\b")
with self.assertRaises(ValueError):
re_unescape("\\Z")


class IsFinalizingTest(unittest.TestCase):
def test_basic(self):
self.assertFalse(is_finalizing())
17 changes: 0 additions & 17 deletions tornado/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
Expand Down Expand Up @@ -47,22 +46,6 @@
unicode_type = str
basestring_type = str

try:
from sys import is_finalizing
except ImportError:
# Emulate it
def _get_emulated_is_finalizing() -> Callable[[], bool]:
L = [] # type: List[None]
atexit.register(lambda: L.append(None))

def is_finalizing() -> bool:
# Not referencing any globals here
return L != []

return is_finalizing

is_finalizing = _get_emulated_is_finalizing()


# versionchanged:: 6.2
# no longer our own TimeoutError, use standard asyncio class
Expand Down
9 changes: 5 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[tox]
envlist =
# Basic configurations: Run the tests for each python version.
py38-full,py39-full,py310-full,py311-full,pypy3-full
py38-full,py39-full,py310-full,py311-full,py312-full,pypy3-full

# Build and test the docs with sphinx.
docs
Expand All @@ -29,6 +29,7 @@ basepython =
py310: python3.10
py311: python3.11
py312: python3.12
py313: python3.13
pypy3: pypy3
# In theory, it doesn't matter which python version is used here.
# In practice, things like changes to the ast module can alter
Expand All @@ -48,7 +49,7 @@ deps =

setenv =
# Treat the extension as mandatory in testing (but not on pypy)
{py3,py38,py39,py310,py311,py312}: TORNADO_EXTENSION=1
{py3,py38,py39,py310,py311,py312,py313}: TORNADO_EXTENSION=1
# CI workers are often overloaded and can cause our tests to exceed
# the default timeout of 5s.
ASYNC_TEST_TIMEOUT=25
Expand All @@ -60,7 +61,7 @@ setenv =
# during sdist installation (and it doesn't seem to be
# possible to set environment variables during that phase of
# tox).
{py3,py38,py39,py310,py311,pypy3}: PYTHONWARNINGS=error:::tornado
{py3,py38,py39,py310,py311,py312,py313,pypy3}: 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)
Expand Down Expand Up @@ -117,5 +118,5 @@ commands =
# 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.
mypy --platform linux --python-version 3.12 {posargs:tornado}
mypy --platform linux --python-version 3.13 {posargs:tornado}
changedir = {toxinidir}

0 comments on commit 62e89cc

Please sign in to comment.