Commit 2d65e5aa by Artur Daschevici

added test, removed unused import

parent d26cad02
...@@ -48,7 +48,9 @@ def wp(l): ...@@ -48,7 +48,9 @@ def wp(l):
l = l.replace(" |", "\033[1;37m |\033[0;31m") l = l.replace(" |", "\033[1;37m |\033[0;31m")
if l.startswith("\033[1;30m"): if l.startswith("\033[1;30m"):
l = l.replace(" |", "\033[1;37m |\033[1;30m") l = l.replace(" |", "\033[1;37m |\033[1;30m")
if l.startswith("\033[1;31m"):
l = l.replace(" |", "\033[1;37m |\033[0;31m")
return l return l
...@@ -157,14 +159,18 @@ def print_outline(scenario, order, outline, reasons_to_fail): ...@@ -157,14 +159,18 @@ def print_outline(scenario, order, outline, reasons_to_fail):
wline = lambda x: write_out("\033[0;36m%s%s\033[0m\n" % (" " * scenario.table_indentation, x)) 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_success = lambda x: write_out("\033[1;32m%s%s\033[0m\n" % (" " * scenario.table_indentation, x))
wline_red = lambda x: wrt("%s%s" % (" " * 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: if order is 0:
wrt("\n") wrt("\n")
wrt("\033[1;37m%s%s:\033[0m\n" % (" " * scenario.indentation, scenario.language.first_of_examples)) wrt("\033[1;37m%s%s:\033[0m\n" % (" " * scenario.indentation, scenario.language.first_of_examples))
wline(head) wline(head)
line = lines[order] line = lines[order]
wline_success(line) if reasons_to_fail:
wline_red_outline(line)
else:
wline_success(line)
if reasons_to_fail: if reasons_to_fail:
elines = reasons_to_fail[0].traceback.splitlines() elines = reasons_to_fail[0].traceback.splitlines()
wrt("\033[1;31m") wrt("\033[1;31m")
......
...@@ -21,6 +21,8 @@ from nose.tools import assert_equals, assert_not_equals ...@@ -21,6 +21,8 @@ from nose.tools import assert_equals, assert_not_equals
from lettuce import registry from lettuce import registry
from difflib import Differ from difflib import Differ
def prepare_stdout(): def prepare_stdout():
registry.clear() registry.clear()
if isinstance(sys.stdout, StringIO): if isinstance(sys.stdout, StringIO):
...@@ -90,7 +92,7 @@ def assert_lines_with_traceback(one, other): ...@@ -90,7 +92,7 @@ def assert_lines_with_traceback(one, other):
def assert_unicode_equals(original, expected): def assert_unicode_equals(original, expected):
if isinstance(original, basestring): if isinstance(original, basestring):
original = original.decode('utf-8') original = original.decode('utf-8')
assert_equals.im_class.maxDiff = None
assert_equals(original, expected) assert_equals(original, expected)
def assert_stderr(expected): def assert_stderr(expected):
......
...@@ -688,7 +688,7 @@ def test_output_with_failful_outline_colorful(): ...@@ -688,7 +688,7 @@ def test_output_with_failful_outline_colorful():
'\033[1;37m Examples:\033[0m\n' '\033[1;37m Examples:\033[0m\n'
'\033[0;36m \033[1;37m |\033[0;36m username\033[1;37m |\033[0;36m password\033[1;37m |\033[0;36m email \033[1;37m |\033[0;36m message \033[1;37m |\033[0;36m\033[0m\n' '\033[0;36m \033[1;37m |\033[0;36m username\033[1;37m |\033[0;36m password\033[1;37m |\033[0;36m email \033[1;37m |\033[0;36m message \033[1;37m |\033[0;36m\033[0m\n'
'\033[1;32m \033[1;37m |\033[1;32m john \033[1;37m |\033[1;32m doe-1234\033[1;37m |\033[1;32m john@gmail.org\033[1;37m |\033[1;32m Welcome, John\033[1;37m |\033[1;32m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m john \033[1;37m |\033[1;32m doe-1234\033[1;37m |\033[1;32m john@gmail.org\033[1;37m |\033[1;32m Welcome, John\033[1;37m |\033[1;32m\033[0m\n'
'\033[1;32m \033[1;37m |\033[1;32m mary \033[1;37m |\033[1;32m wee-9876\033[1;37m |\033[1;32m mary@email.com\033[1;37m |\033[1;32m Welcome, Mary\033[1;37m |\033[1;32m\033[0m\n' '\033[1;31m \033[1;37m |\033[0;31m mary \033[1;37m |\033[0;31m wee-9876\033[1;37m |\033[0;31m mary@email.com\033[1;37m |\033[0;31m Welcome, Mary\033[1;37m |\033[0;31m\033[0m\n'
"\033[1;31m Traceback (most recent call last):\n" "\033[1;31m Traceback (most recent call last):\n"
' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n' ' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n'
" ret = self.function(self.step, *args, **kw)\n" " ret = self.function(self.step, *args, **kw)\n"
......
...@@ -42,6 +42,7 @@ def assert_xsd_valid(filename, content): ...@@ -42,6 +42,7 @@ def assert_xsd_valid(filename, content):
def test_xunit_output_with_no_errors(): def test_xunit_output_with_no_errors():
'Test xunit output with no errors' 'Test xunit output with no errors'
called = [] called = []
def assert_correct_xml(filename, content): def assert_correct_xml(filename, content):
called.append(True) called.append(True)
assert_xsd_valid(filename, content) assert_xsd_valid(filename, content)
......
...@@ -24,9 +24,11 @@ Given I have the following items in my shelf: ...@@ -24,9 +24,11 @@ Given I have the following items in my shelf:
| name | description | | name | description |
| Glass | a nice glass to drink grape juice | | Glass | a nice glass to drink grape juice |
| Pasta | a pasta to cook and eat with grape juice in the glass | | Pasta | a pasta to cook and eat with grape juice in the glass |
| Pasta | a pasta to cook and eat with grape juice in the glass |
''' '''
def test_step_definition(): def test_step_definition():
"Step definition takes a function and a step, keeps its definition " \ "Step definition takes a function and a step, keeps its definition " \
"relative path, and line + 1 (to consider the decorator)" "relative path, and line + 1 (to consider the decorator)"
...@@ -37,7 +39,7 @@ def test_step_definition(): ...@@ -37,7 +39,7 @@ def test_step_definition():
definition = core.StepDefinition("FOO BAR", dumb) definition = core.StepDefinition("FOO BAR", dumb)
assert_equals(definition.function, dumb) assert_equals(definition.function, dumb)
assert_equals(definition.file, core.fs.relpath(__file__).rstrip("c")) assert_equals(definition.file, core.fs.relpath(__file__).rstrip("c"))
assert_equals(definition.line, 35) assert_equals(definition.line, 37)
def test_step_description(): def test_step_description():
...@@ -101,7 +103,7 @@ def test_feature_description(): ...@@ -101,7 +103,7 @@ def test_feature_description():
def test_step_represent_string_when_not_defined(): def test_step_represent_string_when_not_defined():
"Step.represent_string behaviour when not defined" """Step.represent_string behaviour when not defined"""
class FakeFeature: class FakeFeature:
max_length = 10 max_length = 10
...@@ -151,6 +153,32 @@ def test_step_represent_table(): ...@@ -151,6 +153,32 @@ def test_step_represent_table():
' | name | description |\n' ' | name | description |\n'
' | Glass | a nice glass to drink grape juice |\n' ' | Glass | a nice glass to drink grape juice |\n'
' | Pasta | a pasta to cook and eat with grape juice in the glass |\n' ' | Pasta | a pasta to cook and eat with grape juice in the glass |\n'
' | Pasta | a pasta to cook and eat with grape juice in the glass |\n'
)
STEP_WITH_MATRIX = u'''
Given i have the following matrix:
| a | b | ab |
| 2 | 24 | 3 |
'''
STEP_WITH_MATRIX2 = u'''
Given i have the following matrix:
| a | a |
| 2 | a |
| | 67 |
'''
def test_step_represent_matrix():
"Step with a more suggestive representation for a matrix"
step = core.Step.from_string(STEP_WITH_MATRIX2)
assert_equals(
step.represent_columns(),
' | a | a |\n'
' | 2 | a |\n'
' | | 67|\n'
) )
SCENARIO_OUTLINE = u''' SCENARIO_OUTLINE = u'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment