/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 breezy/tests/test__static_tuple.py

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

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
 
from bzrlib import (
 
22
from breezy import (
24
23
    _static_tuple_py,
25
24
    debug,
26
 
    errors,
27
25
    osutils,
28
26
    static_tuple,
29
27
    tests,
30
28
    )
31
 
 
32
 
 
33
 
def load_tests(standard_tests, module, loader):
 
29
from breezy.tests import (
 
30
    features,
 
31
    )
 
32
 
 
33
 
 
34
def load_tests(loader, standard_tests, pattern):
34
35
    """Parameterize tests for all versions of groupcompress."""
35
36
    global compiled_static_tuple_feature
36
37
    suite, compiled_static_tuple_feature = tests.permute_tests_for_extension(
37
 
        standard_tests, loader, 'bzrlib._static_tuple_py',
38
 
        'bzrlib._static_tuple_c')
 
38
        standard_tests, loader, 'breezy._static_tuple_py',
 
39
        'breezy._static_tuple_c')
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):
227
213
        self.assertRaises(TypeError, self.module.StaticTuple, subint(2))
228
214
 
229
215
    def test_holds_long(self):
230
 
        k1 = self.module.StaticTuple(2L**65)
 
216
        k1 = self.module.StaticTuple(2**65)
231
217
        class sublong(long):
232
218
            pass
233
219
        # But not a subclass
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])
614
600
 
615
601
    def test_static_tuple_thunk(self):
616
602
        # Make sure the right implementation is available from
617
 
        # bzrlib.static_tuple.StaticTuple.
 
603
        # breezy.static_tuple.StaticTuple.
618
604
        if self.module is _static_tuple_py:
619
605
            if compiled_static_tuple_feature.available():
620
606
                # We will be using the C version