~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Vincent Ladeuil
  • Date: 2009-05-15 10:14:51 UTC
  • mto: (4396.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4397.
  • Revision ID: v.ladeuil+lp@free.fr-20090515101451-bffnsywhvaskrz1h
Use stderr for UI prompt to address bug #376582.

* bzrlib/ui/__init__.py:
(CLIUIFactory.prompt): Display prompt on stderr.

* bzrlib/tests/test_ui.py: (UITests.test_text_factory_ascii_password,
UITests.test_text_factory_utf8_password,
UITests.assert_get_bool_acceptance_of_user_input,
UITests.test_text_factory_prompt,
UITests.test_silent_ui_getusername,
UITests.test_text_ui_getusername,
UITests.test_text_ui_getusername_utf8):prompt is now displayed on
stderr.

* bzrlib/tests/test_http.py:
(TestAuth.test_prompt_for_username,
TestAuth.test_prompt_for_password): prompt is now displayed on
stderr.

* bzrlib/tests/test_config.py:
(TestAuthenticationConfig._check_default_password_prompt,
TestAuthenticationConfig._check_default_username_prompt): prompt
is now displayed on stderr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1544
1544
        self.server.add_user('joe', 'foo')
1545
1545
        t = self.get_user_transport(None, None)
1546
1546
        stdout = tests.StringIOWrapper()
1547
 
        ui.ui_factory = tests.TestUIFactory(stdin='joe\nfoo\n', stdout=stdout)
 
1547
        stderr = tests.StringIOWrapper()
 
1548
        ui.ui_factory = tests.TestUIFactory(stdin='joe\nfoo\n',
 
1549
                                            stdout=stdout, stderr=stderr)
1548
1550
        self.assertEqual('contents of a\n',t.get('a').read())
1549
1551
        # stdin should be empty
1550
1552
        self.assertEqual('', ui.ui_factory.stdin.readline())
1551
 
        stdout.seek(0)
 
1553
        stderr.seek(0)
1552
1554
        expected_prompt = self._expected_username_prompt(t._unqualified_scheme)
1553
 
        self.assertEquals(expected_prompt, stdout.read(len(expected_prompt)))
 
1555
        self.assertEquals(expected_prompt, stderr.read(len(expected_prompt)))
 
1556
        self.assertEquals('', stdout.getvalue())
1554
1557
        self._check_password_prompt(t._unqualified_scheme, 'joe',
1555
 
                                    stdout.readline())
 
1558
                                    stderr.readline())
1556
1559
 
1557
1560
    def test_prompt_for_password(self):
1558
1561
        if self._testing_pycurl():
1563
1566
        self.server.add_user('joe', 'foo')
1564
1567
        t = self.get_user_transport('joe', None)
1565
1568
        stdout = tests.StringIOWrapper()
1566
 
        ui.ui_factory = tests.TestUIFactory(stdin='foo\n', stdout=stdout)
1567
 
        self.assertEqual('contents of a\n',t.get('a').read())
 
1569
        stderr = tests.StringIOWrapper()
 
1570
        ui.ui_factory = tests.TestUIFactory(stdin='foo\n',
 
1571
                                            stdout=stdout, stderr=stderr)
 
1572
        self.assertEqual('contents of a\n', t.get('a').read())
1568
1573
        # stdin should be empty
1569
1574
        self.assertEqual('', ui.ui_factory.stdin.readline())
1570
1575
        self._check_password_prompt(t._unqualified_scheme, 'joe',
1571
 
                                    stdout.getvalue())
 
1576
                                    stderr.getvalue())
 
1577
        self.assertEquals('', stdout.getvalue())
1572
1578
        # And we shouldn't prompt again for a different request
1573
1579
        # against the same transport.
1574
1580
        self.assertEqual('contents of b\n',t.get('b').read())