~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Benoît Pierre
  • Date: 2011-10-08 16:16:13 UTC
  • mto: This revision was merged to the branch mainline in revision 6215.
  • Revision ID: benoit.pierre@gmail.com-20111008161613-shns4ytr6c80x0m0
More TextUIFactory.choose tests: check prompts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
        # duplicated shortcut
148
148
        self.assertRaises(ValueError, factory.choose, u"", u"&choice1\nchoi&ce2")
149
149
 
 
150
    def test_text_ui_choose_prompt(self):
 
151
        stdin = tests.StringIOWrapper()
 
152
        stdout = tests.StringIOWrapper()
 
153
        stderr = tests.StringIOWrapper()
 
154
        factory = _mod_ui_text.TextUIFactory(stdin, stdout, stderr)
 
155
        # choices with explicit shortcuts
 
156
        factory.choose(u"prompt", u"&yes\n&No\nmore &info")
 
157
        self.assertEqual("prompt ([y]es, [N]o, more [i]nfo): \n", factory.stderr.getvalue())
 
158
        # automatic shortcuts
 
159
        factory.stderr.truncate(0)
 
160
        factory.choose(u"prompt", u"yes\nNo\nmore info")
 
161
        self.assertEqual("prompt ([y]es, [N]o, [m]ore info): \n", factory.stderr.getvalue())
 
162
 
150
163
    def test_text_ui_choose_return_values(self):
151
164
        choose = lambda: factory.choose(u"", u"&Yes\n&No\nMaybe\nmore &info", 3)
152
165
        stdin = tests.StringIOWrapper("y\n" # 0