summaryrefslogtreecommitdiff
path: root/tests/test_interact.py
diff options
context:
space:
mode:
authorThomas Kluyver <takowl@gmail.com>2014-06-01 22:33:48 -0700
committerThomas Kluyver <takowl@gmail.com>2014-06-01 22:33:48 -0700
commit1def9a9f69c0e2c6105fd22f667bf8ff80e56ef6 (patch)
tree7286a6a822b10d5914b28505edfedb4165983e98 /tests/test_interact.py
parentf284c1344dc0183c8e03f8adf975adfa213b82c3 (diff)
downloadpexpect-git-1def9a9f69c0e2c6105fd22f667bf8ff80e56ef6.tar.gz
Allow subprocess tests to import pexpect
Diffstat (limited to 'tests/test_interact.py')
-rwxr-xr-xtests/test_interact.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/test_interact.py b/tests/test_interact.py
index 0c17580..39a1f76 100755
--- a/tests/test_interact.py
+++ b/tests/test_interact.py
@@ -22,14 +22,20 @@ PEXPECT LICENSE
from __future__ import print_function
from __future__ import unicode_literals
+import os
import pexpect
import unittest
from . import PexpectTestCase
class InteractTestCase (PexpectTestCase.PexpectTestCase):
+ def setUp(self):
+ super(InteractTestCase, self).setUp()
+ self.env = os.environ.copy()
+ # Ensure that Pexpect is importable by the subprocesses.
+ self.env['PYTHONPATH'] = self.project_dir + os.pathsep + os.environ.get('PYTHONPATH', '')
def test_interact (self):
- p = pexpect.spawn(str('%s interact.py' % (self.PYTHONBIN,)))
+ p = pexpect.spawn(str('%s interact.py' % (self.PYTHONBIN,)), env=self.env)
p.expect('<in >')
p.sendline (b'Hello')
p.sendline (b'there')
@@ -44,7 +50,7 @@ class InteractTestCase (PexpectTestCase.PexpectTestCase):
assert p.exitstatus == 0, (p.exitstatus, p.before)
def test_interact_unicode (self):
- p = pexpect.spawnu(str('%s interact_unicode.py' % (self.PYTHONBIN,)))
+ p = pexpect.spawnu(str('%s interact_unicode.py' % (self.PYTHONBIN,)), env=self.env)
try:
p.expect('<in >')
p.sendline ('Hello')