11name : Reusable Lazy Imports Tests
22
33# Run the CPython test suite with global lazy imports forced on
4- # (``PYTHON_LAZY_IMPORTS=all``, equivalent to `` -X lazy_imports=all``).
4+ # (``-X lazy_imports=all``).
55#
66# Modules that are known to fail under lazy imports are listed in
77# Lib/test/lazy_imports_all_exclude.txt and skipped here. Remove entries from
2424 runs-on : ubuntu-24.04
2525 timeout-minutes : 60
2626 env :
27- PYTHON_LAZY_IMPORTS : all
2827 EXCLUDE_FILE : Lib/test/lazy_imports_all_exclude.txt
2928 steps :
3029 - uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4140 - name : Display build info
4241 run : make pythoninfo
4342 - name : Verify lazy imports are fully enabled
44- run : ./python -c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')"
43+ run : ./python -X lazy_imports=all - c "import sys; assert sys.flags.lazy_imports == 1, sys.flags.lazy_imports; print('lazy imports all enabled')"
4544 - name : Build test list (all tests minus the known-failing exclusions)
4645 run : |
4746 set -euo pipefail
6059 exit 1
6160 fi
6261 echo "Excluding $(wc -l < exclude_tests.txt) module(s); running $(wc -l < run_tests.txt) of $(wc -l < all_tests.txt)."
63- - name : Run stdlib tests with lazy imports
64- run : xvfb-run xargs ./python -m test --fast-ci --timeout=900 < run_tests.txt
62+ - name : Run tests with lazy imports
63+ run : xvfb-run xargs ./python -X lazy_imports=all - m test --fast-ci --timeout=900 < run_tests.txt
6564 - name : Verify excluded tests still need exclusion
6665 if : success()
6766 run : |
@@ -70,12 +69,12 @@ jobs:
7069 while IFS= read -r test_name; do
7170 [ -n "$test_name" ] || continue
7271 echo "Checking excluded test: $test_name"
73- if xvfb-run ./python -m test --fast-ci --timeout=900 "$test_name"; then
72+ if xvfb-run ./python -X lazy_imports=all - m test --fast-ci --timeout=900 "$test_name"; then
7473 unexpected_passes+=("$test_name")
7574 fi
7675 done < exclude_tests.txt
7776 if [ "${#unexpected_passes[@]}" -ne 0 ]; then
78- echo "::error::These tests still appear in $EXCLUDE_FILE but now pass with PYTHON_LAZY_IMPORTS =all. Remove them from the exclude file:"
77+ echo "::error::These tests still appear in $EXCLUDE_FILE but now pass with -X lazy_imports =all. Remove them from the exclude file:"
7978 printf '%s\n' "${unexpected_passes[@]}"
8079 exit 1
8180 fi
0 commit comments