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
|
cls._zError = re.compile(r"\{\{.*?\}\}")
cls._aRuleTested = set()
def test_parse (self):
zOption = re.compile("^__([a-zA-Z0-9]+)__ ")
spHere, spfThisFile = os.path.split(__file__)
with open(os.path.join(spHere, "gc_test.txt"), "r", encoding="utf-8") as hSrc:
for sLine in ( s for s in hSrc if not s.startswith("#") and s.strip() ):
sLineNum = sLine[:10].strip()
sLine = sLine[10:].strip()
sOption = None
m = zOption.search(sLine)
if m:
sLine = sLine[m.end():]
sOption = m.group(1)
if "->>" in sLine:
sErrorText, sExceptedSuggs = self._splitTestLine(sLine)
if sExceptedSuggs.startswith('"') and sExceptedSuggs.endswith('"'):
sExceptedSuggs = sExceptedSuggs[1:-1]
else:
sErrorText = sLine.strip()
sExceptedSuggs = ""
sExpectedErrors = self._getExpectedErrors(sErrorText)
sTextToCheck = sErrorText.replace("}}", "").replace("{{", "")
sFoundErrors, sListErr, sFoundSuggs = self._getFoundErrors(sTextToCheck, sOption)
self.assertEqual(sExpectedErrors, sFoundErrors, \
"\n# Line num: " + sLineNum + \
"\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + \
"\n expected: " + sExpectedErrors + \
"\n found: " + sFoundErrors + \
"\n errors: \n" + sListErr)
if sExceptedSuggs:
self.assertEqual(sExceptedSuggs, sFoundSuggs, "\n# Line num: " + sLineNum + "\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + "\n errors: \n" + sListErr)
# untested rules
i = 0
for sOpt, sLineId, sRuleId in gce.listRules():
if sLineId not in self._aRuleTested and not re.search("^[0-9]+[sp]$|^[pd]_", sRuleId):
echo(sRuleId, end= ", ")
i += 1
if i:
|
>
>
|
|
|
|
|
|
>
|
>
>
|
>
>
>
>
>
>
|
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
|
cls._zError = re.compile(r"\{\{.*?\}\}")
cls._aRuleTested = set()
def test_parse (self):
zOption = re.compile("^__([a-zA-Z0-9]+)__ ")
spHere, spfThisFile = os.path.split(__file__)
with open(os.path.join(spHere, "gc_test.txt"), "r", encoding="utf-8") as hSrc:
nError = 0
for sLine in ( s for s in hSrc if not s.startswith("#") and s.strip() ):
sLineNum = sLine[:10].strip()
sLine = sLine[10:].strip()
sOption = None
m = zOption.search(sLine)
if m:
sLine = sLine[m.end():]
sOption = m.group(1)
if "->>" in sLine:
sErrorText, sExceptedSuggs = self._splitTestLine(sLine)
if sExceptedSuggs.startswith('"') and sExceptedSuggs.endswith('"'):
sExceptedSuggs = sExceptedSuggs[1:-1]
else:
sErrorText = sLine.strip()
sExceptedSuggs = ""
sExpectedErrors = self._getExpectedErrors(sErrorText)
sTextToCheck = sErrorText.replace("}}", "").replace("{{", "")
sFoundErrors, sListErr, sFoundSuggs = self._getFoundErrors(sTextToCheck, sOption)
# tests
if sExpectedErrors != sFoundErrors:
print("\n# Line num: " + sLineNum + \
"\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + \
"\n expected: " + sExpectedErrors + \
"\n found: " + sFoundErrors + \
"\n errors: \n" + sListErr)
nError += 1
elif sExceptedSuggs:
if sExceptedSuggs != sFoundSuggs:
print("\n# Line num: " + sLineNum + \
"\n> to check: " + _fuckBackslashUTF8(sTextToCheck) + \
"\n expected: " + sExceptedSuggs + \
"\n found: " + sFoundSuggs + \
"\n errors: \n" + sListErr)
nError += 1
if nError:
print("Unexpected errors:", nError)
# untested rules
i = 0
for sOpt, sLineId, sRuleId in gce.listRules():
if sLineId not in self._aRuleTested and not re.search("^[0-9]+[sp]$|^[pd]_", sRuleId):
echo(sRuleId, end= ", ")
i += 1
if i:
|