103
def test_progress_note(self):
104
stderr = tests.StringIOWrapper()
105
stdout = tests.StringIOWrapper()
106
ui_factory = _mod_ui_text.TextUIFactory(stdin=tests.StringIOWrapper(''),
109
pb = ui_factory.nested_progress_bar()
111
result = self.applyDeprecated(deprecated_in((2, 1, 0)),
114
self.assertEqual(None, result)
115
self.assertEqual("t\n", stdout.getvalue())
116
# Since there was no update() call, there should be no clear() call
117
self.failIf(re.search(r'^\r {10,}\r$',
118
stderr.getvalue()) is not None,
119
'We cleared the stderr without anything to put there')
123
def test_progress_note_clears(self):
124
stderr = test_progress._TTYStringIO()
125
stdout = test_progress._TTYStringIO()
126
# so that we get a TextProgressBar
127
os.environ['TERM'] = 'xterm'
128
ui_factory = _mod_ui_text.TextUIFactory(
129
stdin=tests.StringIOWrapper(''),
130
stdout=stdout, stderr=stderr)
131
self.assertIsInstance(ui_factory._progress_view,
132
_mod_ui_text.TextProgressView)
133
pb = ui_factory.nested_progress_bar()
135
# Create a progress update that isn't throttled
137
result = self.applyDeprecated(deprecated_in((2, 1, 0)),
139
self.assertEqual(None, result)
140
self.assertEqual("t\n", stdout.getvalue())
141
# the exact contents will depend on the terminal width and we don't
142
# care about that right now - but you're probably running it on at
143
# least a 10-character wide terminal :)
144
self.assertContainsRe(stderr.getvalue(), r'\r {10,}\r$')
103
148
def test_text_ui_get_boolean(self):
104
149
stdin = tests.StringIOWrapper("y\n" # True
160
204
factory.get_boolean,
161
205
"what do you want"))
162
206
output = out.getvalue()
163
self.assertContainsRe(output,
165
self.assertContainsRe(output,
207
self.assertContainsRe(factory.stdout.getvalue(),
209
self.assertContainsRe(factory.stdout.getvalue(),
166
210
r"what do you want\? \[y/n\]: what do you want\? \[y/n\]: ")
167
211
# stdin should have been totally consumed
168
212
self.assertEqual('', factory.stdin.readline())