/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__static_tuple.py

  • Committer: Vincent Ladeuil
  • Date: 2012-01-05 14:26:58 UTC
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120105142658-vek3v6pzlxb751s2
Tests passing for a first rough version of a cached branch config store. The changes here are too invasive and several parallel proposals have been made. 

@only_raises is evil and gave a hard time since any exception during
save_changes() was swallowed.

Possible improvements: 

- add some needs_write_lock decorators to crucial
  methods (_set_config_location ?) but keep locking the branch at higher levels

- decorate branch.unlock to call stack.save if last_lock() it True
  outside of @only_raises scope (evil decorator)

- add @needs_write_lock to stack.set and stack.remove (will probably get
  rid of most testing issues) we probably need a specialized decorator
  that can relay to the store and from there to the branch or whatever is
  needed. This will also helps bzr config to get it right. The
  get_mutable_section trick should not be needed anymore either.

- decorate branch.unlock to call stack.save if last_lock() it True outside
  of @only_raises scope (evil decorator)

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])