Overview
Comment: | [core] tests: also test messages |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | core |
Files: | files | file ages | folders |
SHA3-256: |
a56f68f7ac774e16ff7db1e244dadffe |
User & Date: | olr on 2018-11-26 08:41:08 |
Other Links: | manifest | tags |
Context
2018-11-26
| ||
08:49 | [fr] correction de messages check-in: 8cc4efc761 user: olr tags: trunk, fr | |
08:41 | [core] tests: also test messages check-in: a56f68f7ac user: olr tags: trunk, core | |
08:15 | [fr] faux positifs check-in: f9a95f5a55 user: olr tags: trunk, fr | |
Changes
Modified gc_lang/fr/modules/tests.py from [7a6a733de8] to [582cec6490].
︙ | ︙ | |||
122 123 124 125 126 127 128 | class TestGrammarChecking (unittest.TestCase): @classmethod def setUpClass (cls): gce.load() cls._zError = re.compile(r"\{\{.*?\}\}") | | | 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | class TestGrammarChecking (unittest.TestCase): @classmethod def setUpClass (cls): gce.load() cls._zError = re.compile(r"\{\{.*?\}\}") cls._aTestedRules = 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() ): |
︙ | ︙ | |||
168 169 170 171 172 173 174 | "\n errors: \n" + sListErr) nError += 1 if nError: print("Unexpected errors:", nError) # untested rules i = 0 for sOpt, sLineId, sRuleId in gce.listRules(): | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | "\n errors: \n" + sListErr) nError += 1 if nError: print("Unexpected errors:", nError) # untested rules i = 0 for sOpt, sLineId, sRuleId in gce.listRules(): if sOpt != "@@@@" and sLineId not in self._aTestedRules and not re.search("^[0-9]+[sp]$|^[pd]_", sRuleId): echo(sLineId + "/" + sRuleId, end= ", ") i += 1 if i: echo("\n[{} untested rules]".format(i)) def _splitTestLine (self, sLine): sText, sSugg = sLine.split("->>") |
︙ | ︙ | |||
192 193 194 195 196 197 198 | sRes = " " * len(sLine) sListErr = "" lAllSugg = [] for dErr in aErrs: sRes = sRes[:dErr["nStart"]] + "~" * (dErr["nEnd"] - dErr["nStart"]) + sRes[dErr["nEnd"]:] sListErr += " * {sLineId} / {sRuleId} at {nStart}:{nEnd}\n".format(**dErr) lAllSugg.append("|".join(dErr["aSuggestions"])) | | > > > > > | 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | sRes = " " * len(sLine) sListErr = "" lAllSugg = [] for dErr in aErrs: sRes = sRes[:dErr["nStart"]] + "~" * (dErr["nEnd"] - dErr["nStart"]) + sRes[dErr["nEnd"]:] sListErr += " * {sLineId} / {sRuleId} at {nStart}:{nEnd}\n".format(**dErr) lAllSugg.append("|".join(dErr["aSuggestions"])) self._aTestedRules.add(dErr["sLineId"]) # test messages if "<start>" in dErr["sMessage"] or "<end>" in dErr["sMessage"]: print("\n# Line num : " + dErr["sLineId"] + \ "\n rule name: " + dErr["sRuleId"] + \ "\n message : " + dErr["sMessage"]) return sRes, sListErr, "|||".join(lAllSugg) def _getExpectedErrors (self, sLine): sRes = " " * len(sLine) for i, m in enumerate(self._zError.finditer(sLine)): nStart = m.start() - (4 * i) nEnd = m.end() - (4 * (i+1)) |
︙ | ︙ |