示例#1
0
 def checkBadInput(self):
     badInputFilePath = os.path.join(common.getTestsPath(), u"{}.bad".format(self.path))
     for line in self.iterFileLines(badInputFilePath):
         if self.passes(line):
             common.error(u"O corrector aceptou «{}».".format(line))
             common.details(self.analyze(line))
             self.errors += 1
示例#2
0
def loadTestList():
    tests = []
    testsPath = common.getTestsPath()
    for jsonFilePath in findJsonFilePaths(testsPath):
        testPath = common.getFirstPathRelativeToSecondPathIfWithin(jsonFilePath[:-5], testsPath)
        tests.append(SpellingTest(testPath))
    return tests
示例#3
0
 def checkBadInput(self):
     badInputFilePath = os.path.join(common.getTestsPath(),
                                     u"{}.bad".format(self.path))
     for line in self.iterFileLines(badInputFilePath):
         if self.passes(line):
             common.error(u"O corrector aceptou «{}».".format(line))
             common.details(self.analyze(line))
             self.errors += 1
示例#4
0
def loadTestList():
    tests = []
    testsPath = common.getTestsPath()
    for jsonFilePath in findJsonFilePaths(testsPath):
        testPath = common.getFirstPathRelativeToSecondPathIfWithin(
            jsonFilePath[:-5], testsPath)
        tests.append(SpellingTest(testPath))
    return tests
示例#5
0
 def checkGoodInput(self):
     goodInputFilePath = os.path.join(common.getTestsPath(), u"{}.good".format(self.path))
     for line in self.iterFileLines(goodInputFilePath):
         if not self.passes(line):
             common.error(u"O corrector non aceptou «{}».".format(line))
             details = self.analyze(line)
             common.details(details)
             self.errors += 1
示例#6
0
 def checkGoodInput(self):
     goodInputFilePath = os.path.join(common.getTestsPath(),
                                      u"{}.good".format(self.path))
     for line in self.iterFileLines(goodInputFilePath):
         if not self.passes(line):
             common.error(u"O corrector non aceptou «{}».".format(line))
             details = self.analyze(line)
             common.details(details)
             self.errors += 1
示例#7
0
 def config(self):
     if self._config is None:
         import json
         try:
             with codecs.open(os.path.join(common.getTestsPath(), self.path + u".json"), "r", "utf-8") as fileObject:
                 self._config = json.load(fileObject)
         except ValueError:
             self._config = {}
         defaultModules = ["rag/gl", "norma"]
         if "aff" not in self._config: self._config["aff"] = defaultModules
         if "dic" not in self._config: self._config["dic"] = defaultModules
         if "rep" not in self._config: self._config["rep"] = defaultModules
     return self._config
示例#8
0
 def config(self):
     if self._config is None:
         import json
         try:
             with codecs.open(
                     os.path.join(common.getTestsPath(),
                                  self.path + u".json"), "r",
                     "utf-8") as fileObject:
                 self._config = json.load(fileObject)
         except ValueError:
             self._config = {}
         defaultModules = ["rag/gl", "norma"]
         if "aff" not in self._config: self._config["aff"] = defaultModules
         if "dic" not in self._config: self._config["dic"] = defaultModules
         if "rep" not in self._config: self._config["rep"] = defaultModules
     return self._config
示例#9
0
import os, sys
import codecs, locale
import common, spellchecker, spelling, syntax

# See http://stackoverflow.com/a/4546129/939364
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout)


def loadBuiltInTestList():
    builtInTests = []
    builtInTests.extend(spelling.loadTestList())
    builtInTests.extend(syntax.loadTestList())
    return builtInTests


# Program starts.

testsPath = common.getTestsPath()
builtInTests = loadBuiltInTestList()

with spellchecker.Manager() as spellCheckerManager:
    for parameter in [parameter.decode('UTF-8') for parameter in sys.argv[1:]]:
        testPath = common.getFirstPathRelativeToSecondPathIfWithin(parameter, testsPath)
        executedTests = 0
        for test in builtInTests:
            if test.path.startswith(testPath):
                print u":: Executando «{path}»…".format(path=test.path)
                test.run(spellCheckerManager)
                executedTests += 1
        if executedTests == 0:
            print u":: Non existe ningunha proba para «{path}».".format(path=testPath)