@@ -22,10 +22,11 @@ "fuck that shit" return s.replace("\u2019", "'").replace("\u2013", "–").replace("\u2014", "—") class TestDictionary (unittest.TestCase): + "Test du correcteur orthographique" @classmethod def setUpClass (cls): cls.oDic = IBDAWG("${dic_main_filename_py}") @@ -45,10 +46,11 @@ for sWord in ["BranchE", "BRanche", "BRAnCHE", "émilie", "éMILIE", "émiLie"]: self.assertFalse(self.oDic.isValid(sWord), sWord) class TestConjugation (unittest.TestCase): + "Tests des conjugaisons" @classmethod def setUpClass (cls): pass @@ -68,10 +70,11 @@ ("manger", ":Sp", ":3s", "mange"), ("finir", ":K", ":3p", "finiraient"), ("prendre", ":If", ":1p", "prendrons")]: self.assertEqual(conj.getConj(sVerb, sTense, sWho), sConj, sVerb) class TestPhonet (unittest.TestCase): + "Tests des équivalences phonétiques" @classmethod def setUpClass (cls): cls.lSet = [ ["ce", "se"], @@ -104,10 +107,11 @@ for sWord in aSet: self.assertListEqual(phonet.getSimil(sWord), sorted(aSet)) class TestMasFemSingPlur (unittest.TestCase): + "Tests des masculins, féminins, singuliers et pluriels" @classmethod def setUpClass (cls): cls.lPlural = [ ("travail", ["travaux"]), @@ -119,20 +123,21 @@ for sSing, lPlur in self.lPlural: self.assertListEqual(mfsp.getMiscPlural(sSing), lPlur) class TestGrammarChecking (unittest.TestCase): + "Tests du correcteur grammatical" @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__) + spHere, _ = 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() @@ -214,10 +219,11 @@ from contextlib import contextmanager @contextmanager def timeblock (label, hDst): + "performance counter (contextmanager)" start = time.perf_counter() try: yield finally: end = time.perf_counter() @@ -228,24 +234,25 @@ def perf (sVersion, hDst=None): "performance tests" print("\nPerformance tests") gce.load() - aErrs = gce.parse("Texte sans importance… utile pour la compilation des règles avant le calcul des perfs.") + gce.parse("Texte sans importance… utile pour la compilation des règles avant le calcul des perfs.") - spHere, spfThisFile = os.path.split(__file__) + spHere, _ = os.path.split(__file__) with open(os.path.join(spHere, "perf.txt"), "r", encoding="utf-8") as hSrc: if hDst: hDst.write("{:<12}{:<20}".format(sVersion, time.strftime("%Y.%m.%d %H:%M"))) for sText in ( s.strip() for s in hSrc if not s.startswith("#") and s.strip() ): with timeblock(sText[:sText.find(".")], hDst): - aErrs = gce.parse(sText) + gce.parse(sText) if hDst: hDst.write("\n") def main(): + "start function" unittest.main() if __name__ == '__main__': main()