~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: Robert Collins
  • Date: 2005-12-12 22:34:21 UTC
  • Revision ID: robertc@robertcollins.net-20051212223421-c0f6e7a7fae0b5ee
Bugfix to source testing logic to get the right path when .py is returned by __file__

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
                occurences += 1
41
41
        return occurences
42
42
 
 
43
    def source_file_name(self, package):
 
44
        """Return the path of the .py file for package."""
 
45
        path = package.__file__
 
46
        if path[-1] in 'co':
 
47
            return path[:-1]
 
48
        else:
 
49
            return path
 
50
 
43
51
    def test_branch_working_tree(self):
44
52
        """Test that the number of uses of working_tree in branch is stable."""
45
53
        occurences = self.find_occurences('self.working_tree()',
46
 
                                          bzrlib.branch.__file__[:-1])
 
54
                                          self.source_file_name(bzrlib.branch))
47
55
        # do not even think of increasing this number. If you think you need to
48
56
        # increase it, then you almost certainly are doing something wrong as
49
57
        # the relationship from working_tree to branch is one way.
56
64
    def test_branch_WorkingTree(self):
57
65
        """Test that the number of uses of working_tree in branch is stable."""
58
66
        occurences = self.find_occurences('WorkingTree',
59
 
                                          bzrlib.branch.__file__[:-1])
 
67
                                          self.source_file_name(bzrlib.branch))
60
68
        # do not even think of increasing this number. If you think you need to
61
69
        # increase it, then you almost certainly are doing something wrong as
62
70
        # the relationship from working_tree to branch is one way.