예제 #1
0
 def test_fmt_where(self):
     expl = '\n'.join(['assert 1',
                       '{1 = foo',
                       '} == 2'])
     res = '\n'.join(['assert 1 == 2',
                      ' +  where 1 = foo'])
     assert util.format_explanation(expl) == res
예제 #2
0
 def test_fmt_newline(self):
     expl = '\n'.join(['assert "foo" == "bar"',
                       '~- foo',
                       '~+ bar'])
     res = '\n'.join(['assert "foo" == "bar"',
                      '  - foo',
                      '  + bar'])
     assert util.format_explanation(expl) == res
예제 #3
0
def getfailure(e):
    explanation = util.format_explanation(e.explanation)
    value = e.cause[1]
    if str(value):
        lines = explanation.split('\n')
        lines[0] += "  << %s" % (value,)
        explanation = '\n'.join(lines)
    text = "%s: %s" % (e.cause[0].__name__, explanation)
    if text.startswith('AssertionError: assert '):
        text = text[16:]
    return text
예제 #4
0
 def test_fmt_newline_before_where(self):
     expl = '\n'.join(['the assertion message here',
                       '>assert 1',
                       '{1 = foo',
                       '} == 2',
                       '{2 = bar',
                       '}'])
     res = '\n'.join(['the assertion message here',
                      'assert 1 == 2',
                      ' +  where 1 = foo',
                      ' +  and   2 = bar'])
     assert util.format_explanation(expl) == res
예제 #5
0
 def test_fmt_newline_before_where(self):
     expl = "\n".join(
         [
             "the assertion message here",
             ">assert 1",
             "{1 = foo",
             "} == 2",
             "{2 = bar",
             "}",
         ]
     )
     res = "\n".join(
         [
             "the assertion message here",
             "assert 1 == 2",
             " +  where 1 = foo",
             " +  and   2 = bar",
         ]
     )
     assert util.format_explanation(expl) == res
예제 #6
0
 def test_format_nonascii_explanation(self):
     assert util.format_explanation('λ')
예제 #7
0
 def nice_explanation(self):
     return format_explanation(self.explanation)
예제 #8
0
 def test_fmt_newline_escaped(self):
     expl = "\n".join(["assert foo == bar", "baz"])
     res = "assert foo == bar\\nbaz"
     assert util.format_explanation(expl) == res
예제 #9
0
 def test_fmt_newline(self):
     expl = "\n".join(['assert "foo" == "bar"', "~- foo", "~+ bar"])
     res = "\n".join(['assert "foo" == "bar"', "  - foo", "  + bar"])
     assert util.format_explanation(expl) == res
예제 #10
0
 def test_fmt_newline(self):
     expl = '\n'.join(['assert "foo" == "bar"', '~- foo', '~+ bar'])
     res = '\n'.join(['assert "foo" == "bar"', '  - foo', '  + bar'])
     assert util.format_explanation(expl) == res
예제 #11
0
 def test_fmt_where_nested(self):
     expl = "\n".join(["assert 1", "{1 = foo", "{foo = bar", "}", "} == 2"])
     res = "\n".join(
         ["assert 1 == 2", " +  where 1 = foo", " +    where foo = bar"])
     assert util.format_explanation(expl) == res
예제 #12
0
 def test_fmt_newline_escaped(self):
     expl = '\n'.join(['assert foo == bar', 'baz'])
     res = 'assert foo == bar\\nbaz'
     assert util.format_explanation(expl) == res
예제 #13
0
 def test_fmt_simple(self):
     expl = 'assert foo'
     assert util.format_explanation(expl) == 'assert foo'
예제 #14
0
 def test_format_nonascii_explanation(self):
     assert util.format_explanation('λ')
예제 #15
0
 def nice_explanation(self):
     return format_explanation(self.explanation)
예제 #16
0
 def test_fmt_newline_escaped(self):
     expl = "\n".join(["assert foo == bar", "baz"])
     res = "assert foo == bar\\nbaz"
     assert util.format_explanation(expl) == res
예제 #17
0
 def test_fmt_newline(self):
     expl = "\n".join(['assert "foo" == "bar"', "~- foo", "~+ bar"])
     res = "\n".join(['assert "foo" == "bar"', "  - foo", "  + bar"])
     assert util.format_explanation(expl) == res
예제 #18
0
 def test_fmt_simple(self):
     expl = 'assert foo'
     assert util.format_explanation(expl) == 'assert foo'
예제 #19
0
 def test_fmt_and(self):
     expl = '\n'.join(['assert 1', '{1 = foo', '} == 2', '{2 = bar', '}'])
     res = '\n'.join(
         ['assert 1 == 2', ' +  where 1 = foo', ' +  and   2 = bar'])
     assert util.format_explanation(expl) == res
예제 #20
0
 def test_fmt_and(self):
     expl = "\n".join(["assert 1", "{1 = foo", "} == 2", "{2 = bar", "}"])
     res = "\n".join(
         ["assert 1 == 2", " +  where 1 = foo", " +  and   2 = bar"])
     assert util.format_explanation(expl) == res
예제 #21
0
 def test_fmt_newline_escaped(self):
     expl = '\n'.join(['assert foo == bar',
                       'baz'])
     res = 'assert foo == bar\\nbaz'
     assert util.format_explanation(expl) == res
예제 #22
0
 def test_fmt_and(self):
     expl = "\n".join(["assert 1", "{1 = foo", "} == 2", "{2 = bar", "}"])
     res = "\n".join(["assert 1 == 2", " +  where 1 = foo", " +  and   2 = bar"])
     assert util.format_explanation(expl) == res
예제 #23
0
 def test_fmt_where_nested(self):
     expl = "\n".join(["assert 1", "{1 = foo", "{foo = bar", "}", "} == 2"])
     res = "\n".join(["assert 1 == 2", " +  where 1 = foo", " +    where foo = bar"])
     assert util.format_explanation(expl) == res
예제 #24
0
 def test_fmt_where_nested(self):
     expl = '\n'.join(['assert 1', '{1 = foo', '{foo = bar', '}', '} == 2'])
     res = '\n'.join(
         ['assert 1 == 2', ' +  where 1 = foo', ' +    where foo = bar'])
     assert util.format_explanation(expl) == res