def buildTestSuite():
    for filename in html5lib_test_files("sanitizer"):
        for test in simplejson.load(file(filename)):
            SanitizeTest.addTest("test_" + test["name"], test["output"], test["input"])
        for test in simplejson.load(file(filename)):
            SanitizeTest.addTest("test_strip_" + test["name"], test["stripped"], test["input"], strip=True)

    return unittest.TestLoader().loadTestsFromTestCase(SanitizeTest)
예제 #2
0
def buildTestSuite():
    for filename in html5lib_test_files("sanitizer"):
        for test in simplejson.load(file(filename)):
            SanitizeTest.addTest('test_' + test['name'], test['output'],
                                 test['input'])

    return unittest.TestLoader().loadTestsFromTestCase(SanitizeTest)
예제 #3
0
def buildTestSuite():
    for filename in html5lib_test_files('tokenizer', '*.test'):
        tests = simplejson.load(file(filename))
        testName = os.path.basename(filename).replace(".test", "")
        if 'tests' in tests:
            for index, test in enumerate(tests['tests']):
                #Skip tests with a self closing flag
                skip = False
                for token in test["output"]:
                    if token[0] == "StartTag" and len(token) == 4:
                        skip = True
                        break
                if skip:
                    continue
                if 'contentModelFlags' not in test:
                    test["contentModelFlags"] = ["PCDATA"]
                for contentModelFlag in test["contentModelFlags"]:
                    test["contentModelFlag"] = contentModelFlag

                    def testFunc(self, test=test):
                        self.runTokenizerTest(test)

                    testFunc.__doc__ = "\t".join(
                        [testName, test['description']])
                    setattr(TestCase, 'test_%s_%d' % (testName, index),
                            testFunc)
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #4
0
def buildTestSuite():
    for filename in html5lib_test_files('validator', '*.test'):
        tests = simplejson.load(file(filename))
        testName = os.path.basename(filename).replace(".test","")
        for index,test in enumerate(tests['tests']):
            def testFunc(self, test=test):
                self.runValidatorTest(test)
            testFunc.__doc__ = "\t".join([testName, test['description']])
            setattr(TestCase, 'test_%s_%d' % (testName, index), testFunc)
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #5
0
def buildTestSuite():
    for filename in html5lib_test_files('serializer', '*.test'):
        test_name = os.path.basename(filename).replace('.test', '')
        tests = simplejson.load(file(filename))
        for index, test in enumerate(tests['tests']):
            xhtml = test.get("xhtml", test["expected"])
            if test_name == 'optionaltags': xhtml = None
            TestCase.addTest('test_%s_%d' % (test_name, index + 1),
                             test["description"], test["input"],
                             test["expected"], xhtml, test.get("options", {}))
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #6
0
def buildTestSuite():
    for filename in html5lib_test_files('serializer', '*.test'):
        test_name = os.path.basename(filename).replace('.test','')
        tests = simplejson.load(file(filename))
        for index, test in enumerate(tests['tests']):
            xhtml = test.get("xhtml", test["expected"])
            if test_name == 'optionaltags': xhtml = None
            TestCase.addTest('test_%s_%d' % (test_name, index+1),
                test["description"], test["input"], test["expected"], xhtml,
                test.get("options", {}))
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #7
0
def buildTestSuite():
    for filename in html5lib_test_files('validator', '*.test'):
        tests = simplejson.load(file(filename))
        testName = os.path.basename(filename).replace(".test", "")
        for index, test in enumerate(tests['tests']):

            def testFunc(self, test=test):
                self.runValidatorTest(test)

            testFunc.__doc__ = "\t".join([testName, test['description']])
            setattr(TestCase, 'test_%s_%d' % (testName, index), testFunc)
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #8
0
def buildTestSuite():
    for filename in html5lib_test_files('tokenizer', '*.test'):
        tests = simplejson.load(file(filename))
        testName = os.path.basename(filename).replace(".test","")
        if 'tests' in tests:
            for index,test in enumerate(tests['tests']):
                #Skip tests with a self closing flag
                skip = False
                for token in test["output"]:
                    if token[0] == "StartTag" and len(token) == 4:
                        skip = True
                        break
                if skip:
                    continue
                if 'contentModelFlags' not in test:
                    test["contentModelFlags"] = ["PCDATA"]
                for contentModelFlag in test["contentModelFlags"]:
                    test["contentModelFlag"] = contentModelFlag
                    def testFunc(self, test=test):
                        self.runTokenizerTest(test)
                    testFunc.__doc__ = "\t".join([testName, 
                                                  test['description']])
                    setattr(TestCase, 'test_%s_%d' % (testName, index), testFunc)
    return unittest.TestLoader().loadTestsFromTestCase(TestCase)
예제 #9
0
def buildTestSuite():
    for filename in html5lib_test_files("sanitizer"):
        for test in simplejson.load(file(filename)):
          SanitizeTest.addTest('test_' + test['name'], test['output'], test['input'])

    return unittest.TestLoader().loadTestsFromTestCase(SanitizeTest)