Rev 5355: Cleanup and simplify bt.test_debug. in file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Jul 21 17:44:01 BST 2010
At file:///home/vila/src/bzr/bugs/525571-lock-bazaar-conf-files/
------------------------------------------------------------
revno: 5355
revision-id: v.ladeuil+lp at free.fr-20100721164401-m6v9p8b2sdebr7yj
parent: v.ladeuil+lp at free.fr-20100721163514-e491wd00fdgbp8sp
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: further-cleanups
timestamp: Wed 2010-07-21 18:44:01 +0200
message:
Cleanup and simplify bt.test_debug.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_debug.py'
--- a/bzrlib/tests/test_debug.py 2010-06-20 11:18:38 +0000
+++ b/bzrlib/tests/test_debug.py 2010-07-21 16:44:01 +0000
@@ -17,14 +17,11 @@
"""Tests for bzrlib.debug"""
-import os
-
-
from bzrlib import (
+ config,
debug,
tests,
)
-from bzrlib.config import config_filename, ensure_config_dir_exists
class TestDebugFlags(tests.TestCaseInTempDir):
@@ -32,33 +29,12 @@
def test_set_debug_flags_from_config(self):
# test both combinations because configobject automatically splits up
# comma-separated lists
- if os.path.isfile(config_filename()):
- # Something is wrong in environment,
- # we risk overwriting users config
- self.assert_(config_filename() + "exists, abort")
-
- self.try_debug_flags(
- """debug_flags = hpss, error\n""",
- set(['hpss', 'error']))
-
- self.try_debug_flags(
- """debug_flags = hpss\n""",
- set(['hpss']))
-
- def try_debug_flags(self, conf_bytes, expected_flags):
- ensure_config_dir_exists()
- f = open(config_filename(), 'wb')
- try:
- f.write(conf_bytes)
- finally:
- f.close()
- saved_debug = set(debug.debug_flags)
- debug.debug_flags.clear()
- try:
- debug.set_debug_flags_from_config()
- self.assertEqual(expected_flags,
- debug.debug_flags)
- finally:
- # restore without rebinding the variable
- debug.debug_flags.clear()
- debug.debug_flags.update(saved_debug)
+ self.try_debug_flags(['hpss', 'error'], 'debug_flags = hpss, error\n')
+ self.try_debug_flags(['hpss'], 'debug_flags = hpss\n')
+
+ def try_debug_flags(self, expected_flags, conf_bytes):
+ conf = config.GlobalConfig(_content=conf_bytes)
+ conf._write_config_file()
+ self.overrideAttr(debug, 'debug_flags', set())
+ debug.set_debug_flags_from_config()
+ self.assertEqual(set(expected_flags), debug.debug_flags)
More information about the bazaar-commits
mailing list