~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__dirstate_helpers.py

  • Committer: Vincent Ladeuil
  • Date: 2009-06-22 12:52:39 UTC
  • mto: (4471.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4472.
  • Revision ID: v.ladeuil+lp@free.fr-20090622125239-kabo9smxt9c3vnir
Use a consistent scheme for naming pyrex source files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
    )
33
33
 
34
34
try:
35
 
    from bzrlib import _dirstate_helpers_c
36
 
    has_dirstate_helpers_c = True
 
35
    from bzrlib import _dirstate_helpers_pyx
 
36
    has_dirstate_helpers_pyx = True
37
37
except ImportError:
38
 
    has_dirstate_helpers_c = False
 
38
    has_dirstate_helpers_pyx = False
39
39
 
40
40
 
41
41
class _CompiledDirstateHelpersFeature(tests.Feature):
42
42
    def _probe(self):
43
 
        return has_dirstate_helpers_c
 
43
        return has_dirstate_helpers_pyx
44
44
 
45
45
    def feature_name(self):
46
 
        return 'bzrlib._dirstate_helpers_c'
 
46
        return 'bzrlib._dirstate_helpers_pyx'
47
47
CompiledDirstateHelpersFeature = _CompiledDirstateHelpersFeature()
48
48
 
49
49
 
56
56
 
57
57
    ue_scenarios = [('dirstate_Python',
58
58
                     {'update_entry': dirstate.py_update_entry})]
59
 
    if has_dirstate_helpers_c:
60
 
        c_scenario = ('dirstate_C',
61
 
                     {'update_entry': _dirstate_helpers_c.update_entry})
62
 
        ue_scenarios.append(c_scenario)
 
59
    if has_dirstate_helpers_pyx:
 
60
        pyrex_scenario = ('dirstate_Pyrex',
 
61
                          {'update_entry': _dirstate_helpers_pyx.update_entry})
 
62
        ue_scenarios.append(pyrex_scenario)
63
63
    process_entry_tests, remaining_tests = tests.split_suite_by_condition(
64
64
        remaining_tests, tests.condition_isinstance(TestUpdateEntry))
65
65
    tests.multiply_tests(process_entry_tests,
69
69
 
70
70
    pe_scenarios = [('dirstate_Python',
71
71
                     {'_process_entry': dirstate.ProcessEntryPython})]
72
 
    if has_dirstate_helpers_c:
73
 
        c_scenario = ('dirstate_C',
74
 
                     {'_process_entry': _dirstate_helpers_c.ProcessEntryC})
75
 
        pe_scenarios.append(c_scenario)
 
72
    if has_dirstate_helpers_pyx:
 
73
        pyrex_scenario = (
 
74
            'dirstate_Pyrex',
 
75
            {'_process_entry': _dirstate_helpers_pyx.ProcessEntryC})
 
76
        pe_scenarios.append(pyrex_scenario)
76
77
    process_entry_tests, remaining_tests = tests.split_suite_by_condition(
77
78
        remaining_tests, tests.condition_isinstance(TestProcessEntry))
78
79
    tests.multiply_tests(process_entry_tests,
261
262
    _test_needs_features = [CompiledDirstateHelpersFeature]
262
263
 
263
264
    def get_bisect_path(self):
264
 
        from bzrlib._dirstate_helpers_c import _bisect_path_left_c
 
265
        from bzrlib._dirstate_helpers_pyx import _bisect_path_left_c
265
266
        return _bisect_path_left_c
266
267
 
267
268
 
282
283
    _test_needs_features = [CompiledDirstateHelpersFeature]
283
284
 
284
285
    def get_bisect_path(self):
285
 
        from bzrlib._dirstate_helpers_c import _bisect_path_right_c
 
286
        from bzrlib._dirstate_helpers_pyx import _bisect_path_right_c
286
287
        return _bisect_path_right_c
287
288
 
288
289
 
394
395
    _test_needs_features = [CompiledDirstateHelpersFeature]
395
396
 
396
397
    def get_bisect_dirblock(self):
397
 
        from bzrlib._dirstate_helpers_c import bisect_dirblock_c
 
398
        from bzrlib._dirstate_helpers_pyx import bisect_dirblock_c
398
399
        return bisect_dirblock_c
399
400
 
400
401
 
516
517
    _test_needs_features = [CompiledDirstateHelpersFeature]
517
518
 
518
519
    def get_cmp_by_dirs(self):
519
 
        from bzrlib._dirstate_helpers_c import cmp_by_dirs_c
 
520
        from bzrlib._dirstate_helpers_pyx import cmp_by_dirs_c
520
521
        return cmp_by_dirs_c
521
522
 
522
523
 
667
668
    _test_needs_features = [CompiledDirstateHelpersFeature]
668
669
 
669
670
    def get_cmp_by_dirs(self):
670
 
        from bzrlib._dirstate_helpers_c import _cmp_path_by_dirblock_c
 
671
        from bzrlib._dirstate_helpers_pyx import _cmp_path_by_dirblock_c
671
672
        return _cmp_path_by_dirblock_c
672
673
 
673
674
 
677
678
    _test_needs_features = [CompiledDirstateHelpersFeature]
678
679
 
679
680
    def assertMemRChr(self, expected, s, c):
680
 
        from bzrlib._dirstate_helpers_c import _py_memrchr
 
681
        from bzrlib._dirstate_helpers_pyx import _py_memrchr
681
682
        self.assertEqual(expected, _py_memrchr(s, c))
682
683
 
683
684
    def test_missing(self):
761
762
    _test_needs_features = [CompiledDirstateHelpersFeature]
762
763
 
763
764
    def get_read_dirblocks(self):
764
 
        from bzrlib._dirstate_helpers_c import _read_dirblocks_c
 
765
        from bzrlib._dirstate_helpers_pyx import _read_dirblocks_c
765
766
        return _read_dirblocks_c
766
767
 
767
768
 
769
770
    """Check that any compiled functions that are available are the default.
770
771
 
771
772
    It is possible to have typos, etc in the import line, such that
772
 
    _dirstate_helpers_c is actually available, but the compiled functions are
 
773
    _dirstate_helpers_pyx is actually available, but the compiled functions are
773
774
    not being used.
774
775
    """
775
776
 
776
777
    def test_bisect_dirblock(self):
777
778
        if CompiledDirstateHelpersFeature.available():
778
 
            from bzrlib._dirstate_helpers_c import bisect_dirblock_c
 
779
            from bzrlib._dirstate_helpers_pyx import bisect_dirblock_c
779
780
            self.assertIs(bisect_dirblock_c, dirstate.bisect_dirblock)
780
781
        else:
781
782
            from bzrlib._dirstate_helpers_py import bisect_dirblock_py
783
784
 
784
785
    def test__bisect_path_left(self):
785
786
        if CompiledDirstateHelpersFeature.available():
786
 
            from bzrlib._dirstate_helpers_c import _bisect_path_left_c
 
787
            from bzrlib._dirstate_helpers_pyx import _bisect_path_left_c
787
788
            self.assertIs(_bisect_path_left_c, dirstate._bisect_path_left)
788
789
        else:
789
790
            from bzrlib._dirstate_helpers_py import _bisect_path_left_py
791
792
 
792
793
    def test__bisect_path_right(self):
793
794
        if CompiledDirstateHelpersFeature.available():
794
 
            from bzrlib._dirstate_helpers_c import _bisect_path_right_c
 
795
            from bzrlib._dirstate_helpers_pyx import _bisect_path_right_c
795
796
            self.assertIs(_bisect_path_right_c, dirstate._bisect_path_right)
796
797
        else:
797
798
            from bzrlib._dirstate_helpers_py import _bisect_path_right_py
799
800
 
800
801
    def test_cmp_by_dirs(self):
801
802
        if CompiledDirstateHelpersFeature.available():
802
 
            from bzrlib._dirstate_helpers_c import cmp_by_dirs_c
 
803
            from bzrlib._dirstate_helpers_pyx import cmp_by_dirs_c
803
804
            self.assertIs(cmp_by_dirs_c, dirstate.cmp_by_dirs)
804
805
        else:
805
806
            from bzrlib._dirstate_helpers_py import cmp_by_dirs_py
807
808
 
808
809
    def test__read_dirblocks(self):
809
810
        if CompiledDirstateHelpersFeature.available():
810
 
            from bzrlib._dirstate_helpers_c import _read_dirblocks_c
 
811
            from bzrlib._dirstate_helpers_pyx import _read_dirblocks_c
811
812
            self.assertIs(_read_dirblocks_c, dirstate._read_dirblocks)
812
813
        else:
813
814
            from bzrlib._dirstate_helpers_py import _read_dirblocks_py
815
816
 
816
817
    def test_update_entry(self):
817
818
        if CompiledDirstateHelpersFeature.available():
818
 
            from bzrlib._dirstate_helpers_c import update_entry
 
819
            from bzrlib._dirstate_helpers_pyx import update_entry
819
820
            self.assertIs(update_entry, dirstate.update_entry)
820
821
        else:
821
822
            from bzrlib.dirstate import py_update_entry
823
824
 
824
825
    def test_process_entry(self):
825
826
        if CompiledDirstateHelpersFeature.available():
826
 
            from bzrlib._dirstate_helpers_c import ProcessEntryC
 
827
            from bzrlib._dirstate_helpers_pyx import ProcessEntryC
827
828
            self.assertIs(ProcessEntryC, dirstate._process_entry)
828
829
        else:
829
830
            from bzrlib.dirstate import ProcessEntryPython