summaryrefslogtreecommitdiff
path: root/distutils2/tests/test_create.py
diff options
context:
space:
mode:
Diffstat (limited to 'distutils2/tests/test_create.py')
-rw-r--r--distutils2/tests/test_create.py30
1 files changed, 10 insertions, 20 deletions
diff --git a/distutils2/tests/test_create.py b/distutils2/tests/test_create.py
index b0b488f..039dcbb 100644
--- a/distutils2/tests/test_create.py
+++ b/distutils2/tests/test_create.py
@@ -5,14 +5,17 @@ import sys
import codecs
from StringIO import StringIO
from textwrap import dedent
+from distutils2 import create
from distutils2.create import MainProgram, ask_yn, ask, main
from distutils2._backport import sysconfig
from distutils2.tests import support, unittest
+from distutils2.tests.support import Inputs
class CreateTestCase(support.TempdirManager,
support.EnvironRestorer,
+ support.LoggingCatcher,
unittest.TestCase):
maxDiff = None
@@ -20,11 +23,6 @@ class CreateTestCase(support.TempdirManager,
def setUp(self):
super(CreateTestCase, self).setUp()
- self._stdin = sys.stdin # TODO use Inputs
- self._stdout = sys.stdout
- sys.stdin = StringIO()
- sys.stdout = StringIO()
- self._cwd = os.getcwd()
self.wdir = self.mkdtemp()
os.chdir(self.wdir)
# patch sysconfig
@@ -34,29 +32,24 @@ class CreateTestCase(support.TempdirManager,
'doc': sys.prefix + '/share/doc/pyxfoil', }
def tearDown(self):
- sys.stdin = self._stdin
- sys.stdout = self._stdout
- os.chdir(self._cwd)
sysconfig.get_paths = self._old_get_paths
+ if hasattr(create, 'raw_input'):
+ del create.raw_input
super(CreateTestCase, self).tearDown()
def test_ask_yn(self):
- sys.stdin.write('y\n')
- sys.stdin.seek(0)
+ create.raw_input = Inputs('y')
self.assertEqual('y', ask_yn('is this a test'))
def test_ask(self):
- sys.stdin.write('a\n')
- sys.stdin.write('b\n')
- sys.stdin.seek(0)
+ create.raw_input = Inputs('a', 'b')
self.assertEqual('a', ask('is this a test'))
self.assertEqual('b', ask(str(list(range(0, 70))), default='c',
lengthy=True))
def test_set_multi(self):
mainprogram = MainProgram()
- sys.stdin.write('aaaaa\n')
- sys.stdin.seek(0)
+ create.raw_input = Inputs('aaaaa')
mainprogram.data['author'] = []
mainprogram._set_multi('_set_multi test', 'author')
self.assertEqual(['aaaaa'], mainprogram.data['author'])
@@ -132,8 +125,7 @@ class CreateTestCase(support.TempdirManager,
scripts=['my_script', 'bin/run'],
)
"""), encoding='utf-8')
- sys.stdin.write(u'y\n')
- sys.stdin.seek(0)
+ create.raw_input = Inputs('y')
main()
path = os.path.join(self.wdir, 'setup.cfg')
@@ -214,9 +206,7 @@ My super Death-scription
barbar is now in the public domain,
ho, baby!
'''))
- sys.stdin.write('y\n')
- sys.stdin.seek(0)
- # FIXME Out of memory error.
+ create.raw_input = Inputs('y')
main()
path = os.path.join(self.wdir, 'setup.cfg')