/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_debug.py

  • Committer: Martin Pool
  • Date: 2009-03-06 04:59:54 UTC
  • mto: This revision was merged to the branch mainline in revision 4086.
  • Revision ID: mbp@sourcefrog.net-20090306045954-yboelzz4hs9os28s
Apparent configobject automatically splits comma-separated lists

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Tests for bzrlib.debug"""
18
18
 
21
21
 
22
22
 
23
23
from bzrlib import debug
24
 
from bzrlib.config import config_filename, ensure_config_dir_exists
25
24
from bzrlib.transport import get_transport
26
25
from bzrlib.tests import TestCaseInTempDir
27
26
 
29
28
class TestDebugFlags(TestCaseInTempDir):
30
29
 
31
30
    def test_set_debug_flags_from_config(self):
 
31
        # TestCase already makes a dummy HOME so we don't have to
 
32
        t = get_transport(os.environ['HOME'])
 
33
 
 
34
        # guard against being run from the wrong directory
 
35
        self.assertFalse(t.has(".bazaar"))
 
36
 
 
37
        t.mkdir(".bazaar")
 
38
 
32
39
        # test both combinations because configobject automatically splits up
33
40
        # comma-separated lists
34
 
        if os.path.isfile(config_filename()):
35
 
            # Something is wrong in environment,
36
 
            # we risk overwriting users config
37
 
            self.assert_(config_filename() + "exists, abort")
38
 
 
39
41
        self.try_debug_flags(
40
42
            """debug_flags = hpss, error\n""",
41
43
            set(['hpss', 'error']))
44
46
            """debug_flags = hpss\n""",
45
47
            set(['hpss']))
46
48
 
47
 
    def try_debug_flags(self, conf_bytes, expected_flags):
48
 
        ensure_config_dir_exists()
49
 
        f = open(config_filename(), 'wb')
50
 
        try:
51
 
            f.write(conf_bytes)
52
 
        finally:
53
 
            f.close()
 
49
    def try_debug_flags(self, conf_file, expected_flags):
 
50
        t = get_transport(os.environ['HOME'])
 
51
        t.put_bytes(".bazaar/bazaar.conf", conf_file)
54
52
        saved_debug = set(debug.debug_flags)
55
 
        debug.debug_flags.clear()
56
53
        try:
57
54
            debug.set_debug_flags_from_config()
58
55
            self.assertEqual(expected_flags,