From 1def9a9f69c0e2c6105fd22f667bf8ff80e56ef6 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Sun, 1 Jun 2014 22:33:48 -0700 Subject: Allow subprocess tests to import pexpect --- tests/test_interact.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests/test_interact.py') 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('') 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('') p.sendline ('Hello') -- cgit v1.2.1