~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.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:
1461
1461
    """Test AuthenticationConfig behaviour"""
1462
1462
 
1463
1463
    def _check_default_password_prompt(self, expected_prompt_format, scheme,
1464
 
                              host=None, port=None, realm=None, path=None):
 
1464
                                       host=None, port=None, realm=None,
 
1465
                                       path=None):
1465
1466
        if host is None:
1466
1467
            host = 'bar.org'
1467
1468
        user, password = 'jim', 'precious'
1470
1471
            'user': user, 'realm': realm}
1471
1472
 
1472
1473
        stdout = tests.StringIOWrapper()
 
1474
        stderr = tests.StringIOWrapper()
1473
1475
        ui.ui_factory = tests.TestUIFactory(stdin=password + '\n',
1474
 
                                            stdout=stdout)
 
1476
                                            stdout=stdout, stderr=stderr)
1475
1477
        # We use an empty conf so that the user is always prompted
1476
1478
        conf = config.AuthenticationConfig()
1477
1479
        self.assertEquals(password,
1478
1480
                          conf.get_password(scheme, host, user, port=port,
1479
1481
                                            realm=realm, path=path))
1480
 
        self.assertEquals(stdout.getvalue(), expected_prompt)
 
1482
        self.assertEquals(expected_prompt, stderr.getvalue())
 
1483
        self.assertEquals('', stdout.getvalue())
1481
1484
 
1482
1485
    def _check_default_username_prompt(self, expected_prompt_format, scheme,
1483
 
                              host=None, port=None, realm=None, path=None):
 
1486
                                       host=None, port=None, realm=None,
 
1487
                                       path=None):
1484
1488
        if host is None:
1485
1489
            host = 'bar.org'
1486
1490
        username = 'jim'
1488
1492
            'scheme': scheme, 'host': host, 'port': port,
1489
1493
            'realm': realm}
1490
1494
        stdout = tests.StringIOWrapper()
 
1495
        stderr = tests.StringIOWrapper()
1491
1496
        ui.ui_factory = tests.TestUIFactory(stdin=username+ '\n',
1492
 
                                            stdout=stdout)
 
1497
                                            stdout=stdout, stderr=stderr)
1493
1498
        # We use an empty conf so that the user is always prompted
1494
1499
        conf = config.AuthenticationConfig()
1495
1500
        self.assertEquals(username, conf.get_user(scheme, host, port=port,
1496
1501
                          realm=realm, path=path, ask=True))
1497
 
        self.assertEquals(stdout.getvalue(), expected_prompt)
 
1502
        self.assertEquals(expected_prompt, stderr.getvalue())
 
1503
        self.assertEquals('', stdout.getvalue())
1498
1504
 
1499
1505
    def test_username_defaults_prompts(self):
1500
1506
        # HTTP prompts can't be tested here, see test_http.py