def print_outline(scenario, order, outline, reasons_to_fail): table = strings.dicts_to_string(scenario.outlines, scenario.keys) lines = table.splitlines() head = lines.pop(0) wline = lambda x: write_out("\033[0;36m%s%s\033[0m\n" % (" " * scenario.table_indentation, x)) wline_success = lambda x: write_out("\033[1;32m%s%s\033[0m\n" % (" " * scenario.table_indentation, x)) wline_red_outline = lambda x: write_out("\033[1;31m%s%s\033[0m\n" % (" " * scenario.table_indentation, x)) wline_red = lambda x: write_out("%s%s" % (" " * scenario.table_indentation, x)) if order is 0: wrt("\n") wrt("\033[1;37m%s%s:\033[0m\n" % (" " * scenario.indentation, scenario.language.first_of_examples)) wline(head) line = lines[order] if reasons_to_fail: wline_red_outline(line) else: wline_success(line) if reasons_to_fail: elines = reasons_to_fail[0].traceback.splitlines() wrt("\033[1;31m") for pindex, line in enumerate(elines): wline_red(line) if pindex + 1 < len(elines): wrt("\n") wrt("\033[0m\n")
def collect_outline_failures(scenario, order, outline, reasons_to_fail): table = strings.dicts_to_string(scenario.outlines, scenario.keys) lines = table.splitlines() head = lines.pop(0) if reasons_to_fail: scenarios_and_its_fails[scenario] = reasons_to_fail[0] failed_scenarios.append(scenario)
def test_dicts_to_string_escapes_pipe(): "strings.dicts_to_string escapes pipe" dicts = [{"name": u"Gabriel | Falcão", "age": 22}, {"name": "Miguel | Arcanjo", "age": 19}] assert_equals( strings.dicts_to_string(dicts, ["name", "age"]), u"| name | age |\n" u"| Gabriel \\| Falcão | 22 |\n" u"| Miguel \\| Arcanjo | 19 |\n", )
def test_dicts_to_string(): "strings.dicts_to_string" dicts = [{"name": u"Gabriel Falcão", "age": 22}, {"name": "Miguel", "age": 19}] assert_equals( strings.dicts_to_string(dicts, ["name", "age"]), u"| name | age |\n" u"| Gabriel Falcão | 22 |\n" u"| Miguel | 19 |\n", )
def test_dicts_to_string_allows_empty(): "strings.dicts_to_string allows empty" dicts = [{ 'name': u'Gabriel | Falcão', 'age': 22 }, { 'name': 'Miguel | Arcanjo' }] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel \\| Falcão | 22 |\n" u"| Miguel \\| Arcanjo | |\n")
def test_dicts_to_string_escapes_pipe(): "strings.dicts_to_string escapes pipe" dicts = [{ 'name': u'Gabriel | Falcão', 'age': 22 }, { 'name': 'Miguel | Arcanjo', 'age': 19 }] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel \\| Falcão | 22 |\n" u"| Miguel \\| Arcanjo | 19 |\n")
def test_dicts_to_string(): "strings.dicts_to_string" dicts = [{ 'name': u'Gabriel Falcão', 'age': 22 }, { 'name': 'Miguel', 'age': 19 }] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel Falcão | 22 |\n" u"| Miguel | 19 |\n")
def print_outline(scenario, order, outline, reasons_to_fail): table = strings.dicts_to_string(scenario.outlines, scenario.keys) lines = table.splitlines() head = lines.pop(0) wline = lambda x: wrt("%s%s\n" % (" " * scenario.table_indentation, x)) if order is 0: wrt("\n") wrt("%s%s:\n" % (" " * scenario.indentation, scenario.language.first_of_examples)) wline(head) line = lines[order] wline(line) if reasons_to_fail: print_spaced = lambda x: wrt("%s%s\n" % (" " * scenario.table_indentation, x)) elines = reasons_to_fail[0].traceback.splitlines() for line in elines: print_spaced(line)
def test_dicts_to_string_allows_empty(): "strings.dicts_to_string allows empty" dicts = [ { 'name': u'Gabriel | Falcão', 'age': 22 }, { 'name': 'Miguel | Arcanjo' } ] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel \\| Falcão | 22 |\n" u"| Miguel \\| Arcanjo | |\n" )
def test_dicts_to_string_escapes_pipe(): "strings.dicts_to_string escapes pipe" dicts = [ { 'name': u'Gabriel | Falcão', 'age': 22 }, { 'name': 'Miguel | Arcanjo', 'age': 19 } ] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel \\| Falcão | 22 |\n" u"| Miguel \\| Arcanjo | 19 |\n" )
def test_dicts_to_string(): "strings.dicts_to_string" dicts = [ { 'name': u'Gabriel Falcão', 'age': 22 }, { 'name': 'Miguel', 'age': 19 } ] assert_equals( strings.dicts_to_string(dicts, ['name', 'age']), u"| name | age |\n" u"| Gabriel Falcão | 22 |\n" u"| Miguel | 19 |\n" )
def represent_examples(self): lines = strings.dicts_to_string(self.outlines, self.keys).splitlines() return "\n".join([(u" " * self.table_indentation) + line for line in lines]) + '\n'
def represent_hashes(self): lines = strings.dicts_to_string(self.hashes, self.keys).splitlines() return u"\n".join([(u" " * self.table_indentation) + line for line in lines]) + "\n"