def get_representation(self): output = "" if not Config().no_indentation: output += self.get_indentation() if not Config().no_numbers: output += colorful.bold_white("%*d. " % (0 if Config().no_indentation else len(str(Config().highest_feature_id)), self._id)) if Config().with_section_names: output += colorful.bold_white("%s: " % self._title) output += colorful.bold_white(self._sentence + " " * (Config().longest_feature_text - len(self._sentence))) output += " " * 10 + colorful.bold_black("# " + fsh.filename(self._filename)) + "\n" for l in self._description.splitlines(): if not Config().no_indentation: output += self.get_indentation() + " " * len(str(Config().highest_feature_id)) + " " output += colorful.white(l) + "\n" return output + "\n"
def print_before_feature(feature): if not feature.is_dry_run(): if not Config().no_indentation: sys.stdout.write(feature.get_indentation()) if not Config().no_numbers: sys.stdout.write(colorful.bold_white("%*d. " % (0 if Config().no_indentation else len(str(Config().highest_feature_id)), feature.get_id()))) if Config().with_section_names: sys.stdout.write(colorful.bold_white("Feature: ")) sys.stdout.write(colorful.bold_white(feature.get_sentence() + " " * (Config().longest_feature_text - len(feature.get_sentence())))) sys.stdout.write(" " * 10 + colorful.bold_black("# " + fsh.filename(feature.get_filename()))) sys.stdout.write("\n") for l in feature.get_description().splitlines(): if not Config().no_indentation: sys.stdout.write(feature.get_indentation() + " " * len(str(Config().highest_feature_id)) + " ") colorful.out.white(l) sys.stdout.write("\n") sys.stdout.flush()
def generate(self): try: from lxml import etree except: raise RadishError("No lxml support. Please install python-lxml") outputs = {} if Config().split_xunit: for f in self._endResult.get_features(): filename = fsh.filename(f.get_filename(), with_extension=False) path = os.path.join(Config().xunit_file, filename + ".xml") if path not in outputs: outputs[path] = [] outputs[path].append(f) else: outputs[XunitWriter.ONE_XUNIT] = self._endResult.get_features() for filename, features in outputs.iteritems(): if filename == XunitWriter.ONE_XUNIT: filename = Config().xunit_file or XunitWriter.REPORT_FILENAME testsuite = etree.Element( "testsuite", name="radish", hostname="localhost", id=unicode(Config().marker), time=str(sum([f.get_duration() for f in features])), tests=str(self._endResult.get_total_steps()), failures=str(self._endResult.get_failed_steps()), skipped=str(self._endResult.get_skipped_steps()), errors="0", timestamp=datetime.now().strftime("%Y-%m-%dT%H:%M:%S") ) # append steps to testsuite for f in features: for s in f.get_scenarios(): for step in s.get_steps(): testsuite.append(step.get_report_as_xunit_tag()) with open(filename, "w") as f: f.write(etree.tostring(testsuite, pretty_print=True, xml_declaration=True, encoding="utf-8"))