This file is indexed.

/usr/share/pyshared/simpleparse/tests/mx_recursive.py is in python-simpleparse 2.1.0a1-6build1.

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
152
153
154
155
156
157
158
159
160
161
162
"""Low-level matching tests for mx.TextTools"""
import unittest, pprint
from simpleparse.stt.TextTools import *

ab = (
	( "ab", Word, "ab", 0 ),
)
cdef = (
	( "cd", Word, "cd", 0 ),
	( "ef", Word, "ef", 1,1 ),
)
tableList = [ ab, cdef ]
	

class MXRecursiveTests(unittest.TestCase):
	def doBasicTest(self, table, testvalue, expected, startPosition=0 ):
		result = tag( testvalue, table , startPosition)
		assert result == expected, '''\n\texpected:%s\n\tgot:%s\n'''%( expected, result )

	def testAB( self ):
		"""Test AB testing command"""
		self.doBasicTest(
			ab,
			"abcdef",
			( 1,[
				("ab",0,2,None),
			],2),
		)
	def testCDEF( self ):
		"""Test CDEF testing command"""
		self.doBasicTest(
			cdef,
			"cdef",
			( 1,[
				("cd",0,2,None),
				("ef",2,4,None),
			],4),
		)
	def testABCDEF( self ):
		"""Test abcdef all together"""
		self.doBasicTest(
			ab+cdef,
			"abcdef",
			( 1,[
				("ab",0,2,None),
				("cd",2,4,None),
				("ef",4,6,None),
			],6),
		)
		
	def testTable1( self ):
		"""Test Table command"""
		self.doBasicTest(
			(
				("first", Table, ab),
				("second", Table, cdef),
			),
			"abcdef",
			( 1,[
				("first",0,2,[
					("ab",0,2,None),
				]),
				("second",2,6,[
					("cd",2,4,None),
					("ef",4,6,None),
				]),
			],6),
		)
	def testTableInList1( self ):
		"""Test TableInList command"""
		self.doBasicTest(
			(
				("first", TableInList, (tableList,0)),
				("second", TableInList,(tableList,1)),
			),
			"abcdef",
			( 1,[
				("first",0,2,[
					("ab",0,2,None),
				]),
				("second",2,6,[
					("cd",2,4,None),
					("ef",4,6,None),
				]),
			],6),
		)

	def testSubTable1( self ):
		"""Test SubTable command"""
		self.doBasicTest(
			(
				("first", SubTable, ab),
				("second", SubTable, cdef),
			),
			"abcdef",
			( 1,[
				("ab",0,2,None),
				("first", 0,2, None),
				("cd",2,4,None),
				("ef",4,6,None),
				("second", 2,6, None),
			],6),
		)
	def testSubTable2( self ):
		"""Test SubTable command with no reporting of st groups"""
		self.doBasicTest(
			(
				(None, SubTable, ab),
				(None, SubTable, cdef),
			),
			"abcdef",
			( 1,[
				("ab",0,2,None),
				("cd",2,4,None),
				("ef",4,6,None),
			],6),
		)
	def testSubTableInList1( self ):
		"""Test SubTableInList command"""
		self.doBasicTest(
			(
				("first", SubTableInList, (tableList,0)),
				("second", SubTableInList, (tableList,1)),
			),
			"abcdef",
			( 1,[
				("ab",0,2,None),
				("first", 0,2, None),
				("cd",2,4,None),
				("ef",4,6,None),
				("second", 2,6, None),
			],6),
		)
	def testSubTableNotReturnRecursive( self ):
		"""Test that SubTable calls don't return a recursive structure"""
		result = tag( "abcdef", (
			("first", SubTableInList, (tableList,0)),
			("second", SubTableInList, (tableList,1)),
		), 0)
		assert result [1] is not result[1][1][3], """Subtable results list was the same list as the list enclosing it, looped data structure created"""
			
	def testSubTableInList2( self ):
		"""Test SubTable command with no reporting of st groups"""
		self.doBasicTest(
			(
				(None, SubTableInList, (tableList,0)),
				(None, SubTableInList, (tableList,1)),
			),
			"abcdef",
			( 1,[
				("ab",0,2,None),
				("cd",2,4,None),
				("ef",4,6,None),
			],6),
		)

		
def getSuite():
	return unittest.makeSuite(MXRecursiveTests,'test')

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