Closed
Description
Bug report
Bug description:
test_pyrepl starts a new Python process in order to test repl output, but it does not correctly isolate the interpreter from user-set environment variables that will affect the output, like PYTHONPATH and PYTHONSTARTUP. All other places in the testsuite that run python do so with -I
or -E
to avoid this problem.
% cat $PYTHONSTARTUP
#!/usr/bin/env python
from __future__ import division
import readline
import rlcompleter
readline.parse_and_bind('tab: complete')
% ./python -m test test_pyrepl -u all
Using random seed: 1113277385
0:00:00 load avg: 0.17 Run 1 test sequentially in a single process
0:00:00 load avg: 0.17 [1/1] test_pyrepl
test test_pyrepl failed -- Traceback (most recent call last):
File "Lib/test/support/__init__.py", line 2622, in wrapper
return func(*args, **kwargs)
File "Lib/test/test_pyrepl/test_pyrepl.py", line 865, in test_exposed_globals_in_repl
self.assertTrue(case1 or case2 or case3 or case4, output)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: False is not true : sorted(dir())
exit
Python 3.14.0a0 (heads/main-dirty:1dc9a4f6b2, Jul 2 2024, 16:58:02) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> s
>>> so
>>> sor
>>> sort
>>> sorte
>>> sorted
>>> sorted(
>>> sorted(d
>>> sorted(di
>>> sorted(dir
>>> sorted(dir(
>>> sorted(dir()
>>> sorted(dir())
['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'division', 'readline', 'rlcompleter']
>>>
>>> e
>>> ex
>>> exi
>>> exit
test_pyrepl failed (1 failure)
== Tests result: FAILURE ==
1 test failed:
test_pyrepl
Total duration: 2.6 sec
Total tests: run=117 failures=1 skipped=1
Total test files: run=1/1 failed=1
Result: FAILURE
### CPython versions tested on:
3.13, CPython main branch
### Operating systems tested on:
Linux