Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #6
0
 def test_format_nonascii_explanation(self):
     assert util.format_explanation('λ')
Exemple #7
0
 def nice_explanation(self):
     return format_explanation(self.explanation)
Exemple #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
Exemple #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
Exemple #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
 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
Exemple #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
Exemple #13
0
 def test_fmt_simple(self):
     expl = 'assert foo'
     assert util.format_explanation(expl) == 'assert foo'
Exemple #14
0
 def test_format_nonascii_explanation(self):
     assert util.format_explanation('λ')
Exemple #15
0
 def nice_explanation(self):
     return format_explanation(self.explanation)
 def test_fmt_newline_escaped(self):
     expl = "\n".join(["assert foo == bar", "baz"])
     res = "assert foo == bar\\nbaz"
     assert util.format_explanation(expl) == res
 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
Exemple #18
0
 def test_fmt_simple(self):
     expl = 'assert foo'
     assert util.format_explanation(expl) == 'assert foo'
Exemple #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
 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
Exemple #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
Exemple #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
Exemple #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
Exemple #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