Example #1
0
class UnittestTestGenerator(TestGenerator):
    main_snippet = parse_fragment("if __name__ == '__main__':\n    unittest.main()\n")
    template = UnittestTemplate()

    def test_class_header(self, name):
        self.ensure_import('unittest')
        return "class %s(unittest.TestCase):" % name
Example #2
0
 def _generate_test_class(self, class_name, method_descriptions, module, body):
     code = parse_fragment(body)
     def methoddesc2testmethod(method_description):
         name = method_description.name
         return TestMethod(name=name, code=find_method_code(code, name))
     return TestClass(name=class_name,
                      code=code,
                      test_cases=list(map(methoddesc2testmethod, method_descriptions)),
                      imports=self.imports,
                      associated_modules=[module])
Example #3
0
 def _generate_test_class(self, class_name, method_descriptions, module, body):
     code = parse_fragment(body)
     def methoddesc2testmethod(method_description):
         name = method_description.name
         return TestMethod(name=name, code=find_method_code(code, name))
     return TestClass(name=class_name,
                      code=code,
                      test_cases=map(methoddesc2testmethod, method_descriptions),
                      imports=self.imports,
                      associated_modules=[module])