Commit 2e725d8c authored by Berker Peksag's avatar Berker Peksag

Issue #18300: Set TERM='' by default in assert_python_*

parent 29483800
...@@ -73,6 +73,10 @@ def run_python_until_end(*args, **env_vars): ...@@ -73,6 +73,10 @@ def run_python_until_end(*args, **env_vars):
# Need to preserve the original environment, for in-place testing of # Need to preserve the original environment, for in-place testing of
# shared library builds. # shared library builds.
env = os.environ.copy() env = os.environ.copy()
# set TERM='' unless the TERM environment variable is passed explicitly
# see issues #11390 and #18300
if 'TERM' not in env_vars:
env['TERM'] = ''
# But a special flag that can be set to override -- in this case, the # But a special flag that can be set to override -- in this case, the
# caller is responsible to pass the full environment. # caller is responsible to pass the full environment.
if env_vars.pop('__cleanenv', None): if env_vars.pop('__cleanenv', None):
......
...@@ -2719,12 +2719,6 @@ output into something we can doctest against: ...@@ -2719,12 +2719,6 @@ output into something we can doctest against:
>>> def normalize(s): >>> def normalize(s):
... return '\n'.join(s.decode().splitlines()) ... return '\n'.join(s.decode().splitlines())
Note: we also pass TERM='' to all the assert_python calls to avoid a bug
in the readline library that is triggered in these tests because we are
running them in a new python process. See:
http://lists.gnu.org/archive/html/bug-readline/2013-06/msg00000.html
With those preliminaries out of the way, we'll start with a file with two With those preliminaries out of the way, we'll start with a file with two
simple tests and no errors. We'll run both the unadorned doctest command, and simple tests and no errors. We'll run both the unadorned doctest command, and
the verbose version, and then check the output: the verbose version, and then check the output:
...@@ -2741,9 +2735,9 @@ the verbose version, and then check the output: ...@@ -2741,9 +2735,9 @@ the verbose version, and then check the output:
... _ = f.write('\n') ... _ = f.write('\n')
... _ = f.write('And that is it.\n') ... _ = f.write('And that is it.\n')
... rc1, out1, err1 = script_helper.assert_python_ok( ... rc1, out1, err1 = script_helper.assert_python_ok(
... '-m', 'doctest', fn, TERM='') ... '-m', 'doctest', fn)
... rc2, out2, err2 = script_helper.assert_python_ok( ... rc2, out2, err2 = script_helper.assert_python_ok(
... '-m', 'doctest', '-v', fn, TERM='') ... '-m', 'doctest', '-v', fn)
With no arguments and passing tests, we should get no output: With no arguments and passing tests, we should get no output:
...@@ -2806,17 +2800,17 @@ text files). ...@@ -2806,17 +2800,17 @@ text files).
... _ = f.write(' \"\"\"\n') ... _ = f.write(' \"\"\"\n')
... import shutil ... import shutil
... rc1, out1, err1 = script_helper.assert_python_failure( ... rc1, out1, err1 = script_helper.assert_python_failure(
... '-m', 'doctest', fn, fn2, TERM='') ... '-m', 'doctest', fn, fn2)
... rc2, out2, err2 = script_helper.assert_python_ok( ... rc2, out2, err2 = script_helper.assert_python_ok(
... '-m', 'doctest', '-o', 'ELLIPSIS', fn, TERM='') ... '-m', 'doctest', '-o', 'ELLIPSIS', fn)
... rc3, out3, err3 = script_helper.assert_python_ok( ... rc3, out3, err3 = script_helper.assert_python_ok(
... '-m', 'doctest', '-o', 'ELLIPSIS', ... '-m', 'doctest', '-o', 'ELLIPSIS',
... '-o', 'NORMALIZE_WHITESPACE', fn, fn2, TERM='') ... '-o', 'NORMALIZE_WHITESPACE', fn, fn2)
... rc4, out4, err4 = script_helper.assert_python_failure( ... rc4, out4, err4 = script_helper.assert_python_failure(
... '-m', 'doctest', '-f', fn, fn2, TERM='') ... '-m', 'doctest', '-f', fn, fn2)
... rc5, out5, err5 = script_helper.assert_python_ok( ... rc5, out5, err5 = script_helper.assert_python_ok(
... '-m', 'doctest', '-v', '-o', 'ELLIPSIS', ... '-m', 'doctest', '-v', '-o', 'ELLIPSIS',
... '-o', 'NORMALIZE_WHITESPACE', fn, fn2, TERM='') ... '-o', 'NORMALIZE_WHITESPACE', fn, fn2)
Our first test run will show the errors from the first file (doctest stops if a Our first test run will show the errors from the first file (doctest stops if a
file has errors). Note that doctest test-run error output appears on stdout, file has errors). Note that doctest test-run error output appears on stdout,
...@@ -2922,7 +2916,7 @@ We should also check some typical error cases. ...@@ -2922,7 +2916,7 @@ We should also check some typical error cases.
Invalid file name: Invalid file name:
>>> rc, out, err = script_helper.assert_python_failure( >>> rc, out, err = script_helper.assert_python_failure(
... '-m', 'doctest', 'nosuchfile', TERM='') ... '-m', 'doctest', 'nosuchfile')
>>> rc, out >>> rc, out
(1, b'') (1, b'')
>>> print(normalize(err)) # doctest: +ELLIPSIS >>> print(normalize(err)) # doctest: +ELLIPSIS
...@@ -2933,7 +2927,7 @@ Invalid file name: ...@@ -2933,7 +2927,7 @@ Invalid file name:
Invalid doctest option: Invalid doctest option:
>>> rc, out, err = script_helper.assert_python_failure( >>> rc, out, err = script_helper.assert_python_failure(
... '-m', 'doctest', '-o', 'nosuchoption', TERM='') ... '-m', 'doctest', '-o', 'nosuchoption')
>>> rc, out >>> rc, out
(2, b'') (2, b'')
>>> print(normalize(err)) # doctest: +ELLIPSIS >>> print(normalize(err)) # doctest: +ELLIPSIS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment