summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2014-06-15 18:06:58 -0700
committerThomas Kluyver <takowl@gmail.com>2014-06-15 18:06:58 -0700
commit9dc15264f618f9b23257ed8f447648ebf46dbec6 (patch)
tree539a93dd6c7edc386d739869372d89c2f542ef1e
parent6447e5f0993c0c6e867e21e8a47c9dbfa66f27cd (diff)
downloadpexpect-9dc15264f618f9b23257ed8f447648ebf46dbec6.tar.gz
Make a modified copy of os.environ for interact testsinteract-does-not-detect-eof
-rwxr-xr-xtests/test_interact.py24
1 files changed, 11 insertions, 13 deletions
diff --git a/tests/test_interact.py b/tests/test_interact.py
index 70a0e08..06fc44a 100755
--- a/tests/test_interact.py
+++ b/tests/test_interact.py
@@ -25,32 +25,30 @@ from __future__ import unicode_literals
import os
import pexpect
import unittest
+import sys
from . import PexpectTestCase
class InteractTestCase (PexpectTestCase.PexpectTestCase):
def setUp(self):
super(InteractTestCase, self).setUp()
- self.save_pythonpath = os.getenv('PYTHONPATH')
+ self.env = env = os.environ.copy()
# Ensure 'import pexpect' works in subprocess interact*.py
- if not self.save_pythonpath:
- os.putenv('PYTHONPATH', self.project_dir)
+ if 'PYTHONPATH' in env:
+ env['PYTHONPATH'] = os.pathsep.join((self.project_dir,
+ env['PYTHONPATH']))
else:
- os.putenv('PYTHONPATH', os.pathsep.join((self.project_dir,
- self.save_pythonpath)))
+ env['PYTHONPATH'] = self.project_dir
- self.interact_py = ' '.join((self.PYTHONBIN,
+ self.interact_py = ' '.join((sys.executable,
'interact.py',))
- self.interact_ucs_py = ' '.join((self.PYTHONBIN,
+ self.interact_ucs_py = ' '.join((sys.executable,
'interact_unicode.py',))
- def tearDown(self):
- os.putenv('PYTHONPATH', self.save_pythonpath or '')
-
def test_interact_escape(self):
" Ensure `escape_character' value exits interactive mode. "
- p = pexpect.spawn(self.interact_py, timeout=5)
+ p = pexpect.spawn(self.interact_py, timeout=5, env=self.env)
p.expect('<in >')
p.sendcontrol(']') # chr(29), the default `escape_character'
# value of pexpect.interact().
@@ -61,7 +59,7 @@ class InteractTestCase (PexpectTestCase.PexpectTestCase):
def test_interact_spawn_eof(self):
" Ensure subprocess receives EOF and exit. "
- p = pexpect.spawn(self.interact_py, timeout=5)
+ p = pexpect.spawn(self.interact_py, timeout=5, env=self.env)
p.expect('<in >')
p.sendline(b'alpha')
p.sendline(b'beta')
@@ -76,7 +74,7 @@ class InteractTestCase (PexpectTestCase.PexpectTestCase):
def test_interact_spawnu_eof(self):
" Ensure subprocess receives unicode, EOF, and exit. "
- p = pexpect.spawnu(self.interact_ucs_py, timeout=5)
+ p = pexpect.spawnu(self.interact_ucs_py, timeout=5, env=self.env)
p.expect('<in >')
p.sendline('ɑlpha')
p.sendline('Βeta')