~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__static_tuple.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-18 14:09:19 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120118140919-rlvdrhpc0nq1lbwi
Change set/remove to require a lock for the branch config files.

This means that tests (or any plugin for that matter) do not requires an
explicit lock on the branch anymore to change a single option. This also
means the optimisation becomes "opt-in" and as such won't be as
spectacular as it may be and/or harder to get right (nothing fails
anymore).

This reduces the diff by ~300 lines.

Code/tests that were updating more than one config option is still taking
a lock to at least avoid some IOs and demonstrate the benefits through
the decreased number of hpss calls.

The duplication between BranchStack and BranchOnlyStack will be removed
once the same sharing is in place for local config files, at which point
the Stack class itself may be able to host the changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2009, 2010, 2011 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
17
17
"""Tests for the StaticTuple type."""
18
18
 
19
19
import cPickle
20
 
import gc
21
20
import sys
22
21
 
23
22
from bzrlib import (
24
23
    _static_tuple_py,
25
24
    debug,
26
 
    errors,
27
25
    osutils,
28
26
    static_tuple,
29
27
    tests,
30
28
    )
 
29
from bzrlib.tests import (
 
30
    features,
 
31
    )
31
32
 
32
33
 
33
34
def load_tests(standard_tests, module, loader):
39
40
    return suite
40
41
 
41
42
 
42
 
class _Meliae(tests.Feature):
43
 
 
44
 
    def _probe(self):
45
 
        try:
46
 
            from meliae import scanner
47
 
        except ImportError:
48
 
            return False
49
 
        return True
50
 
 
51
 
    def feature_name(self):
52
 
        return "Meliae - python memory debugger"
53
 
 
54
 
Meliae = _Meliae()
55
 
 
56
 
 
57
43
class TestStaticTuple(tests.TestCase):
58
44
 
59
45
    def assertRefcount(self, count, obj):
446
432
        # amount of referenced memory. Unfortunately gc.get_referents() first
447
433
        # checks the IS_GC flag before it traverses anything. We could write a
448
434
        # helper func, but that won't work for the generic implementation...
449
 
        self.requireFeature(Meliae)
 
435
        self.requireFeature(features.meliae)
450
436
        from meliae import scanner
451
437
        strs = ['foo', 'bar', 'baz', 'bing']
452
438
        k = self.module.StaticTuple(*strs)
457
443
        self.assertEqual(sorted(refs), sorted(scanner.get_referents(k)))
458
444
 
459
445
    def test_nested_referents(self):
460
 
        self.requireFeature(Meliae)
 
446
        self.requireFeature(features.meliae)
461
447
        from meliae import scanner
462
448
        strs = ['foo', 'bar', 'baz', 'bing']
463
449
        k1 = self.module.StaticTuple(*strs[:2])