Пример #1
0
class TestInlineLexer:

    def setup(self):
        self.il = InlineLexer()

    def test_call(self):
        result = self.il('Word')
        assert result == 'Word'

    def test_parse(self):
        result = self.il.parse('*Word*')
        assert result == '<em>Word</em>'

    def test_parse_double_emphasis(self):
        regex = InlineGrammar.double_emphasis
        r = regex.match('__cat__')
        result = self.il.parse_double_emphasis(r)
        expected = '<strong>cat</strong>'
        assert result == expected

    def test_parse_link(self):
        regex = InlineGrammar.link
        r = regex.match('[example.com](Example)')
        result = self.il.parse_link(r)
        expected = '<a href="example.com">Example</a>'
        assert result == expected

    def test_parse_url(self):
        regex = InlineGrammar.url
        r = regex.match('http://example.co.uk')
        result = self.il.parse_url(r)
        expected = '<a href="http://example.co.uk">http://example.co.uk</a>'
        assert result == expected
Пример #2
0
class TestInlineLexer:
    def setup(self):
        self.il = InlineLexer()

    def test_call(self):
        result = self.il("Word")
        assert result == "Word"

    def test_parse(self):
        result = self.il.parse("*Word*")
        assert result == "<em>Word</em>"

    def test_parse_double_emphasis(self):
        regex = InlineGrammar.double_emphasis
        r = regex.match("__cat__")
        result = self.il.parse_double_emphasis(r)
        expected = "<strong>cat</strong>"
        assert result == expected

    def test_parse_link(self):
        regex = InlineGrammar.link
        r = regex.match("[example.com](Example)")
        result = self.il.parse_link(r)
        expected = '<a href="example.com">Example</a>'
        assert result == expected

    def test_parse_url(self):
        regex = InlineGrammar.url
        r = regex.match("http://example.co.uk")
        result = self.il.parse_url(r)
        expected = '<a href="http://example.co.uk">http://example.co.uk</a>'
        assert result == expected
Пример #3
0
 def setup(self):
     self.il = InlineLexer()