pypy/interpreter/test/test_app_main.py::TestNonInteractive::()::test_putenv_fires_interactive_within_process
self = <pypy.interpreter.test.test_app_main.TestNonInteractive instance at 0x000000011ad1b3a0>
@py.test.mark.skipif('sys.platform=="win32"', reason="windows, sendata, and quoting problems")
def test_putenv_fires_interactive_within_process(self):
try:
import __pypy__
except ImportError:
py.test.skip("This can be only tested on PyPy with real_getenv")
# should be noninteractive when piped in
data = 'import os\nos.putenv("PYTHONINSPECT", "1")\n'
self.run('', senddata=data, expect_prompt=False)
# should go interactive with -c
data = data.replace('\n', ';')
> self.run("-c '%s'" % data, expect_prompt=True)
interpreter/test/test_app_main.py:796:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
interpreter/test/test_app_main.py:680: in run
data, status = self.run_with_status_code(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pypy.interpreter.test.test_app_main.TestNonInteractive instance at 0x000000011ad1b3a0>
cmdline = '/Users/matti/build-worker-arm64/own-macos-arm64/build/virt_test/bin/python "/Users/matti/build-worker-arm64/own-macos-arm64/build/pypy/interpreter/app_main.py" -c \'import os;os.putenv("PYTHONINSPECT", "1");\''
senddata = '', expect_prompt = True, expect_banner = False, python_flags = ''
env = None
def run_with_status_code(self, cmdline, senddata='', expect_prompt=False,
expect_banner=False, python_flags='', env=None):
if os.name == 'nt':
if __pypy__ is None:
py.test.skip('app_main cannot run on non-pypy for windows')
cmdline = '%s %s "%s" %s %s' % (sys.executable, python_flags,
app_main, python_flags, cmdline)
print 'POPEN:', cmdline
process = subprocess.Popen(
cmdline,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
shell=True, env=env,
universal_newlines=True
)
child_in, child_out_err = process.stdin, process.stdout
child_in.write(senddata)
child_in.close()
data = child_out_err.read()
child_out_err.close()
process.wait()
assert (banner in data) == expect_banner # no banner unless expected
> assert ('>>> ' in data) == expect_prompt # no prompt unless expected
E assert '>>> ' in '' == True
interpreter/test/test_app_main.py:676: AssertionError
---------- Captured stdout call ----------
POPEN: /Users/matti/build-worker-arm64/own-macos-arm64/build/virt_test/bin/python "/Users/matti/build-worker-arm64/own-macos-arm64/build/pypy/interpreter/app_main.py"
POPEN: /Users/matti/build-worker-arm64/own-macos-arm64/build/virt_test/bin/python "/Users/matti/build-worker-arm64/own-macos-arm64/build/pypy/interpreter/app_main.py" -c 'import os;os.putenv("PYTHONINSPECT", "1");'
builder: own-macos-arm64 build #1202
test: pypy/interpreter/test/test_app_main/py/TestNonInteractive/()/test_putenv_fires_interactive_within_process