~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_workingtree/test_workingtree.py

  • Committer: Vincent Ladeuil
  • Date: 2011-08-12 14:47:42 UTC
  • mto: This revision was merged to the branch mainline in revision 6075.
  • Revision ID: v.ladeuil+lp@free.fr-20110812144742-g12l2cgakyulg935
Migrate bzr.workingtree.worth_saving_limit to stack-based config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
    branch,
25
25
    branchbuilder,
26
26
    bzrdir,
 
27
    config,
27
28
    errors,
28
29
    osutils,
29
30
    symbol_versioning,
30
31
    tests,
 
32
    trace,
31
33
    urlutils,
32
34
    )
33
35
from bzrlib.errors import (
1119
1121
 
1120
1122
class TestControlComponent(TestCaseWithWorkingTree):
1121
1123
    """WorkingTree implementations adequately implement ControlComponent."""
1122
 
    
 
1124
 
1123
1125
    def test_urls(self):
1124
1126
        wt = self.make_branch_and_tree('wt')
1125
1127
        self.assertIsInstance(wt.user_url, str)
1150
1152
 
1151
1153
    def test_set_in_branch(self):
1152
1154
        wt = self.make_wt_with_worth_saving_limit()
1153
 
        config = wt.branch.get_config()
1154
 
        config.set_user_option('bzr.workingtree.worth_saving_limit', '20')
 
1155
        conf = config.BranchStack(wt.branch)
 
1156
        conf.set('bzr.workingtree.worth_saving_limit', '20')
1155
1157
        self.assertEqual(20, wt._worth_saving_limit())
1156
1158
        ds = wt.current_dirstate()
1157
1159
        self.assertEqual(10, ds._worth_saving_limit)
1158
1160
 
1159
1161
    def test_invalid(self):
1160
1162
        wt = self.make_wt_with_worth_saving_limit()
1161
 
        config = wt.branch.get_config()
1162
 
        config.set_user_option('bzr.workingtree.worth_saving_limit', 'a')
 
1163
        conf = config.BranchStack(wt.branch)
 
1164
        conf.set('bzr.workingtree.worth_saving_limit', 'a')
1163
1165
        # If the config entry is invalid, default to 10
1164
 
        # TODO: This writes a warning to the user, trap it somehow
 
1166
        warnings = []
 
1167
        def warning(*args):
 
1168
            warnings.append(args[0] % args[1:])
 
1169
        self.overrideAttr(trace, 'warning', warning)
1165
1170
        self.assertEqual(10, wt._worth_saving_limit())
 
1171
        self.assertLength(1, warnings)
 
1172
        self.assertEquals('Value "a" is not valid for'
 
1173
                          ' "bzr.workingtree.worth_saving_limit"',
 
1174
                          warnings[0])
1166
1175
 
1167
1176
 
1168
1177
class TestFormatAttributes(TestCaseWithWorkingTree):