This file is indexed.

/usr/share/pyshared/simpleparse/tests/mx_high.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
"""Low-level matching tests for mx.TextTools"""
import unittest, pprint
from simpleparse.stt.TextTools import *

import string
from simpleparse.stt import TextTools
mxVersion = tuple(string.split( TextTools.__version__, '.')[:3])

class MXHighTests(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 )

	### XXX Need to figure out what the heck loop is for and how to test it


	def testCall( self ):
		"""Test call-to-match Call command"""
		def function( text, start, end ):
			return end
	
		self.doBasicTest(
			(
				( "ab", Call, function, 0 ),
			),
			"cdffgg",
			( 1,[
				("ab",0,6,None),
			],6),
		)
	def testCall2( self ):
		"""Test call-to-match Call command with object instance"""
		class X:
			def __call__( self, text, start, end ):
				return end
	
		self.doBasicTest(
			(
				( "ab", Call, X(), 0 ),
			),
			"cdffgg",
			( 1,[
				("ab",0,6,None),
			],6),
		)
		
	def testCallArg( self ):
		"""Test call-to-match CallArg command"""
		def function( text, start, end, *arguments ):
			assert arguments == (1,2,3), """Passed arguments were not what we passed in"""
			return end
	
		self.doBasicTest(
			(
				( "ab", CallArg, (function,1,2,3), 0 ),
			),
			"cdffgg",
			( 1,[
				("ab",0,6,None),
			],6),
		)

	if mxVersion >= ('2','1'):
		def testsWordStart1( self ):
			"""Test simple sWordStart command"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sWordStart, TextSearch("ab", algorithm=algo), 0 ),
					),
					"ddeeffab",
					( 1,[("ab",0,6,None)],6),
				)
		def testsWordStart2( self ):
			"""Test simple sWordStart command ignore fail"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sWordStart, TextSearch("ab", algorithm=algo), 1,1),
					),
					"cdffgg",
					( 1,[],0),
				)
			
		def testsWordEnd1( self ):
			"""Test simple sWordEnd command"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sWordEnd, TextSearch("ab", algorithm=algo), 0 ),
					),
					"ddeeffab",
					( 1,[("ab",0,8,None)],8),
				)
		def testsWordEnd2( self ):
			"""Test simple sWordEnd command ignore fail"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sWordEnd, TextSearch("ab", algorithm=algo), 1,1),
					),
					"cdffgg",
					( 1,[],0),
				)


		def testsFindWord1( self ):
			"""Test simple sWordFind command"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sFindWord, TextSearch("ab", algorithm=algo), 0 ),
					),
					"ddeeffab",
					( 1,[("ab",6,8,None)],8),
				)
		def testsFindWord2( self ):
			"""Test simple sFindWord command ignore fail"""
			for algo in [BOYERMOORE, TRIVIAL]:
				self.doBasicTest(
					(
						( "ab", sFindWord, TextSearch("ab", algorithm=algo), 1,1),
					),
					"cdffgg",
					( 1,[],0),
				)
	else:
		def testsWordStart1( self ):
			"""Test simple sWordStart command"""
			self.doBasicTest(
				(
					( "ab", sWordStart, BMS("ab"), 0 ),
				),
				"ddeeffab",
				( 1,[("ab",0,6,None)],6),
			)
		def testsWordStart2( self ):
			"""Test simple sWordStart command ignore fail"""
			self.doBasicTest(
				(
					( "ab", sWordStart, BMS("ab"), 1,1),
				),
				"cdffgg",
				( 1,[],0),
			)
			
		def testsWordEnd1( self ):
			"""Test simple sWordEnd command"""
			self.doBasicTest(
				(
					( "ab", sWordEnd, BMS("ab"), 0 ),
				),
				"ddeeffab",
				( 1,[("ab",0,8,None)],8),
			)
		def testsWordEnd2( self ):
			"""Test simple sWordEnd command ignore fail"""
			self.doBasicTest(
				(
					( "ab", sWordEnd, BMS("ab"), 1,1),
				),
				"cdffgg",
				( 1,[],0),
			)


		def testsFindWord1( self ):
			"""Test simple sWordFind command"""
			self.doBasicTest(
				(
					( "ab", sFindWord, BMS("ab"), 0 ),
				),
				"ddeeffab",
				( 1,[("ab",6,8,None)],8),
			)
		def testsFindWord2( self ):
			"""Test simple sFindWord command ignore fail"""
			self.doBasicTest(
				(
					( "ab", sFindWord, BMS("ab"), 1,1),
				),
				"cdffgg",
				( 1,[],0),
			)
		

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

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