Exemplo n.º 1
0
 def _create_error_info(self, recorder, module_map):
     for spec, error in recorder.failures:
         module_bunch = module_map.get(spec.module())
         if module_bunch is None:
             continue
         module_bunch.failures.append(
             bunch(contexts=spec.contexts,
                   spec_name=spec.spec_name(long=True),
                   error_message=self._add_indent(error)))
Exemplo n.º 2
0
 def _create_result_record(self, module_map, target, entry):
     for spec, error in target:
         module_bunch = module_map.get(spec.module())
         if module_bunch is None:
             continue
         module_bunch[entry].append(
             bunch(contexts=spec.contexts,
                   spec_name=spec.spec_name(long=True),
                   error_message=self._add_indent(error)))
Exemplo n.º 3
0
 def generate(self, recorder):
     if self.output_folder is None:
         return
     summary = self._create_summary(recorder)
     result = bunch(summary=summary, modules=[])
     module_map = {}
     self._create_module_bunch(module_map, result)
     self._create_result_record(module_map, recorder.failures, "failures")
     self._create_result_record(module_map, recorder.errors, "errors")
     self._create_file("summary.rst", result)
Exemplo n.º 4
0
 def _create_module_bunch(self, module_map, result):
     for module in self.modules.get_modules("pyspec"):
         name = module.short_name()
         if name == "__main__":
             name = os.path.splitext(module.target().__file__)[0]
         print_name = "%s module\n%s" % (name, "-" * (len(name) + 7))
         module_bunch = tempita.bunch(name=print_name,
                                      failures=[],
                                      errors=[],
                                      success=[])
         module_map[module] = module_bunch
         result.modules.append(module_bunch)
Exemplo n.º 5
0
    def _create_summary(self, recorder):
        summary = bunch(ran=recorder.run_count,
                        error=len(recorder.errors),
                        failure=len(recorder.failures),
                        now=time.ctime(),
                        version=pyspec.__version__,
                        message=bunch())
        if summary.error == 0:
            summary.message["error"] = "There is no error."
        elif summary.error == 1:
            summary.message["error"] = "There is 1 error."
        else:
            summary.message["error"] = "There is %d errors." % summary.error

        if summary.failure == 0:
            summary.message["failure"] = "There is no failure."
        elif summary.failure == 1:
            summary.message["failure"] = "There is 1 failure."
        else:
            summary.message[
                "failure"] = "There is %d failures." % summary.failure
        return summary