Remove in-tree dependency when building unvendored python modules (#3864)

This commit is contained in:
Gyeongjae Choi 2023-06-05 19:48:48 +09:00 committed by GitHub
parent 4a7cc0c20e
commit 73c497bfbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1630 additions and 36 deletions

View File

@ -18,6 +18,9 @@ export PYMICRO=$(word 3,$(version_tuple))
export HOSTPYTHONROOT=$(shell python${PYMAJOR}.${PYMINOR} -c "import sys; print(sys.prefix)")
export HOSTPYTHON=$(HOSTPYTHONROOT)/bin/python$(PYMAJOR).$(PYMINOR)
export PYTHON_ARCHIVE_URL=https://www.python.org/ftp/python/$(PYVERSION)/Python-$(PYVERSION).tgz
export PYTHON_ARCHIVE_SHA256=1a79f3df32265d9e6625f1a0b31c28eb1594df911403d11f3320ee1da1b3e048
export CPYTHONROOT=$(PYODIDE_ROOT)/cpython
export CPYTHONINSTALL=$(CPYTHONROOT)/installs/python-$(PYVERSION)
export CPYTHONLIB=$(CPYTHONINSTALL)/lib/python$(PYMAJOR).$(PYMINOR)

View File

@ -8,7 +8,6 @@ PYTHON_CFLAGS=$(CFLAGS_BASE) -DPY_CALL_TRAMPOLINE
BUILD=$(CPYTHONROOT)/build/Python-$(PYVERSION)
INSTALL=$(CPYTHONINSTALL)
TARBALL=$(ROOT)/downloads/Python-$(PYVERSION).tgz
URL=https://www.python.org/ftp/python/$(PYVERSION)/Python-$(PYVERSION).tgz
LIB=libpython$(PYMAJOR).$(PYMINOR).a
FFIBUILD=$(ROOT)/build/libffi
@ -50,8 +49,8 @@ clean-all: clean
$(TARBALL):
[ -d $(ROOT)/downloads ] || mkdir $(ROOT)/downloads
wget -q -O $@ $(URL)
shasum --algorithm 256 --check checksums --quiet || (rm $@; false)
wget -q -O $@ $(PYTHON_ARCHIVE_URL)
shasum --algorithm 256 $(TARBALL) | grep -q $(PYTHON_ARCHIVE_SHA256)
$(BUILD)/.patched: $(TARBALL)

View File

@ -1 +0,0 @@
1a79f3df32265d9e6625f1a0b31c28eb1594df911403d11f3320ee1da1b3e048 downloads/Python-3.11.3.tgz

View File

@ -5,9 +5,10 @@ package:
- always
top-level:
- distutils
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONLIB
tar --exclude=__pycache__ -cf - distutils | tar -C $DISTDIR -xf -
cd Lib && tar --exclude=__pycache__ --exclude=tests -cf - distutils | tar -C $DISTDIR -xf -

View File

@ -5,11 +5,12 @@ package:
- always
top-level:
- _hashlib
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
emcc $STDLIB_MODULE_CFLAGS -c Modules/_hashopenssl.c -o Modules/_hashlib.o \
$(pkg-config --cflags --dont-define-prefix libcrypto) -DOPENSSL_THREADS

View File

@ -6,10 +6,12 @@ package:
top-level:
- lzma
- _lzma
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
emcc $STDLIB_MODULE_CFLAGS -c Modules/_lzmamodule.c -o Modules/_lzmamodule.o \
$(pkg-config --cflags --dont-define-prefix liblzma)

View File

@ -5,9 +5,10 @@ package:
- always
top-level:
- _pydecimal
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
cp Lib/_pydecimal.py $DISTDIR

View File

@ -5,9 +5,11 @@ package:
- always
top-level:
- pydoc_data
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD/Lib
cd Lib
tar --exclude=__pycache__ -cf - pydoc_data | tar -C $DISTDIR -xf -

View File

@ -6,11 +6,12 @@ package:
top-level:
- sqlite3
- _sqlite3
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
export FILES=(
"Modules/_sqlite/blob.c"
"Modules/_sqlite/connection.c"

View File

@ -6,10 +6,12 @@ package:
top-level:
- ssl
- _ssl
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
emcc $STDLIB_MODULE_CFLAGS -c Modules/_ssl.c -o Modules/_ssl.o \
$(pkg-config --cflags --dont-define-prefix openssl) \
$(pkg-config --libs --dont-define-prefix openssl) \

View File

@ -5,13 +5,17 @@ package:
- always
top-level:
- test
# TODO: also include test directories included in other stdlib modules
source:
sha256: $(PYTHON_ARCHIVE_SHA256)
url: $(PYTHON_ARCHIVE_URL)
patches:
- patches/0005-gh-93839-Move-Lib-ctypes-test-to-Lib-test-test_ctype.patch
- patches/0006-gh-93839-Move-Lib-unttest-test-to-Lib-test-test_unit.patch
- patches/0007-gh-93839-Use-load_package_tests-for-testmock-GH-9405.patch
- patches/0008-Move-test-directories.patch
build:
type: cpython_module
script: |
cd $CPYTHONBUILD
export TEST_EXTENSIONS="\
_testinternalcapi.so \
_testcapi.so \
@ -32,11 +36,10 @@ build:
emcc ${TEST_MODULE_CFLAGS} -c Modules/_ctypes/_ctypes_test.c -o Modules/_ctypes_test.o
for testname in ${TEST_EXTENSIONS}; do \
cd ${CPYTHONBUILD} && \
emcc Modules/${testname/.so/.o} -o ${DISTDIR}/$testname ${SIDE_MODULE_LDFLAGS}
done
cd ${CPYTHONBUILD}/Lib && \
cd Lib && \
tar --exclude=__pycache__ -cf - \
test distutils/tests sqlite3/test \
| tar -C $DISTDIR -xf -

View File

@ -0,0 +1,753 @@
From d82e0bfe8b98a122ca443b356d81998c804b686e Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Tue, 21 Jun 2022 10:24:33 +0200
Subject: [PATCH 5/9] gh-93839: Move Lib/ctypes/test/ to Lib/test/test_ctypes/
(#94041)
* Move Lib/ctypes/test/ to Lib/test/test_ctypes/
* Remove Lib/test/test_ctypes.py
* Update imports and build system.
---
Lib/ctypes/test/__main__.py | 4 -
Lib/test/leakers/test_ctypes.py | 2 +-
Lib/test/test_ctypes.py | 10 --
.../test => test/test_ctypes}/__init__.py | 0
Lib/test/test_ctypes/__main__.py | 4 +
.../test => test/test_ctypes}/test_anon.py | 0
.../test_ctypes}/test_array_in_pointer.py | 0
.../test => test/test_ctypes}/test_arrays.py | 2 +-
.../test_ctypes}/test_as_parameter.py | 2 +-
.../test_ctypes}/test_bitfields.py | 2 +-
.../test => test/test_ctypes}/test_buffers.py | 2 +-
.../test => test/test_ctypes}/test_bytes.py | 0
.../test_ctypes}/test_byteswap.py | 0
.../test_ctypes}/test_callbacks.py | 2 +-
.../test => test/test_ctypes}/test_cast.py | 2 +-
.../test => test/test_ctypes}/test_cfuncs.py | 2 +-
.../test_ctypes}/test_checkretval.py | 2 +-
.../test => test/test_ctypes}/test_delattr.py | 0
.../test => test/test_ctypes}/test_errno.py | 0
.../test => test/test_ctypes}/test_find.py | 0
.../test_ctypes}/test_frombuffer.py | 0
.../test => test/test_ctypes}/test_funcptr.py | 0
.../test_ctypes}/test_functions.py | 2 +-
.../test_ctypes}/test_incomplete.py | 0
.../test => test/test_ctypes}/test_init.py | 0
.../test_ctypes}/test_internals.py | 0
.../test_ctypes}/test_keeprefs.py | 0
.../test => test/test_ctypes}/test_libc.py | 0
.../test => test/test_ctypes}/test_loading.py | 0
.../test_ctypes}/test_macholib.py | 0
.../test_ctypes}/test_memfunctions.py | 2 +-
.../test => test/test_ctypes}/test_numbers.py | 0
.../test => test/test_ctypes}/test_objects.py | 8 +-
.../test_ctypes}/test_parameters.py | 2 +-
.../test => test/test_ctypes}/test_pep3118.py | 0
.../test_ctypes}/test_pickling.py | 0
.../test_ctypes}/test_pointers.py | 0
.../test_ctypes}/test_prototypes.py | 2 +-
.../test_ctypes}/test_python_api.py | 0
.../test_ctypes}/test_random_things.py | 0
.../test_ctypes}/test_refcounts.py | 0
.../test => test/test_ctypes}/test_repr.py | 0
.../test_ctypes}/test_returnfuncptrs.py | 0
.../test_ctypes}/test_simplesubclasses.py | 0
.../test => test/test_ctypes}/test_sizes.py | 0
.../test => test/test_ctypes}/test_slicing.py | 2 +-
.../test_ctypes}/test_stringptr.py | 0
.../test => test/test_ctypes}/test_strings.py | 2 +-
.../test_ctypes}/test_struct_fields.py | 0
.../test_ctypes}/test_structures.py | 2 +-
.../test_ctypes}/test_unaligned_structures.py | 0
.../test => test/test_ctypes}/test_unicode.py | 2 +-
.../test => test/test_ctypes}/test_values.py | 0
.../test_ctypes}/test_varsize_struct.py | 0
.../test => test/test_ctypes}/test_win32.py | 0
.../test_ctypes}/test_wintypes.py | 0
Makefile.pre.in | 4 +-
...2-06-20-23-04-52.gh-issue-93839.OE3Ybk.rst | 2 +
PCbuild/lib.pyproj | 109 +++++++++---------
Tools/wasm/wasm_assets.py | 1 -
60 files changed, 83 insertions(+), 93 deletions(-)
delete mode 100644 Lib/ctypes/test/__main__.py
delete mode 100644 Lib/test/test_ctypes.py
rename Lib/{ctypes/test => test/test_ctypes}/__init__.py (100%)
create mode 100644 Lib/test/test_ctypes/__main__.py
rename Lib/{ctypes/test => test/test_ctypes}/test_anon.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_array_in_pointer.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_arrays.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_as_parameter.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_bitfields.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_buffers.py (98%)
rename Lib/{ctypes/test => test/test_ctypes}/test_bytes.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_byteswap.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_callbacks.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_cast.py (98%)
rename Lib/{ctypes/test => test/test_ctypes}/test_cfuncs.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_checkretval.py (95%)
rename Lib/{ctypes/test => test/test_ctypes}/test_delattr.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_errno.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_find.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_frombuffer.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_funcptr.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_functions.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_incomplete.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_init.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_internals.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_keeprefs.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_libc.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_loading.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_macholib.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_memfunctions.py (98%)
rename Lib/{ctypes/test => test/test_ctypes}/test_numbers.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_objects.py (87%)
rename Lib/{ctypes/test => test/test_ctypes}/test_parameters.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_pep3118.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_pickling.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_pointers.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_prototypes.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_python_api.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_random_things.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_refcounts.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_repr.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_returnfuncptrs.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_simplesubclasses.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_sizes.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_slicing.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_stringptr.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_strings.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_struct_fields.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_structures.py (99%)
rename Lib/{ctypes/test => test/test_ctypes}/test_unaligned_structures.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_unicode.py (97%)
rename Lib/{ctypes/test => test/test_ctypes}/test_values.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_varsize_struct.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_win32.py (100%)
rename Lib/{ctypes/test => test/test_ctypes}/test_wintypes.py (100%)
create mode 100644 Misc/NEWS.d/next/Tests/2022-06-20-23-04-52.gh-issue-93839.OE3Ybk.rst
diff --git a/Lib/ctypes/test/__main__.py b/Lib/ctypes/test/__main__.py
deleted file mode 100644
index 362a9ec8cf..0000000000
--- a/Lib/ctypes/test/__main__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-from ctypes.test import load_tests
-import unittest
-
-unittest.main()
diff --git a/Lib/test/leakers/test_ctypes.py b/Lib/test/leakers/test_ctypes.py
index 7d7e9ff3a1..ec09ac3699 100644
--- a/Lib/test/leakers/test_ctypes.py
+++ b/Lib/test/leakers/test_ctypes.py
@@ -1,5 +1,5 @@
-# Taken from Lib/ctypes/test/test_keeprefs.py, PointerToStructure.test().
+# Taken from Lib/test/test_ctypes/test_keeprefs.py, PointerToStructure.test().
from ctypes import Structure, c_int, POINTER
import gc
diff --git a/Lib/test/test_ctypes.py b/Lib/test/test_ctypes.py
deleted file mode 100644
index b0a12c9734..0000000000
--- a/Lib/test/test_ctypes.py
+++ /dev/null
@@ -1,10 +0,0 @@
-import unittest
-from test.support.import_helper import import_module
-
-
-ctypes_test = import_module('ctypes.test')
-
-load_tests = ctypes_test.load_tests
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/Lib/ctypes/test/__init__.py b/Lib/test/test_ctypes/__init__.py
similarity index 100%
rename from Lib/ctypes/test/__init__.py
rename to Lib/test/test_ctypes/__init__.py
diff --git a/Lib/test/test_ctypes/__main__.py b/Lib/test/test_ctypes/__main__.py
new file mode 100644
index 0000000000..3003d4db89
--- /dev/null
+++ b/Lib/test/test_ctypes/__main__.py
@@ -0,0 +1,4 @@
+from test.test_ctypes import load_tests
+import unittest
+
+unittest.main()
diff --git a/Lib/ctypes/test/test_anon.py b/Lib/test/test_ctypes/test_anon.py
similarity index 100%
rename from Lib/ctypes/test/test_anon.py
rename to Lib/test/test_ctypes/test_anon.py
diff --git a/Lib/ctypes/test/test_array_in_pointer.py b/Lib/test/test_ctypes/test_array_in_pointer.py
similarity index 100%
rename from Lib/ctypes/test/test_array_in_pointer.py
rename to Lib/test/test_ctypes/test_array_in_pointer.py
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/test/test_ctypes/test_arrays.py
similarity index 99%
rename from Lib/ctypes/test/test_arrays.py
rename to Lib/test/test_ctypes/test_arrays.py
index 14603b7049..415a5785a9 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/test/test_ctypes/test_arrays.py
@@ -3,7 +3,7 @@
import sys
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
formats = "bBhHiIlLqQfd"
diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/test/test_ctypes/test_as_parameter.py
similarity index 99%
rename from Lib/ctypes/test/test_as_parameter.py
rename to Lib/test/test_ctypes/test_as_parameter.py
index f9d27cb89d..b35defb158 100644
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/test/test_ctypes/test_as_parameter.py
@@ -1,6 +1,6 @@
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import _ctypes_test
dll = CDLL(_ctypes_test.__file__)
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/test/test_ctypes/test_bitfields.py
similarity index 99%
rename from Lib/ctypes/test/test_bitfields.py
rename to Lib/test/test_ctypes/test_bitfields.py
index 66acd62e68..dad71a0ba7 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/test/test_ctypes/test_bitfields.py
@@ -1,5 +1,5 @@
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
from test import support
import unittest
import os
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/test/test_ctypes/test_buffers.py
similarity index 98%
rename from Lib/ctypes/test/test_buffers.py
rename to Lib/test/test_ctypes/test_buffers.py
index 15782be757..a9be2023aa 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/test/test_ctypes/test_buffers.py
@@ -1,5 +1,5 @@
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import unittest
class StringBufferTestCase(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_bytes.py b/Lib/test/test_ctypes/test_bytes.py
similarity index 100%
rename from Lib/ctypes/test/test_bytes.py
rename to Lib/test/test_ctypes/test_bytes.py
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/test/test_ctypes/test_byteswap.py
similarity index 100%
rename from Lib/ctypes/test/test_byteswap.py
rename to Lib/test/test_ctypes/test_byteswap.py
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/test/test_ctypes/test_callbacks.py
similarity index 99%
rename from Lib/ctypes/test/test_callbacks.py
rename to Lib/test/test_ctypes/test_callbacks.py
index 1099cf9a69..2758720d4a 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/test/test_ctypes/test_callbacks.py
@@ -3,7 +3,7 @@
from test import support
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
from _ctypes import CTYPES_MAX_ARGCOUNT
import _ctypes_test
diff --git a/Lib/ctypes/test/test_cast.py b/Lib/test/test_ctypes/test_cast.py
similarity index 98%
rename from Lib/ctypes/test/test_cast.py
rename to Lib/test/test_ctypes/test_cast.py
index 6878f97328..7ee23b16f1 100644
--- a/Lib/ctypes/test/test_cast.py
+++ b/Lib/test/test_ctypes/test_cast.py
@@ -1,5 +1,5 @@
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import unittest
import sys
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/test/test_ctypes/test_cfuncs.py
similarity index 99%
rename from Lib/ctypes/test/test_cfuncs.py
rename to Lib/test/test_ctypes/test_cfuncs.py
index ac2240fa19..0a9394bf31 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/test/test_ctypes/test_cfuncs.py
@@ -3,7 +3,7 @@
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import _ctypes_test
diff --git a/Lib/ctypes/test/test_checkretval.py b/Lib/test/test_ctypes/test_checkretval.py
similarity index 95%
rename from Lib/ctypes/test/test_checkretval.py
rename to Lib/test/test_ctypes/test_checkretval.py
index e9567dc391..1492099f4b 100644
--- a/Lib/ctypes/test/test_checkretval.py
+++ b/Lib/test/test_ctypes/test_checkretval.py
@@ -1,7 +1,7 @@
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
class CHECKED(c_int):
def _check_retval_(value):
diff --git a/Lib/ctypes/test/test_delattr.py b/Lib/test/test_ctypes/test_delattr.py
similarity index 100%
rename from Lib/ctypes/test/test_delattr.py
rename to Lib/test/test_ctypes/test_delattr.py
diff --git a/Lib/ctypes/test/test_errno.py b/Lib/test/test_ctypes/test_errno.py
similarity index 100%
rename from Lib/ctypes/test/test_errno.py
rename to Lib/test/test_ctypes/test_errno.py
diff --git a/Lib/ctypes/test/test_find.py b/Lib/test/test_ctypes/test_find.py
similarity index 100%
rename from Lib/ctypes/test/test_find.py
rename to Lib/test/test_ctypes/test_find.py
diff --git a/Lib/ctypes/test/test_frombuffer.py b/Lib/test/test_ctypes/test_frombuffer.py
similarity index 100%
rename from Lib/ctypes/test/test_frombuffer.py
rename to Lib/test/test_ctypes/test_frombuffer.py
diff --git a/Lib/ctypes/test/test_funcptr.py b/Lib/test/test_ctypes/test_funcptr.py
similarity index 100%
rename from Lib/ctypes/test/test_funcptr.py
rename to Lib/test/test_ctypes/test_funcptr.py
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/test/test_ctypes/test_functions.py
similarity index 99%
rename from Lib/ctypes/test/test_functions.py
rename to Lib/test/test_ctypes/test_functions.py
index f9e92e1cc6..4a784c8d79 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/test/test_ctypes/test_functions.py
@@ -6,7 +6,7 @@
"""
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import sys, unittest
try:
diff --git a/Lib/ctypes/test/test_incomplete.py b/Lib/test/test_ctypes/test_incomplete.py
similarity index 100%
rename from Lib/ctypes/test/test_incomplete.py
rename to Lib/test/test_ctypes/test_incomplete.py
diff --git a/Lib/ctypes/test/test_init.py b/Lib/test/test_ctypes/test_init.py
similarity index 100%
rename from Lib/ctypes/test/test_init.py
rename to Lib/test/test_ctypes/test_init.py
diff --git a/Lib/ctypes/test/test_internals.py b/Lib/test/test_ctypes/test_internals.py
similarity index 100%
rename from Lib/ctypes/test/test_internals.py
rename to Lib/test/test_ctypes/test_internals.py
diff --git a/Lib/ctypes/test/test_keeprefs.py b/Lib/test/test_ctypes/test_keeprefs.py
similarity index 100%
rename from Lib/ctypes/test/test_keeprefs.py
rename to Lib/test/test_ctypes/test_keeprefs.py
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/test/test_ctypes/test_libc.py
similarity index 100%
rename from Lib/ctypes/test/test_libc.py
rename to Lib/test/test_ctypes/test_libc.py
diff --git a/Lib/ctypes/test/test_loading.py b/Lib/test/test_ctypes/test_loading.py
similarity index 100%
rename from Lib/ctypes/test/test_loading.py
rename to Lib/test/test_ctypes/test_loading.py
diff --git a/Lib/ctypes/test/test_macholib.py b/Lib/test/test_ctypes/test_macholib.py
similarity index 100%
rename from Lib/ctypes/test/test_macholib.py
rename to Lib/test/test_ctypes/test_macholib.py
diff --git a/Lib/ctypes/test/test_memfunctions.py b/Lib/test/test_ctypes/test_memfunctions.py
similarity index 98%
rename from Lib/ctypes/test/test_memfunctions.py
rename to Lib/test/test_ctypes/test_memfunctions.py
index e784b9a706..d5c9735211 100644
--- a/Lib/ctypes/test/test_memfunctions.py
+++ b/Lib/test/test_ctypes/test_memfunctions.py
@@ -2,7 +2,7 @@
from test import support
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
class MemFunctionsTest(unittest.TestCase):
@unittest.skip('test disabled')
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/test/test_ctypes/test_numbers.py
similarity index 100%
rename from Lib/ctypes/test/test_numbers.py
rename to Lib/test/test_ctypes/test_numbers.py
diff --git a/Lib/ctypes/test/test_objects.py b/Lib/test/test_ctypes/test_objects.py
similarity index 87%
rename from Lib/ctypes/test/test_objects.py
rename to Lib/test/test_ctypes/test_objects.py
index 19e3dc1f2d..44a3c61ad7 100644
--- a/Lib/ctypes/test/test_objects.py
+++ b/Lib/test/test_ctypes/test_objects.py
@@ -42,7 +42,7 @@
of 'x' ('_b_base_' is either None, or the root object owning the memory block):
>>> print(x.array._b_base_) # doctest: +ELLIPSIS
-<ctypes.test.test_objects.X object at 0x...>
+<test.test_ctypes.test_objects.X object at 0x...>
>>>
>>> x.array[0] = b'spam spam spam'
@@ -56,12 +56,12 @@
import unittest, doctest
-import ctypes.test.test_objects
+import test.test_ctypes.test_objects
class TestCase(unittest.TestCase):
def test(self):
- failures, tests = doctest.testmod(ctypes.test.test_objects)
+ failures, tests = doctest.testmod(test.test_ctypes.test_objects)
self.assertFalse(failures, 'doctests failed, see output above')
if __name__ == '__main__':
- doctest.testmod(ctypes.test.test_objects)
+ doctest.testmod(test.test_ctypes.test_objects)
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/test/test_ctypes/test_parameters.py
similarity index 99%
rename from Lib/ctypes/test/test_parameters.py
rename to Lib/test/test_ctypes/test_parameters.py
index 38af7ac13d..2f755a6d09 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/test/test_ctypes/test_parameters.py
@@ -1,5 +1,5 @@
import unittest
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import test.support
class SimpleTypesTestCase(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_pep3118.py b/Lib/test/test_ctypes/test_pep3118.py
similarity index 100%
rename from Lib/ctypes/test/test_pep3118.py
rename to Lib/test/test_ctypes/test_pep3118.py
diff --git a/Lib/ctypes/test/test_pickling.py b/Lib/test/test_ctypes/test_pickling.py
similarity index 100%
rename from Lib/ctypes/test/test_pickling.py
rename to Lib/test/test_ctypes/test_pickling.py
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/test/test_ctypes/test_pointers.py
similarity index 100%
rename from Lib/ctypes/test/test_pointers.py
rename to Lib/test/test_ctypes/test_pointers.py
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/test/test_ctypes/test_prototypes.py
similarity index 99%
rename from Lib/ctypes/test/test_prototypes.py
rename to Lib/test/test_ctypes/test_prototypes.py
index cd0c649de3..bf27561487 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/test/test_ctypes/test_prototypes.py
@@ -1,5 +1,5 @@
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import unittest
# IMPORTANT INFO:
diff --git a/Lib/ctypes/test/test_python_api.py b/Lib/test/test_ctypes/test_python_api.py
similarity index 100%
rename from Lib/ctypes/test/test_python_api.py
rename to Lib/test/test_ctypes/test_python_api.py
diff --git a/Lib/ctypes/test/test_random_things.py b/Lib/test/test_ctypes/test_random_things.py
similarity index 100%
rename from Lib/ctypes/test/test_random_things.py
rename to Lib/test/test_ctypes/test_random_things.py
diff --git a/Lib/ctypes/test/test_refcounts.py b/Lib/test/test_ctypes/test_refcounts.py
similarity index 100%
rename from Lib/ctypes/test/test_refcounts.py
rename to Lib/test/test_ctypes/test_refcounts.py
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/test/test_ctypes/test_repr.py
similarity index 100%
rename from Lib/ctypes/test/test_repr.py
rename to Lib/test/test_ctypes/test_repr.py
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/test/test_ctypes/test_returnfuncptrs.py
similarity index 100%
rename from Lib/ctypes/test/test_returnfuncptrs.py
rename to Lib/test/test_ctypes/test_returnfuncptrs.py
diff --git a/Lib/ctypes/test/test_simplesubclasses.py b/Lib/test/test_ctypes/test_simplesubclasses.py
similarity index 100%
rename from Lib/ctypes/test/test_simplesubclasses.py
rename to Lib/test/test_ctypes/test_simplesubclasses.py
diff --git a/Lib/ctypes/test/test_sizes.py b/Lib/test/test_ctypes/test_sizes.py
similarity index 100%
rename from Lib/ctypes/test/test_sizes.py
rename to Lib/test/test_ctypes/test_sizes.py
diff --git a/Lib/ctypes/test/test_slicing.py b/Lib/test/test_ctypes/test_slicing.py
similarity index 99%
rename from Lib/ctypes/test/test_slicing.py
rename to Lib/test/test_ctypes/test_slicing.py
index a3932f1767..b3e68f9a82 100644
--- a/Lib/ctypes/test/test_slicing.py
+++ b/Lib/test/test_ctypes/test_slicing.py
@@ -1,6 +1,6 @@
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import _ctypes_test
diff --git a/Lib/ctypes/test/test_stringptr.py b/Lib/test/test_ctypes/test_stringptr.py
similarity index 100%
rename from Lib/ctypes/test/test_stringptr.py
rename to Lib/test/test_ctypes/test_stringptr.py
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/test/test_ctypes/test_strings.py
similarity index 99%
rename from Lib/ctypes/test/test_strings.py
rename to Lib/test/test_ctypes/test_strings.py
index 12e208828a..a9003be3f5 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/test/test_ctypes/test_strings.py
@@ -1,6 +1,6 @@
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
class StringArrayTestCase(unittest.TestCase):
def test(self):
diff --git a/Lib/ctypes/test/test_struct_fields.py b/Lib/test/test_ctypes/test_struct_fields.py
similarity index 100%
rename from Lib/ctypes/test/test_struct_fields.py
rename to Lib/test/test_ctypes/test_struct_fields.py
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/test/test_ctypes/test_structures.py
similarity index 99%
rename from Lib/ctypes/test/test_structures.py
rename to Lib/test/test_ctypes/test_structures.py
index 97ad2b8ed8..13c0470ba2 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/test/test_ctypes/test_structures.py
@@ -2,7 +2,7 @@
import sys
import unittest
from ctypes import *
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
from struct import calcsize
import _ctypes_test
from test import support
diff --git a/Lib/ctypes/test/test_unaligned_structures.py b/Lib/test/test_ctypes/test_unaligned_structures.py
similarity index 100%
rename from Lib/ctypes/test/test_unaligned_structures.py
rename to Lib/test/test_ctypes/test_unaligned_structures.py
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/test/test_ctypes/test_unicode.py
similarity index 97%
rename from Lib/ctypes/test/test_unicode.py
rename to Lib/test/test_ctypes/test_unicode.py
index 60c75424b7..319cb3b1dc 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/test/test_ctypes/test_unicode.py
@@ -1,6 +1,6 @@
import unittest
import ctypes
-from ctypes.test import need_symbol
+from test.test_ctypes import need_symbol
import _ctypes_test
diff --git a/Lib/ctypes/test/test_values.py b/Lib/test/test_ctypes/test_values.py
similarity index 100%
rename from Lib/ctypes/test/test_values.py
rename to Lib/test/test_ctypes/test_values.py
diff --git a/Lib/ctypes/test/test_varsize_struct.py b/Lib/test/test_ctypes/test_varsize_struct.py
similarity index 100%
rename from Lib/ctypes/test/test_varsize_struct.py
rename to Lib/test/test_ctypes/test_varsize_struct.py
diff --git a/Lib/ctypes/test/test_win32.py b/Lib/test/test_ctypes/test_win32.py
similarity index 100%
rename from Lib/ctypes/test/test_win32.py
rename to Lib/test/test_ctypes/test_win32.py
diff --git a/Lib/ctypes/test/test_wintypes.py b/Lib/test/test_ctypes/test_wintypes.py
similarity index 100%
rename from Lib/ctypes/test/test_wintypes.py
rename to Lib/test/test_ctypes/test_wintypes.py
diff --git a/Misc/NEWS.d/next/Tests/2022-06-20-23-04-52.gh-issue-93839.OE3Ybk.rst b/Misc/NEWS.d/next/Tests/2022-06-20-23-04-52.gh-issue-93839.OE3Ybk.rst
new file mode 100644
index 0000000000..121b64b133
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2022-06-20-23-04-52.gh-issue-93839.OE3Ybk.rst
@@ -0,0 +1,2 @@
+Move ``Lib/ctypes/test/`` to ``Lib/test/test_ctypes/``. Patch by Victor
+Stinner.
diff --git a/PCbuild/lib.pyproj b/PCbuild/lib.pyproj
index 43c570f1da..692b083349 100644
--- a/PCbuild/lib.pyproj
+++ b/PCbuild/lib.pyproj
@@ -83,59 +83,6 @@
<Compile Include="ctypes\macholib\dylib.py" />
<Compile Include="ctypes\macholib\framework.py" />
<Compile Include="ctypes\macholib\__init__.py" />
- <Compile Include="ctypes\test\test_anon.py" />
- <Compile Include="ctypes\test\test_arrays.py" />
- <Compile Include="ctypes\test\test_array_in_pointer.py" />
- <Compile Include="ctypes\test\test_as_parameter.py" />
- <Compile Include="ctypes\test\test_bitfields.py" />
- <Compile Include="ctypes\test\test_buffers.py" />
- <Compile Include="ctypes\test\test_bytes.py" />
- <Compile Include="ctypes\test\test_byteswap.py" />
- <Compile Include="ctypes\test\test_callbacks.py" />
- <Compile Include="ctypes\test\test_cast.py" />
- <Compile Include="ctypes\test\test_cfuncs.py" />
- <Compile Include="ctypes\test\test_checkretval.py" />
- <Compile Include="ctypes\test\test_delattr.py" />
- <Compile Include="ctypes\test\test_errno.py" />
- <Compile Include="ctypes\test\test_find.py" />
- <Compile Include="ctypes\test\test_frombuffer.py" />
- <Compile Include="ctypes\test\test_funcptr.py" />
- <Compile Include="ctypes\test\test_functions.py" />
- <Compile Include="ctypes\test\test_incomplete.py" />
- <Compile Include="ctypes\test\test_init.py" />
- <Compile Include="ctypes\test\test_internals.py" />
- <Compile Include="ctypes\test\test_keeprefs.py" />
- <Compile Include="ctypes\test\test_libc.py" />
- <Compile Include="ctypes\test\test_loading.py" />
- <Compile Include="ctypes\test\test_macholib.py" />
- <Compile Include="ctypes\test\test_memfunctions.py" />
- <Compile Include="ctypes\test\test_numbers.py" />
- <Compile Include="ctypes\test\test_objects.py" />
- <Compile Include="ctypes\test\test_parameters.py" />
- <Compile Include="ctypes\test\test_pep3118.py" />
- <Compile Include="ctypes\test\test_pickling.py" />
- <Compile Include="ctypes\test\test_pointers.py" />
- <Compile Include="ctypes\test\test_prototypes.py" />
- <Compile Include="ctypes\test\test_python_api.py" />
- <Compile Include="ctypes\test\test_random_things.py" />
- <Compile Include="ctypes\test\test_refcounts.py" />
- <Compile Include="ctypes\test\test_repr.py" />
- <Compile Include="ctypes\test\test_returnfuncptrs.py" />
- <Compile Include="ctypes\test\test_simplesubclasses.py" />
- <Compile Include="ctypes\test\test_sizes.py" />
- <Compile Include="ctypes\test\test_slicing.py" />
- <Compile Include="ctypes\test\test_stringptr.py" />
- <Compile Include="ctypes\test\test_strings.py" />
- <Compile Include="ctypes\test\test_structures.py" />
- <Compile Include="ctypes\test\test_struct_fields.py" />
- <Compile Include="ctypes\test\test_unaligned_structures.py" />
- <Compile Include="ctypes\test\test_unicode.py" />
- <Compile Include="ctypes\test\test_values.py" />
- <Compile Include="ctypes\test\test_varsize_struct.py" />
- <Compile Include="ctypes\test\test_win32.py" />
- <Compile Include="ctypes\test\test_wintypes.py" />
- <Compile Include="ctypes\test\__init__.py" />
- <Compile Include="ctypes\test\__main__.py" />
<Compile Include="ctypes\util.py" />
<Compile Include="ctypes\wintypes.py" />
<Compile Include="ctypes\_endian.py" />
@@ -944,7 +891,59 @@
<Compile Include="test\test_crashers.py" />
<Compile Include="test\test_crypt.py" />
<Compile Include="test\test_csv.py" />
- <Compile Include="test\test_ctypes.py" />
+ <Compile Include="test\test_ctypes\test_anon.py" />
+ <Compile Include="test\test_ctypes\test_arrays.py" />
+ <Compile Include="test\test_ctypes\test_array_in_pointer.py" />
+ <Compile Include="test\test_ctypes\test_as_parameter.py" />
+ <Compile Include="test\test_ctypes\test_bitfields.py" />
+ <Compile Include="test\test_ctypes\test_buffers.py" />
+ <Compile Include="test\test_ctypes\test_bytes.py" />
+ <Compile Include="test\test_ctypes\test_byteswap.py" />
+ <Compile Include="test\test_ctypes\test_callbacks.py" />
+ <Compile Include="test\test_ctypes\test_cast.py" />
+ <Compile Include="test\test_ctypes\test_cfuncs.py" />
+ <Compile Include="test\test_ctypes\test_checkretval.py" />
+ <Compile Include="test\test_ctypes\test_delattr.py" />
+ <Compile Include="test\test_ctypes\test_errno.py" />
+ <Compile Include="test\test_ctypes\test_find.py" />
+ <Compile Include="test\test_ctypes\test_frombuffer.py" />
+ <Compile Include="test\test_ctypes\test_funcptr.py" />
+ <Compile Include="test\test_ctypes\test_functions.py" />
+ <Compile Include="test\test_ctypes\test_incomplete.py" />
+ <Compile Include="test\test_ctypes\test_init.py" />
+ <Compile Include="test\test_ctypes\test_internals.py" />
+ <Compile Include="test\test_ctypes\test_keeprefs.py" />
+ <Compile Include="test\test_ctypes\test_libc.py" />
+ <Compile Include="test\test_ctypes\test_loading.py" />
+ <Compile Include="test\test_ctypes\test_macholib.py" />
+ <Compile Include="test\test_ctypes\test_memfunctions.py" />
+ <Compile Include="test\test_ctypes\test_numbers.py" />
+ <Compile Include="test\test_ctypes\test_objects.py" />
+ <Compile Include="test\test_ctypes\test_parameters.py" />
+ <Compile Include="test\test_ctypes\test_pep3118.py" />
+ <Compile Include="test\test_ctypes\test_pickling.py" />
+ <Compile Include="test\test_ctypes\test_pointers.py" />
+ <Compile Include="test\test_ctypes\test_prototypes.py" />
+ <Compile Include="test\test_ctypes\test_python_api.py" />
+ <Compile Include="test\test_ctypes\test_random_things.py" />
+ <Compile Include="test\test_ctypes\test_refcounts.py" />
+ <Compile Include="test\test_ctypes\test_repr.py" />
+ <Compile Include="test\test_ctypes\test_returnfuncptrs.py" />
+ <Compile Include="test\test_ctypes\test_simplesubclasses.py" />
+ <Compile Include="test\test_ctypes\test_sizes.py" />
+ <Compile Include="test\test_ctypes\test_slicing.py" />
+ <Compile Include="test\test_ctypes\test_stringptr.py" />
+ <Compile Include="test\test_ctypes\test_strings.py" />
+ <Compile Include="test\test_ctypes\test_structures.py" />
+ <Compile Include="test\test_ctypes\test_struct_fields.py" />
+ <Compile Include="test\test_ctypes\test_unaligned_structures.py" />
+ <Compile Include="test\test_ctypes\test_unicode.py" />
+ <Compile Include="test\test_ctypes\test_values.py" />
+ <Compile Include="test\test_ctypes\test_varsize_struct.py" />
+ <Compile Include="test\test_ctypes\test_win32.py" />
+ <Compile Include="test\test_ctypes\test_wintypes.py" />
+ <Compile Include="test\test_ctypes\__init__.py" />
+ <Compile Include="test\test_ctypes\__main__.py" />
<Compile Include="test\test_curses.py" />
<Compile Include="test\test_datetime.py" />
<Compile Include="test\test_dbm.py" />
@@ -1725,7 +1724,6 @@
<Folder Include="concurrent\futures" />
<Folder Include="ctypes" />
<Folder Include="ctypes\macholib" />
- <Folder Include="ctypes\test" />
<Folder Include="curses" />
<Folder Include="dbm" />
<Folder Include="distutils" />
@@ -1769,6 +1767,7 @@
<Folder Include="test\subprocessdata" />
<Folder Include="test\support" />
<Folder Include="test\test_asyncio" />
+ <Folder Include="test\test_ctypes" />
<Folder Include="test\test_email" />
<Folder Include="test\test_email\data" />
<Folder Include="test\test_import" />
diff --git a/Tools/wasm/wasm_assets.py b/Tools/wasm/wasm_assets.py
index b7e83517ca..d0a0570840 100755
--- a/Tools/wasm/wasm_assets.py
+++ b/Tools/wasm/wasm_assets.py
@@ -111,7 +111,6 @@
# regression test sub directories
OMIT_SUBDIRS = (
- "ctypes/test/",
"tkinter/test/",
"unittest/test/",
)
--
2.29.2.windows.2

View File

@ -0,0 +1,724 @@
From c735d545343c3ab002c62596b2fb2cfa4488b0af Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Tue, 21 Jun 2022 10:27:59 +0200
Subject: [PATCH 6/9] gh-93839: Move Lib/unttest/test/ to Lib/test/test_unittest/
(#94043)
* Move Lib/unittest/test/ to Lib/test/test_unittest/
* Remove Lib/test/test_unittest.py
* Replace unittest.test with test.test_unittest
* Remove unittest.load_tests()
* Rewrite unittest __init__.py and __main__.py
* Update build system, CODEOWNERS, and wasm_assets.py
---
.github/CODEOWNERS | 2 +-
Lib/test/test_unittest.py | 16 -----
Lib/test/test_unittest/__init__.py | 6 ++
Lib/test/test_unittest/__main__.py | 4 ++
.../test_unittest}/_test_warnings.py | 0
.../test => test/test_unittest}/dummy.py | 0
.../test => test/test_unittest}/support.py | 0
.../test_unittest}/test_assertions.py | 0
.../test_unittest}/test_async_case.py | 0
.../test => test/test_unittest}/test_break.py | 0
.../test => test/test_unittest}/test_case.py | 2 +-
.../test_unittest}/test_discovery.py | 6 +-
.../test_unittest}/test_functiontestcase.py | 2 +-
.../test_unittest}/test_loader.py | 6 +-
.../test_unittest}/test_program.py | 16 ++---
.../test_unittest}/test_result.py | 0
.../test_unittest}/test_runner.py | 2 +-
.../test_unittest}/test_setups.py | 0
.../test_unittest}/test_skipping.py | 2 +-
.../test => test/test_unittest}/test_suite.py | 2 +-
.../test_unittest}/testmock/__init__.py | 2 +-
.../test_unittest}/testmock/__main__.py | 2 +-
.../test_unittest}/testmock/support.py | 0
.../test_unittest}/testmock/testasync.py | 0
.../test_unittest}/testmock/testcallable.py | 2 +-
.../test_unittest}/testmock/testhelpers.py | 0
.../testmock/testmagicmethods.py | 0
.../test_unittest}/testmock/testmock.py | 2 +-
.../test_unittest}/testmock/testpatch.py | 22 +++----
.../test_unittest}/testmock/testsealable.py | 0
.../test_unittest}/testmock/testsentinel.py | 0
.../test_unittest}/testmock/testwith.py | 2 +-
Lib/unittest/__init__.py | 10 ----
Lib/unittest/test/__init__.py | 25 --------
Lib/unittest/test/__main__.py | 18 ------
Makefile.pre.in | 4 +-
PCbuild/lib.pyproj | 58 +++++++++----------
Tools/wasm/wasm_assets.py | 1 -
38 files changed, 77 insertions(+), 137 deletions(-)
delete mode 100644 Lib/test/test_unittest.py
create mode 100644 Lib/test/test_unittest/__init__.py
create mode 100644 Lib/test/test_unittest/__main__.py
rename Lib/{unittest/test => test/test_unittest}/_test_warnings.py (100%)
rename Lib/{unittest/test => test/test_unittest}/dummy.py (100%)
rename Lib/{unittest/test => test/test_unittest}/support.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_assertions.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_async_case.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_break.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_case.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_discovery.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_functiontestcase.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_loader.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_program.py (96%)
rename Lib/{unittest/test => test/test_unittest}/test_result.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_runner.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_setups.py (100%)
rename Lib/{unittest/test => test/test_unittest}/test_skipping.py (99%)
rename Lib/{unittest/test => test/test_unittest}/test_suite.py (99%)
rename Lib/{unittest/test => test/test_unittest}/testmock/__init__.py (86%)
rename Lib/{unittest/test => test/test_unittest}/testmock/__main__.py (86%)
rename Lib/{unittest/test => test/test_unittest}/testmock/support.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testasync.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testcallable.py (98%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testhelpers.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testmagicmethods.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testmock.py (99%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testpatch.py (98%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testsealable.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testsentinel.py (100%)
rename Lib/{unittest/test => test/test_unittest}/testmock/testwith.py (99%)
delete mode 100644 Lib/unittest/test/__init__.py
delete mode 100644 Lib/unittest/test/__main__.py
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
deleted file mode 100644
index 1079c7df2e..0000000000
--- a/Lib/test/test_unittest.py
+++ /dev/null
@@ -1,16 +0,0 @@
-import unittest.test
-
-from test import support
-
-
-def load_tests(*_):
- # used by unittest
- return unittest.test.suite()
-
-
-def tearDownModule():
- support.reap_children()
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/Lib/test/test_unittest/__init__.py b/Lib/test/test_unittest/__init__.py
new file mode 100644
index 0000000000..bc502ef32d
--- /dev/null
+++ b/Lib/test/test_unittest/__init__.py
@@ -0,0 +1,6 @@
+import os.path
+from test.support import load_package_tests
+
+
+def load_tests(*args):
+ return load_package_tests(os.path.dirname(__file__), *args)
diff --git a/Lib/test/test_unittest/__main__.py b/Lib/test/test_unittest/__main__.py
new file mode 100644
index 0000000000..40a23a297e
--- /dev/null
+++ b/Lib/test/test_unittest/__main__.py
@@ -0,0 +1,4 @@
+from . import load_tests
+import unittest
+
+unittest.main()
diff --git a/Lib/unittest/test/_test_warnings.py b/Lib/test/test_unittest/_test_warnings.py
similarity index 100%
rename from Lib/unittest/test/_test_warnings.py
rename to Lib/test/test_unittest/_test_warnings.py
diff --git a/Lib/unittest/test/dummy.py b/Lib/test/test_unittest/dummy.py
similarity index 100%
rename from Lib/unittest/test/dummy.py
rename to Lib/test/test_unittest/dummy.py
diff --git a/Lib/unittest/test/support.py b/Lib/test/test_unittest/support.py
similarity index 100%
rename from Lib/unittest/test/support.py
rename to Lib/test/test_unittest/support.py
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/test/test_unittest/test_assertions.py
similarity index 100%
rename from Lib/unittest/test/test_assertions.py
rename to Lib/test/test_unittest/test_assertions.py
diff --git a/Lib/unittest/test/test_async_case.py b/Lib/test/test_unittest/test_async_case.py
similarity index 100%
rename from Lib/unittest/test/test_async_case.py
rename to Lib/test/test_unittest/test_async_case.py
diff --git a/Lib/unittest/test/test_break.py b/Lib/test/test_unittest/test_break.py
similarity index 100%
rename from Lib/unittest/test/test_break.py
rename to Lib/test/test_unittest/test_break.py
diff --git a/Lib/unittest/test/test_case.py b/Lib/test/test_unittest/test_case.py
similarity index 99%
rename from Lib/unittest/test/test_case.py
rename to Lib/test/test_unittest/test_case.py
index 374a255255..e000fe4f07 100644
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/test/test_unittest/test_case.py
@@ -15,7 +15,7 @@
import unittest
-from unittest.test.support import (
+from test.test_unittest.support import (
TestEquality, TestHashing, LoggingResult, LegacyLoggingResult,
ResultWithNoStartTestRunStopTestRun
)
diff --git a/Lib/unittest/test/test_discovery.py b/Lib/test/test_unittest/test_discovery.py
similarity index 99%
rename from Lib/unittest/test/test_discovery.py
rename to Lib/test/test_unittest/test_discovery.py
index 3b58786ec1..946fa1258e 100644
--- a/Lib/unittest/test/test_discovery.py
+++ b/Lib/test/test_unittest/test_discovery.py
@@ -10,7 +10,7 @@
import unittest
import unittest.mock
-import unittest.test
+import test.test_unittest
class TestableTestProgram(unittest.TestProgram):
@@ -789,7 +789,7 @@ def test_discovery_from_dotted_path(self):
loader = unittest.TestLoader()
tests = [self]
- expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
+ expectedPath = os.path.abspath(os.path.dirname(test.test_unittest.__file__))
self.wasRun = False
def _find_tests(start_dir, pattern):
@@ -797,7 +797,7 @@ def _find_tests(start_dir, pattern):
self.assertEqual(start_dir, expectedPath)
return tests
loader._find_tests = _find_tests
- suite = loader.discover('unittest.test')
+ suite = loader.discover('test.test_unittest')
self.assertTrue(self.wasRun)
self.assertEqual(suite._tests, tests)
diff --git a/Lib/unittest/test/test_functiontestcase.py b/Lib/test/test_unittest/test_functiontestcase.py
similarity index 99%
rename from Lib/unittest/test/test_functiontestcase.py
rename to Lib/test/test_unittest/test_functiontestcase.py
index 4971729880..2ebed9564a 100644
--- a/Lib/unittest/test/test_functiontestcase.py
+++ b/Lib/test/test_unittest/test_functiontestcase.py
@@ -1,6 +1,6 @@
import unittest
-from unittest.test.support import LoggingResult
+from test.test_unittest.support import LoggingResult
class Test_FunctionTestCase(unittest.TestCase):
diff --git a/Lib/unittest/test/test_loader.py b/Lib/test/test_unittest/test_loader.py
similarity index 99%
rename from Lib/unittest/test/test_loader.py
rename to Lib/test/test_unittest/test_loader.py
index de2268cda9..c06ebb658d 100644
--- a/Lib/unittest/test/test_loader.py
+++ b/Lib/test/test_unittest/test_loader.py
@@ -716,7 +716,7 @@ def test_loadTestsFromName__module_not_loaded(self):
# We're going to try to load this module as a side-effect, so it
# better not be loaded before we try.
#
- module_name = 'unittest.test.dummy'
+ module_name = 'test.test_unittest.dummy'
sys.modules.pop(module_name, None)
loader = unittest.TestLoader()
@@ -844,7 +844,7 @@ def test_loadTestsFromNames__unknown_attr_name(self):
loader = unittest.TestLoader()
suite = loader.loadTestsFromNames(
- ['unittest.loader.sdasfasfasdf', 'unittest.test.dummy'])
+ ['unittest.loader.sdasfasfasdf', 'test.test_unittest.dummy'])
error, test = self.check_deferred_error(loader, list(suite)[0])
expected = "module 'unittest.loader' has no attribute 'sdasfasfasdf'"
self.assertIn(
@@ -1141,7 +1141,7 @@ def test_loadTestsFromNames__module_not_loaded(self):
# We're going to try to load this module as a side-effect, so it
# better not be loaded before we try.
#
- module_name = 'unittest.test.dummy'
+ module_name = 'test.test_unittest.dummy'
sys.modules.pop(module_name, None)
loader = unittest.TestLoader()
diff --git a/Lib/unittest/test/test_program.py b/Lib/test/test_unittest/test_program.py
similarity index 96%
rename from Lib/unittest/test/test_program.py
rename to Lib/test/test_unittest/test_program.py
index 26a8550af8..169fc4ed94 100644
--- a/Lib/unittest/test/test_program.py
+++ b/Lib/test/test_unittest/test_program.py
@@ -5,8 +5,8 @@
import subprocess
from test import support
import unittest
-import unittest.test
-from unittest.test.test_result import BufferedWriter
+import test.test_unittest
+from test.test_unittest.test_result import BufferedWriter
class Test_TestProgram(unittest.TestCase):
@@ -15,7 +15,7 @@ def test_discovery_from_dotted_path(self):
loader = unittest.TestLoader()
tests = [self]
- expectedPath = os.path.abspath(os.path.dirname(unittest.test.__file__))
+ expectedPath = os.path.abspath(os.path.dirname(test.test_unittest.__file__))
self.wasRun = False
def _find_tests(start_dir, pattern):
@@ -23,7 +23,7 @@ def _find_tests(start_dir, pattern):
self.assertEqual(start_dir, expectedPath)
return tests
loader._find_tests = _find_tests
- suite = loader.discover('unittest.test')
+ suite = loader.discover('test.test_unittest')
self.assertTrue(self.wasRun)
self.assertEqual(suite._tests, tests)
@@ -93,10 +93,10 @@ def run(self, test):
sys.argv = ['faketest']
runner = FakeRunner()
program = unittest.TestProgram(testRunner=runner, exit=False,
- defaultTest='unittest.test',
+ defaultTest='test.test_unittest',
testLoader=self.FooBarLoader())
sys.argv = old_argv
- self.assertEqual(('unittest.test',), program.testNames)
+ self.assertEqual(('test.test_unittest',), program.testNames)
def test_defaultTest_with_iterable(self):
class FakeRunner(object):
@@ -109,10 +109,10 @@ def run(self, test):
runner = FakeRunner()
program = unittest.TestProgram(
testRunner=runner, exit=False,
- defaultTest=['unittest.test', 'unittest.test2'],
+ defaultTest=['test.test_unittest', 'test.test_unittest2'],
testLoader=self.FooBarLoader())
sys.argv = old_argv
- self.assertEqual(['unittest.test', 'unittest.test2'],
+ self.assertEqual(['test.test_unittest', 'test.test_unittest2'],
program.testNames)
def test_NonExit(self):
diff --git a/Lib/unittest/test/test_result.py b/Lib/test/test_unittest/test_result.py
similarity index 100%
rename from Lib/unittest/test/test_result.py
rename to Lib/test/test_unittest/test_result.py
diff --git a/Lib/unittest/test/test_runner.py b/Lib/test/test_unittest/test_runner.py
similarity index 99%
rename from Lib/unittest/test/test_runner.py
rename to Lib/test/test_unittest/test_runner.py
index d3488b40e8..9e3a0a9ca0 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/test/test_unittest/test_runner.py
@@ -8,7 +8,7 @@
import unittest
from unittest.case import _Outcome
-from unittest.test.support import (LoggingResult,
+from test.test_unittest.support import (LoggingResult,
ResultWithNoStartTestRunStopTestRun)
diff --git a/Lib/unittest/test/test_setups.py b/Lib/test/test_unittest/test_setups.py
similarity index 100%
rename from Lib/unittest/test/test_setups.py
rename to Lib/test/test_unittest/test_setups.py
diff --git a/Lib/unittest/test/test_skipping.py b/Lib/test/test_unittest/test_skipping.py
similarity index 99%
rename from Lib/unittest/test/test_skipping.py
rename to Lib/test/test_unittest/test_skipping.py
index 64ceeae37e..f146dcac18 100644
--- a/Lib/unittest/test/test_skipping.py
+++ b/Lib/test/test_unittest/test_skipping.py
@@ -1,6 +1,6 @@
import unittest
-from unittest.test.support import LoggingResult
+from test.test_unittest.support import LoggingResult
class Test_TestSkipping(unittest.TestCase):
diff --git a/Lib/unittest/test/test_suite.py b/Lib/test/test_unittest/test_suite.py
similarity index 99%
rename from Lib/unittest/test/test_suite.py
rename to Lib/test/test_unittest/test_suite.py
index 0551a16996..ca52ee9d9c 100644
--- a/Lib/unittest/test/test_suite.py
+++ b/Lib/test/test_unittest/test_suite.py
@@ -3,7 +3,7 @@
import gc
import sys
import weakref
-from unittest.test.support import LoggingResult, TestEquality
+from test.test_unittest.support import LoggingResult, TestEquality
### Support code for Test_TestSuite
diff --git a/Lib/unittest/test/testmock/__init__.py b/Lib/test/test_unittest/testmock/__init__.py
similarity index 86%
rename from Lib/unittest/test/testmock/__init__.py
rename to Lib/test/test_unittest/testmock/__init__.py
index 87d7ae994d..6ee60b2376 100644
--- a/Lib/unittest/test/testmock/__init__.py
+++ b/Lib/test/test_unittest/testmock/__init__.py
@@ -10,7 +10,7 @@ def load_tests(*args):
suite = unittest.TestSuite()
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
- modname = "unittest.test.testmock." + fn[:-3]
+ modname = "test.test_unittest.testmock." + fn[:-3]
__import__(modname)
module = sys.modules[modname]
suite.addTest(loader.loadTestsFromModule(module))
diff --git a/Lib/unittest/test/testmock/__main__.py b/Lib/test/test_unittest/testmock/__main__.py
similarity index 86%
rename from Lib/unittest/test/testmock/__main__.py
rename to Lib/test/test_unittest/testmock/__main__.py
index 45c633a4ee..1e3068b0dd 100644
--- a/Lib/unittest/test/testmock/__main__.py
+++ b/Lib/test/test_unittest/testmock/__main__.py
@@ -6,7 +6,7 @@ def load_tests(loader, standard_tests, pattern):
# top level directory cached on loader instance
this_dir = os.path.dirname(__file__)
pattern = pattern or "test*.py"
- # We are inside unittest.test.testmock, so the top-level is three notches up
+ # We are inside test.test_unittest.testmock, so the top-level is three notches up
top_level_dir = os.path.dirname(os.path.dirname(os.path.dirname(this_dir)))
package_tests = loader.discover(start_dir=this_dir, pattern=pattern,
top_level_dir=top_level_dir)
diff --git a/Lib/unittest/test/testmock/support.py b/Lib/test/test_unittest/testmock/support.py
similarity index 100%
rename from Lib/unittest/test/testmock/support.py
rename to Lib/test/test_unittest/testmock/support.py
diff --git a/Lib/unittest/test/testmock/testasync.py b/Lib/test/test_unittest/testmock/testasync.py
similarity index 100%
rename from Lib/unittest/test/testmock/testasync.py
rename to Lib/test/test_unittest/testmock/testasync.py
diff --git a/Lib/unittest/test/testmock/testcallable.py b/Lib/test/test_unittest/testmock/testcallable.py
similarity index 98%
rename from Lib/unittest/test/testmock/testcallable.py
rename to Lib/test/test_unittest/testmock/testcallable.py
index 5eadc00704..ca88511f63 100644
--- a/Lib/unittest/test/testmock/testcallable.py
+++ b/Lib/test/test_unittest/testmock/testcallable.py
@@ -3,7 +3,7 @@
# http://www.voidspace.org.uk/python/mock/
import unittest
-from unittest.test.testmock.support import is_instance, X, SomeClass
+from test.test_unittest.testmock.support import is_instance, X, SomeClass
from unittest.mock import (
Mock, MagicMock, NonCallableMagicMock,
diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/test/test_unittest/testmock/testhelpers.py
similarity index 100%
rename from Lib/unittest/test/testmock/testhelpers.py
rename to Lib/test/test_unittest/testmock/testhelpers.py
diff --git a/Lib/unittest/test/testmock/testmagicmethods.py b/Lib/test/test_unittest/testmock/testmagicmethods.py
similarity index 100%
rename from Lib/unittest/test/testmock/testmagicmethods.py
rename to Lib/test/test_unittest/testmock/testmagicmethods.py
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/test/test_unittest/testmock/testmock.py
similarity index 99%
rename from Lib/unittest/test/testmock/testmock.py
rename to Lib/test/test_unittest/testmock/testmock.py
index c99098dc4e..8a92490137 100644
--- a/Lib/unittest/test/testmock/testmock.py
+++ b/Lib/test/test_unittest/testmock/testmock.py
@@ -5,7 +5,7 @@
from test.support import ALWAYS_EQ
import unittest
-from unittest.test.testmock.support import is_instance
+from test.test_unittest.testmock.support import is_instance
from unittest import mock
from unittest.mock import (
call, DEFAULT, patch, sentinel,
diff --git a/Lib/unittest/test/testmock/testpatch.py b/Lib/test/test_unittest/testmock/testpatch.py
similarity index 98%
rename from Lib/unittest/test/testmock/testpatch.py
rename to Lib/test/test_unittest/testmock/testpatch.py
index 8ab63a1317..93ec0ca4be 100644
--- a/Lib/unittest/test/testmock/testpatch.py
+++ b/Lib/test/test_unittest/testmock/testpatch.py
@@ -7,8 +7,8 @@
from collections import OrderedDict
import unittest
-from unittest.test.testmock import support
-from unittest.test.testmock.support import SomeClass, is_instance
+from test.test_unittest.testmock import support
+from test.test_unittest.testmock.support import SomeClass, is_instance
from test.test_importlib.util import uncache
from unittest.mock import (
@@ -669,7 +669,7 @@ def test_patch_dict_decorator_resolution(self):
# the new dictionary during function call
original = support.target.copy()
- @patch.dict('unittest.test.testmock.support.target', {'bar': 'BAR'})
+ @patch.dict('test.test_unittest.testmock.support.target', {'bar': 'BAR'})
def test():
self.assertEqual(support.target, {'foo': 'BAZ', 'bar': 'BAR'})
@@ -1614,7 +1614,7 @@ def test_patch_with_spec_mock_repr(self):
def test_patch_nested_autospec_repr(self):
- with patch('unittest.test.testmock.support', autospec=True) as m:
+ with patch('test.test_unittest.testmock.support', autospec=True) as m:
self.assertIn(" name='support.SomeClass.wibble()'",
repr(m.SomeClass.wibble()))
self.assertIn(" name='support.SomeClass().wibble()'",
@@ -1882,7 +1882,7 @@ def foo(x=0):
with patch.object(foo, '__module__', "testpatch2"):
self.assertEqual(foo.__module__, "testpatch2")
- self.assertEqual(foo.__module__, 'unittest.test.testmock.testpatch')
+ self.assertEqual(foo.__module__, 'test.test_unittest.testmock.testpatch')
with patch.object(foo, '__annotations__', dict([('s', 1, )])):
self.assertEqual(foo.__annotations__, dict([('s', 1, )]))
@@ -1917,16 +1917,16 @@ def test_dotted_but_module_not_loaded(self):
# This exercises the AttributeError branch of _dot_lookup.
# make sure it's there
- import unittest.test.testmock.support
+ import test.test_unittest.testmock.support
# now make sure it's not:
with patch.dict('sys.modules'):
- del sys.modules['unittest.test.testmock.support']
- del sys.modules['unittest.test.testmock']
- del sys.modules['unittest.test']
+ del sys.modules['test.test_unittest.testmock.support']
+ del sys.modules['test.test_unittest.testmock']
+ del sys.modules['test.test_unittest']
del sys.modules['unittest']
# now make sure we can patch based on a dotted path:
- @patch('unittest.test.testmock.support.X')
+ @patch('test.test_unittest.testmock.support.X')
def test(mock):
pass
test()
@@ -1943,7 +1943,7 @@ class Foo:
def test_cant_set_kwargs_when_passing_a_mock(self):
- @patch('unittest.test.testmock.support.X', new=object(), x=1)
+ @patch('test.test_unittest.testmock.support.X', new=object(), x=1)
def test(): pass
with self.assertRaises(TypeError):
test()
diff --git a/Lib/unittest/test/testmock/testsealable.py b/Lib/test/test_unittest/testmock/testsealable.py
similarity index 100%
rename from Lib/unittest/test/testmock/testsealable.py
rename to Lib/test/test_unittest/testmock/testsealable.py
diff --git a/Lib/unittest/test/testmock/testsentinel.py b/Lib/test/test_unittest/testmock/testsentinel.py
similarity index 100%
rename from Lib/unittest/test/testmock/testsentinel.py
rename to Lib/test/test_unittest/testmock/testsentinel.py
diff --git a/Lib/unittest/test/testmock/testwith.py b/Lib/test/test_unittest/testmock/testwith.py
similarity index 99%
rename from Lib/unittest/test/testmock/testwith.py
rename to Lib/test/test_unittest/testmock/testwith.py
index c74d49a63c..8dc8eb1137 100644
--- a/Lib/unittest/test/testmock/testwith.py
+++ b/Lib/test/test_unittest/testmock/testwith.py
@@ -1,7 +1,7 @@
import unittest
from warnings import catch_warnings
-from unittest.test.testmock.support import is_instance
+from test.test_unittest.testmock.support import is_instance
from unittest.mock import MagicMock, Mock, patch, sentinel, mock_open, call
diff --git a/Lib/unittest/__init__.py b/Lib/unittest/__init__.py
index 005d23f6d0..b8de8c95d6 100644
--- a/Lib/unittest/__init__.py
+++ b/Lib/unittest/__init__.py
@@ -73,16 +73,6 @@ def testMultiply(self):
_TextTestResult = TextTestResult
-# There are no tests here, so don't try to run anything discovered from
-# introspecting the symbols (e.g. FunctionTestCase). Instead, all our
-# tests come from within unittest.test.
-def load_tests(loader, tests, pattern):
- import os.path
- # top level directory cached on loader instance
- this_dir = os.path.dirname(__file__)
- return loader.discover(start_dir=this_dir, pattern=pattern)
-
-
# Lazy import of IsolatedAsyncioTestCase from .async_case
# It imports asyncio, which is relatively heavy, but most tests
# do not need it.
diff --git a/Lib/unittest/test/__init__.py b/Lib/unittest/test/__init__.py
deleted file mode 100644
index 143f4ab5a3..0000000000
--- a/Lib/unittest/test/__init__.py
+++ /dev/null
@@ -1,25 +0,0 @@
-import os
-import sys
-import unittest
-
-
-here = os.path.dirname(__file__)
-loader = unittest.defaultTestLoader
-
-def suite():
- suite = unittest.TestSuite()
- for fn in os.listdir(here):
- if fn.startswith("test") and fn.endswith(".py"):
- modname = "unittest.test." + fn[:-3]
- try:
- __import__(modname)
- except unittest.SkipTest:
- continue
- module = sys.modules[modname]
- suite.addTest(loader.loadTestsFromModule(module))
- suite.addTest(loader.loadTestsFromName('unittest.test.testmock'))
- return suite
-
-
-if __name__ == "__main__":
- unittest.main(defaultTest="suite")
diff --git a/Lib/unittest/test/__main__.py b/Lib/unittest/test/__main__.py
deleted file mode 100644
index 44d0591e84..0000000000
--- a/Lib/unittest/test/__main__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-import os
-import unittest
-
-
-def load_tests(loader, standard_tests, pattern):
- # top level directory cached on loader instance
- this_dir = os.path.dirname(__file__)
- pattern = pattern or "test_*.py"
- # We are inside unittest.test, so the top-level is two notches up
- top_level_dir = os.path.dirname(os.path.dirname(this_dir))
- package_tests = loader.discover(start_dir=this_dir, pattern=pattern,
- top_level_dir=top_level_dir)
- standard_tests.addTests(package_tests)
- return standard_tests
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/PCbuild/lib.pyproj b/PCbuild/lib.pyproj
index 692b083349..f3f44d1d8f 100644
--- a/PCbuild/lib.pyproj
+++ b/PCbuild/lib.pyproj
@@ -1491,33 +1491,33 @@
<Compile Include="unittest\runner.py" />
<Compile Include="unittest\signals.py" />
<Compile Include="unittest\suite.py" />
- <Compile Include="unittest\test\dummy.py" />
- <Compile Include="unittest\test\support.py" />
- <Compile Include="unittest\test\testmock\support.py" />
- <Compile Include="unittest\test\testmock\testcallable.py" />
- <Compile Include="unittest\test\testmock\testhelpers.py" />
- <Compile Include="unittest\test\testmock\testmagicmethods.py" />
- <Compile Include="unittest\test\testmock\testmock.py" />
- <Compile Include="unittest\test\testmock\testpatch.py" />
- <Compile Include="unittest\test\testmock\testsentinel.py" />
- <Compile Include="unittest\test\testmock\testwith.py" />
- <Compile Include="unittest\test\testmock\__init__.py" />
- <Compile Include="unittest\test\testmock\__main__.py" />
- <Compile Include="unittest\test\test_assertions.py" />
- <Compile Include="unittest\test\test_break.py" />
- <Compile Include="unittest\test\test_case.py" />
- <Compile Include="unittest\test\test_discovery.py" />
- <Compile Include="unittest\test\test_functiontestcase.py" />
- <Compile Include="unittest\test\test_loader.py" />
- <Compile Include="unittest\test\test_program.py" />
- <Compile Include="unittest\test\test_result.py" />
- <Compile Include="unittest\test\test_runner.py" />
- <Compile Include="unittest\test\test_setups.py" />
- <Compile Include="unittest\test\test_skipping.py" />
- <Compile Include="unittest\test\test_suite.py" />
- <Compile Include="unittest\test\_test_warnings.py" />
- <Compile Include="unittest\test\__init__.py" />
- <Compile Include="unittest\test\__main__.py" />
+ <Compile Include="test\test_unittest\dummy.py" />
+ <Compile Include="test\test_unittest\support.py" />
+ <Compile Include="test\test_unittest\testmock\support.py" />
+ <Compile Include="test\test_unittest\testmock\testcallable.py" />
+ <Compile Include="test\test_unittest\testmock\testhelpers.py" />
+ <Compile Include="test\test_unittest\testmock\testmagicmethods.py" />
+ <Compile Include="test\test_unittest\testmock\testmock.py" />
+ <Compile Include="test\test_unittest\testmock\testpatch.py" />
+ <Compile Include="test\test_unittest\testmock\testsentinel.py" />
+ <Compile Include="test\test_unittest\testmock\testwith.py" />
+ <Compile Include="test\test_unittest\testmock\__init__.py" />
+ <Compile Include="test\test_unittest\testmock\__main__.py" />
+ <Compile Include="test\test_unittest\test_assertions.py" />
+ <Compile Include="test\test_unittest\test_break.py" />
+ <Compile Include="test\test_unittest\test_case.py" />
+ <Compile Include="test\test_unittest\test_discovery.py" />
+ <Compile Include="test\test_unittest\test_functiontestcase.py" />
+ <Compile Include="test\test_unittest\test_loader.py" />
+ <Compile Include="test\test_unittest\test_program.py" />
+ <Compile Include="test\test_unittest\test_result.py" />
+ <Compile Include="test\test_unittest\test_runner.py" />
+ <Compile Include="test\test_unittest\test_setups.py" />
+ <Compile Include="test\test_unittest\test_skipping.py" />
+ <Compile Include="test\test_unittest\test_suite.py" />
+ <Compile Include="test\test_unittest\_test_warnings.py" />
+ <Compile Include="test\test_unittest\__init__.py" />
+ <Compile Include="test\test_unittest\__main__.py" />
<Compile Include="unittest\util.py" />
<Compile Include="unittest\__init__.py" />
<Compile Include="unittest\__main__.py" />
@@ -1804,6 +1804,8 @@
<Folder Include="test\test_json" />
<Folder Include="test\test_peg_generator" />
<Folder Include="test\test_tools" />
+ <Folder Include="test\test_unittest" />
+ <Folder Include="test\test_unittest\testmock" />
<Folder Include="test\test_warnings" />
<Folder Include="test\test_warnings\data" />
<Folder Include="test\tracedmodules" />
@@ -1813,8 +1815,6 @@
<Folder Include="tkinter\test\test_ttk" />
<Folder Include="turtledemo" />
<Folder Include="unittest" />
- <Folder Include="unittest\test" />
- <Folder Include="unittest\test\testmock" />
<Folder Include="urllib" />
<Folder Include="venv" />
<Folder Include="wsgiref" />
diff --git a/Tools/wasm/wasm_assets.py b/Tools/wasm/wasm_assets.py
index d0a0570840..67afde60f0 100755
--- a/Tools/wasm/wasm_assets.py
+++ b/Tools/wasm/wasm_assets.py
@@ -112,7 +112,6 @@
# regression test sub directories
OMIT_SUBDIRS = (
"tkinter/test/",
- "unittest/test/",
)
def get_builddir(args: argparse.Namespace) -> pathlib.Path:
--
2.29.2.windows.2

View File

@ -0,0 +1,40 @@
From 50ebd72fb0e69c78f95cea3d4a47589beb91ac37 Mon Sep 17 00:00:00 2001
From: Christian Heimes <christian@python.org>
Date: Tue, 21 Jun 2022 14:51:39 +0200
Subject: [PATCH 7/9] gh-93839: Use load_package_tests() for testmock (GH-94055)
Fixes failing tests on WebAssembly platforms.
Automerge-Triggered-By: GH:tiran
---
Lib/test/test_unittest/testmock/__init__.py | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/Lib/test/test_unittest/testmock/__init__.py b/Lib/test/test_unittest/testmock/__init__.py
index 6ee60b2376..bc502ef32d 100644
--- a/Lib/test/test_unittest/testmock/__init__.py
+++ b/Lib/test/test_unittest/testmock/__init__.py
@@ -1,17 +1,6 @@
-import os
-import sys
-import unittest
+import os.path
+from test.support import load_package_tests
-here = os.path.dirname(__file__)
-loader = unittest.defaultTestLoader
-
def load_tests(*args):
- suite = unittest.TestSuite()
- for fn in os.listdir(here):
- if fn.startswith("test") and fn.endswith(".py"):
- modname = "test.test_unittest.testmock." + fn[:-3]
- __import__(modname)
- module = sys.modules[modname]
- suite.addTest(loader.loadTestsFromModule(module))
- return suite
+ return load_package_tests(os.path.dirname(__file__), *args)
--
2.29.2.windows.2

View File

@ -0,0 +1,36 @@
From 4c71c808cc65ed6003b1e29d583c71586ebb36e1 Mon Sep 17 00:00:00 2001
From: ryanking13 <def6488@gmail.com>
Date: Wed, 25 Jan 2023 15:54:16 +0900
Subject: [PATCH 8/9] Move test directories
---
Makefile.pre.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Makefile.pre.in b/Makefile.pre.in
index b356f6293e..68c55a356a 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -1932,8 +1932,7 @@ LIBSUBDIRS= asyncio \
xmlrpc \
zoneinfo \
__phello__
-TESTSUBDIRS= ctypes/test \
- distutils/tests \
+TESTSUBDIRS= distutils/tests \
idlelib/idle_test \
lib2to3/tests \
lib2to3/tests/data \
@@ -2009,7 +2008,8 @@ TESTSUBDIRS= ctypes/test \
test/ziptestdata \
tkinter/test tkinter/test/test_tkinter \
tkinter/test/test_ttk \
- unittest/test unittest/test/testmock
+ test/test_ctypes \
+ test/test_unittest test/test_unittest/testmock
TEST_MODULES=@TEST_MODULES@
libinstall: all $(srcdir)/Modules/xxmodule.c
--
2.29.2.windows.2

View File

@ -26,6 +26,7 @@ from urllib import request
from . import common, pypabuild
from .common import (
_environment_substitute_str,
_get_sha256_checksum,
chdir,
exit_with_stdio,
@ -130,7 +131,7 @@ def get_bash_runner() -> Iterator[BashRunnerWithSharedEnvironment]:
yield b
def check_checksum(archive: Path, source_metadata: _SourceSpec) -> None:
def check_checksum(archive: Path, checksum: str) -> None:
"""
Checks that an archive matches the checksum in the package metadata.
@ -139,12 +140,9 @@ def check_checksum(archive: Path, source_metadata: _SourceSpec) -> None:
----------
archive
the path to the archive we wish to checksum
source_metadata
The source section from meta.yaml.
checksum
the checksum we expect the archive to have
"""
if source_metadata.sha256 is None:
return
checksum = source_metadata.sha256
real_checksum = _get_sha256_checksum(archive)
if real_checksum != checksum:
raise ValueError(
@ -191,7 +189,10 @@ def download_and_extract(
The source section from meta.yaml.
"""
# We only call this function when the URL is defined
build_env = get_build_environment_vars()
url = cast(str, src_metadata.url)
url = _environment_substitute_str(url, build_env)
max_retry = 3
for retry_cnt in range(max_retry):
try:
@ -218,7 +219,10 @@ def download_and_extract(
with open(tarballpath, "wb") as f:
f.write(response.read())
try:
check_checksum(tarballpath, src_metadata)
checksum = src_metadata.sha256
if checksum is not None:
checksum = _environment_substitute_str(checksum, build_env)
check_checksum(tarballpath, checksum)
except Exception:
tarballpath.unlink()
raise
@ -768,8 +772,7 @@ def _build_package_inner(
bash_runner.env["PKG_BUILD_DIR"] = str(srcpath)
bash_runner.env["DISTDIR"] = str(src_dist_dir)
if not continue_:
clear_only = package_type == "cpython_module"
prepare_source(build_dir, srcpath, source_metadata, clear_only=clear_only)
prepare_source(build_dir, srcpath, source_metadata)
patch(pkg_root, srcpath, source_metadata)
src_dist_dir.mkdir(exist_ok=True, parents=True)

View File

@ -40,12 +40,12 @@ BUILD_VARS: set[str] = {
"TARGETINSTALLDIR",
"SYSCONFIG_NAME",
"HOSTSITEPACKAGES",
"PYTHON_ARCHIVE_URL",
"PYTHON_ARCHIVE_SHA256",
"PYVERSION",
"PYMAJOR",
"PYMINOR",
"PYMICRO",
"CPYTHONBUILD",
"CPYTHONLIB",
"SIDE_MODULE_CFLAGS",
"SIDE_MODULE_CXXFLAGS",
"SIDE_MODULE_LDFLAGS",
@ -281,6 +281,31 @@ def _get_make_environment_vars() -> dict[str, str]:
return environment
def _environment_substitute_str(string: str, env: dict[str, str] | None = None) -> str:
"""
Substitute $(VAR) in string with the value of the environment variable VAR.
Parameters
----------
string
A string
env
A dictionary of environment variables. If None, use os.environ.
Returns
-------
A string with the substitutions applied.
"""
if env is None:
env = dict(os.environ)
for e_name, e_value in env.items():
string = string.replace(f"$({e_name})", e_value)
return string
def environment_substitute_args(
args: dict[str, str], env: dict[str, str] | None = None
) -> dict[str, Any]:
@ -304,8 +329,7 @@ def environment_substitute_args(
subbed_args = {}
for arg, value in args.items():
if isinstance(value, str):
for e_name, e_value in env.items():
value = value.replace(f"$({e_name})", e_value)
value = _environment_substitute_str(value, env)
subbed_args[arg] = value
return subbed_args