~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-02 14:46:06 UTC
  • mfrom: (4396.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090602144606-fbbsgi540zlly0pv
(vila) Display prompt on stderr (not stdout)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1569
1569
        self.server.add_user('joe', 'foo')
1570
1570
        t = self.get_user_transport(None, None)
1571
1571
        stdout = tests.StringIOWrapper()
1572
 
        ui.ui_factory = tests.TestUIFactory(stdin='joe\nfoo\n', stdout=stdout)
 
1572
        stderr = tests.StringIOWrapper()
 
1573
        ui.ui_factory = tests.TestUIFactory(stdin='joe\nfoo\n',
 
1574
                                            stdout=stdout, stderr=stderr)
1573
1575
        self.assertEqual('contents of a\n',t.get('a').read())
1574
1576
        # stdin should be empty
1575
1577
        self.assertEqual('', ui.ui_factory.stdin.readline())
1576
 
        stdout.seek(0)
 
1578
        stderr.seek(0)
1577
1579
        expected_prompt = self._expected_username_prompt(t._unqualified_scheme)
1578
 
        self.assertEquals(expected_prompt, stdout.read(len(expected_prompt)))
 
1580
        self.assertEquals(expected_prompt, stderr.read(len(expected_prompt)))
 
1581
        self.assertEquals('', stdout.getvalue())
1579
1582
        self._check_password_prompt(t._unqualified_scheme, 'joe',
1580
 
                                    stdout.readline())
 
1583
                                    stderr.readline())
1581
1584
 
1582
1585
    def test_prompt_for_password(self):
1583
1586
        if self._testing_pycurl():
1588
1591
        self.server.add_user('joe', 'foo')
1589
1592
        t = self.get_user_transport('joe', None)
1590
1593
        stdout = tests.StringIOWrapper()
1591
 
        ui.ui_factory = tests.TestUIFactory(stdin='foo\n', stdout=stdout)
1592
 
        self.assertEqual('contents of a\n',t.get('a').read())
 
1594
        stderr = tests.StringIOWrapper()
 
1595
        ui.ui_factory = tests.TestUIFactory(stdin='foo\n',
 
1596
                                            stdout=stdout, stderr=stderr)
 
1597
        self.assertEqual('contents of a\n', t.get('a').read())
1593
1598
        # stdin should be empty
1594
1599
        self.assertEqual('', ui.ui_factory.stdin.readline())
1595
1600
        self._check_password_prompt(t._unqualified_scheme, 'joe',
1596
 
                                    stdout.getvalue())
 
1601
                                    stderr.getvalue())
 
1602
        self.assertEquals('', stdout.getvalue())
1597
1603
        # And we shouldn't prompt again for a different request
1598
1604
        # against the same transport.
1599
1605
        self.assertEqual('contents of b\n',t.get('b').read())