This file is indexed.

/usr/share/pyshared/bike/parsing/test_fastparserast.py is in bicyclerepair 0.9-6.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python
import unittest
from fastparserast import *
from fastparser import fastparser
from bike.query.getTypeOf import getTypeOf
from bike.testutils import *

class TestGetModule(BRMTestCase):

    def test_getRootWorksAfterDefinedByCreateSourceNodeAt(self):
        src=trimLines("""
        class TheClass:
            pass
        a = TheClass()
        """)
        root = createSourceNodeAt(src,"mymodule")
        assert root == getRoot()

    def test_returnsNoneIfModuleDoesntExist(self):
        assert getModule(tmpfile) == None


class TestGetEndLine(BRMTestCase):
    def test_returnsEndLineWithSimpleFunction(self):
        src = trimLines("""
        class TheClass:
            def theMethod():
                pass
        def foo():
            b = TheClass()
            return b
        a = foo()
        a.theMethod()
        """)
        root = fastparser(src)
        fn = getTypeOf(root,"foo")
        self.assertEqual(fn.getEndLine(),7)

    def test_worksWithFunctionsThatHaveEmptyLinesInThem(self):
        src = fnWithEmptyLineInIt
        root = fastparser(src)
        fn = getTypeOf(root,"TheClass.theFunction")
        self.assertEqual(fn.getEndLine(),8)

class TestGetBaseClassNames(BRMTestCase):
    def test_worksForClassHierarchy(self):
        src = trimLines("""
        class root:
            def theMethod():
                pass

        class a(root):
            def theMethod():
                pass    

        class b(root):
            pass

        class TheClass(a,b):
            def theMethod():
                pass

        rootinstance = root()
        rootinstance.theMethod()
        """)
        #classes = getASTNodeFromSrc(src,"Source").fastparseroot.getChildNodes()
        classes = createAST(src).fastparseroot.getChildNodes()
        self.assertEqual(classes[3].getBaseClassNames(),['a','b'])

    def test_returnsEmptyListForClassWithNoBases(self):
        src = trimLines("""
        class root:
            pass
        """)
        #classes = getASTNodeFromSrc(src,"Source").fastparseroot.getChildNodes()
        classes = createAST(src).fastparseroot.getChildNodes()        
        self.assertEqual(classes[0].getBaseClassNames(),[])


class TestGetMaskedLines(BRMTestCase):
    def test_doit(self):
        src =trimLines("""
        class foo: #bah
            pass
        """)
        mod = createAST(src).fastparseroot
        lines = mod.getMaskedModuleLines()
        assert lines[0] == "class foo: #***\n"


class TestGetLinesNotIncludingThoseBelongingToChildScopes(BRMTestCase):
    def test_worksForModule(self):
        src =trimLines("""
        class TheClass:
            def theMethod():
                pass
        def foo():
            b = TheClass()
            return b
        a = foo()
        a.theMethod()
        """)
        mod = createAST(src).fastparseroot
        self.assertEqual(''.join(mod.getLinesNotIncludingThoseBelongingToChildScopes()),
                         trimLines("""
                         a = foo()
                         a.theMethod()
                         """))

    def test_worksForModuleWithSingleLineFunctions(self):
        src=trimLines("""
        a = blah()
        def foo(): pass
        b = 1
        """)
        mod = createAST(src).fastparseroot
        lines = mod.getLinesNotIncludingThoseBelongingToChildScopes()
        self.assertEqual(''.join(lines),
                         trimLines("""
                         a = blah()
                         b = 1
                         """))


    def test_worksForSingleLineFunction(self):
        src=trimLines("""
        a = blah()
        def foo(): pass
        b = 1
        """)
        fn = createAST(src).fastparseroot.getChildNodes()[0]
        lines = fn.getLinesNotIncludingThoseBelongingToChildScopes()
        self.assertEqual(''.join(lines),
                         trimLines("""
                         def foo(): pass
                         """))


fnWithEmptyLineInIt = """
class TheClass:
    def theFunction():
        a = foo()

        print 'a'

    # end of function
"""

if __name__ == "__main__":
    unittest.main()