~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-29 21:35:05 UTC
  • mfrom: (4576 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4577.
  • Revision ID: john@arbash-meinel.com-20090729213505-tkqsvy1zfpocu75w
Merge bzr.dev 4576 in prep for NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
2
 
#   Authors: Robert Collins <robert.collins@canonical.com>
 
1
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
3
2
#
4
3
# This program is free software; you can redistribute it and/or modify
5
4
# it under the terms of the GNU General Public License as published by
18
17
"""Tests for finding and reading the bzr config file[s]."""
19
18
# import system imports here
20
19
from cStringIO import StringIO
21
 
import getpass
22
20
import os
23
21
import sys
24
22
 
368
366
        parser = my_config._get_parser(file=config_file)
369
367
        self.failUnless(my_config._get_parser() is parser)
370
368
 
 
369
    def test_get_user_option_as_bool(self):
 
370
        config_file = StringIO("""
 
371
a_true_bool = true
 
372
a_false_bool = 0
 
373
an_invalid_bool = maybe
 
374
a_list = hmm, who knows ? # This interpreted as a list !
 
375
""".encode('utf-8'))
 
376
        my_config = config.IniBasedConfig(None)
 
377
        parser = my_config._get_parser(file=config_file)
 
378
        get_option = my_config.get_user_option_as_bool
 
379
        self.assertEqual(True, get_option('a_true_bool'))
 
380
        self.assertEqual(False, get_option('a_false_bool'))
 
381
        self.assertIs(None, get_option('an_invalid_bool'))
 
382
        self.assertIs(None, get_option('not_defined_in_this_config'))
371
383
 
372
384
class TestGetConfig(tests.TestCase):
373
385
 
1548
1560
"""))
1549
1561
        entered_password = 'typed-by-hand'
1550
1562
        stdout = tests.StringIOWrapper()
 
1563
        stderr = tests.StringIOWrapper()
1551
1564
        ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
1552
 
                                            stdout=stdout)
 
1565
                                            stdout=stdout, stderr=stderr)
1553
1566
 
1554
1567
        # Since the password defined in the authentication config is ignored,
1555
1568
        # the user is prompted
1569
1582
"""))
1570
1583
        entered_password = 'typed-by-hand'
1571
1584
        stdout = tests.StringIOWrapper()
 
1585
        stderr = tests.StringIOWrapper()
1572
1586
        ui.ui_factory = tests.TestUIFactory(stdin=entered_password + '\n',
1573
 
                                            stdout=stdout)
 
1587
                                            stdout=stdout,
 
1588
                                            stderr=stderr)
1574
1589
 
1575
1590
        # Since the password defined in the authentication config is ignored,
1576
1591
        # the user is prompted