Beispiel #1
0
class TestRenderer:

    def setup(self):
        self.renderer = Renderer()

    def test_header(self):
        result = self.renderer.header(3, 'Cat')
        expected = '<h3>Cat</h3>\n'
        assert result == expected

    def test_unordered_list(self):
        text_list = ['foo', 'bar']
        result = self.renderer.unordered_list(text_list)
        expected = '<ul>\n<li>foo</li>\n<li>bar</li>\n</ul>\n'
        assert result == expected

    def test_table(self):
        header = ['First', 'Second']
        body = [['foo', 'bar'], ['baz', 'cat']]
        result = self.renderer.table(header, body)
        expected = (
            '<table>\n<tr>\n' +
            '<th>First</th>\n<th>Second</th>\n' +
            '</tr>\n<tr>\n' +
            '<td>foo</td>\n<td>bar</td>\n'
            '</tr>\n<tr>\n' +
            '<td>baz</td>\n<td>cat</td>\n' +
            '</tr>\n</table>\n'
        )
        assert result == expected

    def test_paragraph(self):
        result = self.renderer.paragraph('cat')
        expected = '<p>cat</p>\n'
        assert result == expected

    def test_emphasis(self):
        result = self.renderer.emphasis('is')
        expected = '<em>is</em>'
        assert result == expected

    def test_double_emphasis(self):
        result = self.renderer.double_emphasis('cat')
        expected = '<strong>cat</strong>'
        assert result == expected

    def test_code(self):
        result = self.renderer.code('foo')
        expected = '<code>foo</code>'
        assert result == expected

    def test_link(self):
        result = self.renderer.link('example.com', 'example')
        expected = '<a href="example.com">example</a>'
        assert result == expected
Beispiel #2
0
class TestRenderer:
    def setup(self):
        self.renderer = Renderer()

    def test_header(self):
        result = self.renderer.header(3, "Cat")
        expected = "<h3>Cat</h3>\n"
        assert result == expected

    def test_unordered_list(self):
        text_list = ["foo", "bar"]
        result = self.renderer.unordered_list(text_list)
        expected = "<ul>\n<li>foo</li>\n<li>bar</li>\n</ul>\n"
        assert result == expected

    def test_table(self):
        header = ["First", "Second"]
        body = [["foo", "bar"], ["baz", "cat"]]
        result = self.renderer.table(header, body)
        expected = (
            "<table>\n<tr>\n"
            + "<th>First</th>\n<th>Second</th>\n"
            + "</tr>\n<tr>\n"
            + "<td>foo</td>\n<td>bar</td>\n"
            "</tr>\n<tr>\n" + "<td>baz</td>\n<td>cat</td>\n" + "</tr>\n</table>\n"
        )
        assert result == expected

    def test_paragraph(self):
        result = self.renderer.paragraph("cat")
        expected = "<p>cat</p>\n"
        assert result == expected

    def test_emphasis(self):
        result = self.renderer.emphasis("is")
        expected = "<em>is</em>"
        assert result == expected

    def test_double_emphasis(self):
        result = self.renderer.double_emphasis("cat")
        expected = "<strong>cat</strong>"
        assert result == expected

    def test_code(self):
        result = self.renderer.code("foo")
        expected = "<code>foo</code>"
        assert result == expected

    def test_link(self):
        result = self.renderer.link("example.com", "example")
        expected = '<a href="example.com">example</a>'
        assert result == expected
Beispiel #3
0
 def setup(self):
     self.renderer = Renderer()