~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Martin Pool
  • Date: 2010-01-29 14:09:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4992.
  • Revision ID: mbp@sourcefrog.net-20100129140905-2uiarb6p8di1ywsr
Correction to url

from review: https://code.edge.launchpad.net/~mbp/bzr/doc/+merge/18250

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
35
35
    trace,
36
36
    transport,
37
37
    )
38
 
from bzrlib.tests import features
39
38
from bzrlib.util.configobj import configobj
40
39
 
41
40
 
368
367
            '/home/bogus/.cache')
369
368
 
370
369
 
371
 
class TestIniConfig(tests.TestCaseInTempDir):
 
370
class TestIniConfig(tests.TestCase):
372
371
 
373
372
    def make_config_parser(self, s):
374
373
        conf = config.IniBasedConfig(None)
394
393
        parser = my_config._get_parser(file=config_file)
395
394
        self.failUnless(my_config._get_parser() is parser)
396
395
 
397
 
    def _dummy_chown(self, path, uid, gid):
398
 
        self.path, self.uid, self.gid = path, uid, gid
399
 
 
400
 
    def test_ini_config_ownership(self):
401
 
        """Ensure that chown is happening during _write_config_file.
402
 
        """
403
 
        self.requireFeature(features.chown_feature)
404
 
        self.overrideAttr(os, 'chown', self._dummy_chown)
405
 
        self.path = self.uid = self.gid = None
406
 
        def get_filename():
407
 
            return 'foo.conf'
408
 
        conf = config.IniBasedConfig(get_filename)
409
 
        conf._write_config_file()
410
 
        self.assertEquals(self.path, 'foo.conf')
411
 
        self.assertTrue(isinstance(self.uid, int))
412
 
        self.assertTrue(isinstance(self.gid, int))
413
396
 
414
397
class TestGetUserOptionAs(TestIniConfig):
415
398
 
423
406
        get_bool = conf.get_user_option_as_bool
424
407
        self.assertEqual(True, get_bool('a_true_bool'))
425
408
        self.assertEqual(False, get_bool('a_false_bool'))
426
 
        warnings = []
427
 
        def warning(*args):
428
 
            warnings.append(args[0] % args[1:])
429
 
        self.overrideAttr(trace, 'warning', warning)
430
 
        msg = 'Value "%s" is not a boolean for "%s"'
431
409
        self.assertIs(None, get_bool('an_invalid_bool'))
432
 
        self.assertEquals(msg % ('maybe', 'an_invalid_bool'), warnings[0])
433
 
        warnings = []
434
410
        self.assertIs(None, get_bool('not_defined_in_this_config'))
435
 
        self.assertEquals([], warnings)
 
411
 
436
412
 
437
413
    def test_get_user_option_as_list(self):
438
414
        conf, parser = self.make_config_parser("""