Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,21 @@ jobs:
- os: macos-latest
extra_test_args:
- '-u all'
env_polluting_tests: []
env_polluting_tests:
- test_set
skips: []
timeout: 50
- os: ubuntu-latest
extra_test_args:
- '-u all'
env_polluting_tests: []
env_polluting_tests:
- test_set
skips: []
timeout: 60
- os: windows-2025
extra_test_args: [] # TODO: Enable '-u all'
env_polluting_tests: []
env_polluting_tests:
- test_set
skips:
- test_rlcompleter
- test_pathlib # panic by surrogate chars
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/seq_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def test_pickle(self):
self.assertEqual(lst2, lst)
self.assertNotEqual(id(lst2), id(lst))

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skip("TODO: RUSTPYTHON; hangs")
def test_free_after_iterating(self):
support.check_free_after_iterating(self, iter, self.type2test)
support.check_free_after_iterating(self, reversed, self.type2test)
18 changes: 4 additions & 14 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,6 @@ def requires_lzma(reason='requires lzma'):
import lzma
except ImportError:
lzma = None
lzma = None # XXX: RUSTPYTHON; xz is not supported yet
return unittest.skipUnless(lzma, reason)

def requires_zstd(reason='requires zstd'):
Expand Down Expand Up @@ -856,22 +855,13 @@ def gc_collect():
longer than expected. This function tries its best to force all garbage
objects to disappear.
"""
return # TODO: RUSTPYTHON

import gc
gc.collect()
gc.collect()
gc.collect()

@contextlib.contextmanager
def disable_gc():
# TODO: RUSTPYTHON; GC is not supported yet
try:
yield
finally:
pass
return

import gc
have_gc = gc.isenabled()
gc.disable()
Expand Down Expand Up @@ -2004,10 +1994,6 @@ def _check_tracemalloc():


def check_free_after_iterating(test, iter, cls, args=()):
# TODO: RUSTPYTHON; GC is not supported yet
test.assertTrue(False)
return

done = False
def wrapper():
class A(cls):
Expand Down Expand Up @@ -3048,6 +3034,10 @@ def get_signal_name(exitcode):
except KeyError:
pass

# Format Windows exit status as hexadecimal
if 0xC0000000 <= exitcode:
return f"0x{exitcode:X}"

return None

class BrokenIter:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/_hypothesis_stubs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum
import functools
import unittest
from enum import Enum

__all__ = [
"given",
Expand Down
1 change: 0 additions & 1 deletion Lib/test/support/ast_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import ast


class ASTTestMixin:
"""Test mixing to have basic assertions for AST nodes."""

Expand Down
22 changes: 6 additions & 16 deletions Lib/test/support/asyncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,17 @@
sophisticated high-performance network servers and clients a snap.
"""

import os
import select
import socket
import sys
import time
import warnings
from errno import (
EAGAIN,
EALREADY,
EBADF,
ECONNABORTED,
ECONNRESET,
EINPROGRESS,
EINVAL,
EISCONN,
ENOTCONN,
EPIPE,
ESHUTDOWN,
EWOULDBLOCK,
errorcode,
)

import os
from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \
errorcode


_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
EBADF})
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/support/bytecode_helper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""bytecode_helper - support tools for testing correct bytecode generation"""

import unittest
import dis
import io
import opcode
import unittest

try:
import _testinternalcapi
except ImportError:
Expand Down
18 changes: 7 additions & 11 deletions Lib/test/support/channels.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
"""Cross-interpreter Channels High Level Module."""

import time
from concurrent.interpreters import _crossinterp
from concurrent.interpreters._crossinterp import (
UNBOUND_ERROR,
UNBOUND_REMOVE,
)

import _interpchannels as _channels
from concurrent.interpreters import _crossinterp

# aliases:
from _interpchannels import (
ChannelClosedError,
ChannelEmptyError,
ChannelError,
ChannelNotEmptyError,
ChannelNotFoundError,
ChannelError, ChannelNotFoundError, ChannelClosedError,
ChannelEmptyError, ChannelNotEmptyError,
)
from concurrent.interpreters._crossinterp import (
UNBOUND_ERROR, UNBOUND_REMOVE,
)


__all__ = [
'UNBOUND', 'UNBOUND_ERROR', 'UNBOUND_REMOVE',
'create', 'list_all',
Expand Down
1 change: 0 additions & 1 deletion Lib/test/support/hashlib_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import hashlib
import importlib
import unittest

from test.support.import_helper import import_module

try:
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/support/hypothesis_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
else:
# Regrtest changes to use a tempdir as the working directory, so we have
# to tell Hypothesis to use the original in order to persist the database.
from hypothesis.configuration import set_hypothesis_home_dir

from test.support import has_socket_support
from test.support.os_helper import SAVEDCWD
from hypothesis.configuration import set_hypothesis_home_dir

set_hypothesis_home_dir(os.path.join(SAVEDCWD, ".hypothesis"))

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/i18n_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import sys
import unittest
from pathlib import Path

from test.support import REPO_ROOT, TEST_HOME_DIR, requires_subprocess
from test.test_tools import skip_if_missing


pygettext = Path(REPO_ROOT) / 'Tools' / 'i18n' / 'pygettext.py'

msgid_pattern = re.compile(r'msgid(.*?)(?:msgid_plural|msgctxt|msgstr)',
Expand Down
1 change: 0 additions & 1 deletion Lib/test/support/logging_helper.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging.handlers


class TestHandler(logging.handlers.BufferingHandler):
def __init__(self, matcher):
# BufferingHandler takes a "capacity" argument
Expand Down
1 change: 1 addition & 0 deletions Lib/test/support/os_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from test import support


# Filename used for testing
TESTFN_ASCII = '@test'

Expand Down
9 changes: 8 additions & 1 deletion Lib/test/support/pty_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@

from test.support.import_helper import import_module


def run_pty(script, input=b"dummy input\r", env=None):
pty = import_module('pty')
output = bytearray()
[master, slave] = pty.openpty()
args = (sys.executable, '-c', script)

# Isolate readline from personal init files by setting INPUTRC
# to an empty file. See also GH-142353.
if env is None:
env = {**os.environ.copy(), "INPUTRC": os.devnull}
else:
env.setdefault("INPUTRC", os.devnull)

proc = subprocess.Popen(args, stdin=slave, stdout=slave, stderr=slave, env=env)
os.close(slave)
with ExitStack() as cleanup:
Expand Down
7 changes: 4 additions & 3 deletions Lib/test/support/script_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

import collections
import importlib
import sys
import os
import os.path
import py_compile
import subprocess
import sys
from importlib.util import source_from_cache
import py_compile

from importlib.util import source_from_cache
from test import support
from test.support.import_helper import make_legacy_pyc


# Cached result of the expensive test performed in the function below.
__cached_interp_requires_environment = None

Expand Down
13 changes: 6 additions & 7 deletions Lib/test/support/smtpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@
# - Handle more ESMTP extensions
# - handle error codes from the backend smtpd

import collections
import sys
import os
import errno
import getopt
import os
import socket
import sys
import time
from email._header_value_parser import get_addr_spec, get_angle_addr
import socket
import collections
from test.support import asyncore, asynchat
from warnings import warn

from test.support import asynchat, asyncore
from email._header_value_parser import get_addr_spec, get_angle_addr

__all__ = [
"SMTPChannel", "SMTPServer", "DebuggingServer", "PureProxy",
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/socket_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import errno
import os.path
import socket
import subprocess
import sys
import subprocess
import tempfile
import unittest

Expand Down
3 changes: 1 addition & 2 deletions Lib/test/support/strace_helper.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import os
import re
import sys
import textwrap
import os
import unittest
from dataclasses import dataclass
from functools import cache

from test import support
from test.support.script_helper import run_python_until_end

Expand Down
24 changes: 18 additions & 6 deletions Lib/test/support/threading_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from test import support


#=======================================================================
# Threading support to prevent reporting refleaks when running regrtest.py -R

Expand Down Expand Up @@ -249,21 +250,32 @@ def requires_working_threading(*, module=False):
return unittest.skipUnless(can_start_thread, msg)


def run_concurrently(worker_func, nthreads, args=(), kwargs={}):
def run_concurrently(worker_func, nthreads=None, args=(), kwargs={}):
"""
Run the worker function concurrently in multiple threads.
Run the worker function(s) concurrently in multiple threads.

If `worker_func` is a single callable, it is used for all threads.
If it is a list of callables, each callable is used for one thread.
"""
from collections.abc import Iterable

if nthreads is None:
nthreads = len(worker_func)
if not isinstance(worker_func, Iterable):
worker_func = [worker_func] * nthreads
assert len(worker_func) == nthreads

barrier = threading.Barrier(nthreads)

def wrapper_func(*args, **kwargs):
def wrapper_func(func, *args, **kwargs):
# Wait for all threads to reach this point before proceeding.
barrier.wait()
worker_func(*args, **kwargs)
func(*args, **kwargs)

with catch_threading_exception() as cm:
workers = [
threading.Thread(target=wrapper_func, args=args, kwargs=kwargs)
for _ in range(nthreads)
threading.Thread(target=wrapper_func, args=(func, *args), kwargs=kwargs)
for func in worker_func
]
with start_threads(workers):
pass
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/venv.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import contextlib
import logging
import os
import shlex
import subprocess
import shlex
import sys
import sysconfig
import tempfile
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ def test_obsolete_write_lock(self):
a = array.array('B', b"")
self.assertRaises(BufferError, _testcapi.getbuffer_with_null_view, a)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.skip("TODO: RUSTPYTHON; hangs")
def test_free_after_iterating(self):
support.check_free_after_iterating(self, iter, array.array,
(self.typecode,))
Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_ast/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ def cleanup():
with self.assertRaisesRegex(AttributeError, msg):
ast.AST()

@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: <test.test_ast.test_ast.AST_Tests.test_AST_garbage_collection.<locals>.X object at 0x7e85c3a80> is not None
def test_AST_garbage_collection(self):
class X:
pass
Expand Down
Loading
Loading