~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Martin Pool
  • Date: 2008-12-16 07:56:29 UTC
  • mto: (3882.7.11 progress)
  • mto: This revision was merged to the branch mainline in revision 3940.
  • Revision ID: mbp@sourcefrog.net-20081216075629-zhgjzxgoh32453tu
Choose the UIFactory class depending on the terminal capabilities

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    def test_progress_note(self):
102
102
        stderr = StringIO()
103
103
        stdout = StringIO()
104
 
        ui_factory = TextUIFactory(stderr=stderr,
105
 
                stdout=stdout)
 
104
        ui_factory = TextUIFactory(stdin=StringIO(''),
 
105
            stderr=stderr,
 
106
            stdout=stdout)
106
107
        pb = ui_factory.nested_progress_bar()
107
108
        try:
108
109
            result = pb.note('t')
122
123
        # defaults to creating a Dots progress bar. we
123
124
        # need to force it to believe we are a TTY
124
125
        ui_factory = TextUIFactory(
 
126
            stdin=StringIO(''),
125
127
            stdout=stdout, stderr=stderr)
126
128
        pb = ui_factory.nested_progress_bar()
127
129
        try:
139
141
 
140
142
    def test_progress_nested(self):
141
143
        # test factory based nested and popping.
142
 
        ui = TextUIFactory()
 
144
        ui = TextUIFactory(None, None, None)
143
145
        pb1 = ui.nested_progress_bar()
144
146
        pb2 = ui.nested_progress_bar()
145
147
        self.assertRaises(AssertionError, pb1.finished)
168
170
        pb2.finished()
169
171
        pb1.finished()
170
172
 
171
 
    def test_cli_stdin_is_default_stdin(self):
172
 
        factory = CLIUIFactory()
173
 
        self.assertEqual(sys.stdin, factory.stdin)
174
 
 
175
173
    def assert_get_bool_acceptance_of_user_input(self, factory):
176
174
        factory.stdin = StringIO("y\nyes with garbage\n"
177
175
                                 "yes\nn\nnot an answer\n"
202
200
        self.assertEqual('', factory.stdin.readline())
203
201
 
204
202
    def test_text_ui_getbool(self):
205
 
        factory = TextUIFactory()
 
203
        factory = TextUIFactory(None, None, None)
206
204
        self.assert_get_bool_acceptance_of_user_input(factory)
207
205
 
208
206
    def test_text_factory_prompts_and_clears(self):
209
207
        # a get_boolean call should clear the pb before prompting
210
208
        out = _TTYStringIO()
211
 
        factory = TextUIFactory(stdout=out, stderr=out)
212
 
        factory.stdin = StringIO("yada\ny\n")
 
209
        factory = TextUIFactory(stdin=StringIO("yada\ny\n"), stdout=out, stderr=out)
213
210
        pb = factory.nested_progress_bar()
214
211
        pb.show_bar = False
215
212
        pb.show_spinner = False