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

  • Committer: Vincent Ladeuil
  • Date: 2009-07-10 07:43:15 UTC
  • mto: (4529.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4530.
  • Revision ID: v.ladeuil+lp@free.fr-20090710074315-tfbke0r54hk2af6o
Fix TZ-dependent tests.

* bzrlib/tests/test_annotate.py:
(TestAnnotate.create_merged_trees,
TestAnnotate.create_deeply_merged_trees): Isolate from timezone.

* bzrlib/branchbuilder.py:
(BranchBuilder.build_snapshot): timezone is useful to build
TZ-independent tests .

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 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
28
28
    multiparent,
29
29
    osutils,
30
30
    pack,
31
 
    tests,
32
31
    )
33
32
from bzrlib.errors import (
34
33
    RevisionAlreadyPresent,
70
69
    )
71
70
 
72
71
 
73
 
compiled_knit_feature = tests.ModuleAvailableFeature(
74
 
                            'bzrlib._knit_load_data_pyx')
 
72
class _CompiledKnitFeature(Feature):
 
73
 
 
74
    def _probe(self):
 
75
        try:
 
76
            import bzrlib._knit_load_data_c
 
77
        except ImportError:
 
78
            return False
 
79
        return True
 
80
 
 
81
    def feature_name(self):
 
82
        return 'bzrlib._knit_load_data_c'
 
83
 
 
84
CompiledKnitFeature = _CompiledKnitFeature()
75
85
 
76
86
 
77
87
class KnitContentTestsMixin(object):
356
366
        :return: (versioned_file, reload_counter)
357
367
            versioned_file  a KnitVersionedFiles using the packs for access
358
368
        """
359
 
        builder = self.make_branch_builder('.', format="1.9")
 
369
        builder = self.make_branch_builder('.')
360
370
        builder.start_series()
361
371
        builder.build_snapshot('rev-1', None, [
362
372
            ('add', ('', 'root-id', 'directory', None)),
862
872
 
863
873
    def get_knit_index(self, transport, name, mode):
864
874
        mapper = ConstantMapper(name)
 
875
        orig = knit._load_data
 
876
        def reset():
 
877
            knit._load_data = orig
 
878
        self.addCleanup(reset)
865
879
        from bzrlib._knit_load_data_py import _load_data_py
866
 
        self.overrideAttr(knit, '_load_data', _load_data_py)
 
880
        knit._load_data = _load_data_py
867
881
        allow_writes = lambda: 'w' in mode
868
882
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
869
883
 
1294
1308
 
1295
1309
class LowLevelKnitIndexTests_c(LowLevelKnitIndexTests):
1296
1310
 
1297
 
    _test_needs_features = [compiled_knit_feature]
 
1311
    _test_needs_features = [CompiledKnitFeature]
1298
1312
 
1299
1313
    def get_knit_index(self, transport, name, mode):
1300
1314
        mapper = ConstantMapper(name)
1301
 
        from bzrlib._knit_load_data_pyx import _load_data_c
1302
 
        self.overrideAttr(knit, '_load_data', _load_data_c)
 
1315
        orig = knit._load_data
 
1316
        def reset():
 
1317
            knit._load_data = orig
 
1318
        self.addCleanup(reset)
 
1319
        from bzrlib._knit_load_data_c import _load_data_c
 
1320
        knit._load_data = _load_data_c
1303
1321
        allow_writes = lambda: mode == 'w'
1304
 
        return _KndxIndex(transport, mapper, lambda:None,
1305
 
                          allow_writes, lambda:True)
 
1322
        return _KndxIndex(transport, mapper, lambda:None, allow_writes, lambda:True)
1306
1323
 
1307
1324
 
1308
1325
class Test_KnitAnnotator(TestCaseWithMemoryTransport):
2213
2230
        # self.assertEqual([("annotate", key_basis)], basis.calls)
2214
2231
        self.assertEqual([('get_parent_map', set([key_basis])),
2215
2232
            ('get_parent_map', set([key_basis])),
2216
 
            ('get_record_stream', [key_basis], 'topological', True)],
 
2233
            ('get_record_stream', [key_basis], 'unordered', True)],
2217
2234
            basis.calls)
2218
2235
 
2219
2236
    def test_check(self):
2325
2342
        # ask which fallbacks have which parents.
2326
2343
        self.assertEqual([
2327
2344
            ("get_parent_map", set([key_basis, key_basis_2, key_missing])),
2328
 
            # topological is requested from the fallback, because that is what
2329
 
            # was requested at the top level.
2330
 
            ("get_record_stream", [key_basis_2, key_basis], 'topological', True)],
 
2345
            # unordered is asked for by the underlying worker as it still
 
2346
            # buffers everything while answering - which is a problem!
 
2347
            ("get_record_stream", [key_basis_2, key_basis], 'unordered', True)],
2331
2348
            calls)
2332
2349
 
2333
2350
    def test_get_record_stream_unordered_deltas(self):
2554
2571
        last_call = basis.calls[-1]
2555
2572
        self.assertEqual('get_record_stream', last_call[0])
2556
2573
        self.assertEqual(set([key_left, key_right]), set(last_call[1]))
2557
 
        self.assertEqual('topological', last_call[2])
 
2574
        self.assertEqual('unordered', last_call[2])
2558
2575
        self.assertEqual(True, last_call[3])
2559
2576
 
2560
2577