mirror of
https://github.com/evennia/evennia.git
synced 2026-03-24 16:56:32 +01:00
updat text2html tests
This commit is contained in:
parent
efe9c69337
commit
6a5a17492c
1 changed files with 33 additions and 61 deletions
|
|
@ -7,20 +7,20 @@ import mock
|
|||
|
||||
|
||||
class TestText2Html(TestCase):
|
||||
def test_re_color(self):
|
||||
def test_format_styles(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_color("foo"))
|
||||
self.assertEqual("foo", parser.format_styles("foo"))
|
||||
self.assertEqual(
|
||||
'<span class="color-001">red</span>foo',
|
||||
parser.re_color(ansi.ANSI_UNHILITE + ansi.ANSI_RED + "red" + ansi.ANSI_NORMAL + "foo"),
|
||||
parser.format_styles(ansi.ANSI_UNHILITE + ansi.ANSI_RED + "red" + ansi.ANSI_NORMAL + "foo"),
|
||||
)
|
||||
self.assertEqual(
|
||||
'<span class="bgcolor-001">red</span>foo',
|
||||
parser.re_color(ansi.ANSI_BACK_RED + "red" + ansi.ANSI_NORMAL + "foo"),
|
||||
parser.format_styles(ansi.ANSI_BACK_RED + "red" + ansi.ANSI_NORMAL + "foo"),
|
||||
)
|
||||
self.assertEqual(
|
||||
'<span class="bgcolor-001"><span class="color-002">red</span></span>foo',
|
||||
parser.re_color(
|
||||
'<span class="bgcolor-001 color-002">red</span>foo',
|
||||
parser.format_styles(
|
||||
ansi.ANSI_BACK_RED
|
||||
+ ansi.ANSI_UNHILITE
|
||||
+ ansi.ANSI_GREEN
|
||||
|
|
@ -29,63 +29,37 @@ class TestText2Html(TestCase):
|
|||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_re_bold(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_bold("foo"))
|
||||
self.assertEqual(
|
||||
# "a <strong>red</strong>foo", # TODO: why not?
|
||||
"a <strong>redfoo</strong>",
|
||||
parser.re_bold("a " + ansi.ANSI_HILITE + "red" + ansi.ANSI_UNHILITE + "foo"),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_re_underline(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_underline("foo"))
|
||||
self.assertEqual(
|
||||
'a <span class="underline">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_underline(
|
||||
'a <span class="underline">red</span>foo',
|
||||
parser.format_styles(
|
||||
"a "
|
||||
+ ansi.ANSI_UNDERLINE
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_re_blinking(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_blinking("foo"))
|
||||
self.assertEqual(
|
||||
'a <span class="blink">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_blinking(
|
||||
'a <span class="blink">red</span>foo',
|
||||
parser.format_styles(
|
||||
"a "
|
||||
+ ansi.ANSI_BLINK
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_re_inversing(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_inversing("foo"))
|
||||
self.assertEqual(
|
||||
'a <span class="inverse">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_inversing(
|
||||
'a <span class="bgcolor-007 color-000">red</span>foo',
|
||||
parser.format_styles(
|
||||
"a "
|
||||
+ ansi.ANSI_INVERSE
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_remove_bells(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.remove_bells("foo"))
|
||||
|
|
@ -95,7 +69,7 @@ class TestText2Html(TestCase):
|
|||
"a "
|
||||
+ ansi.ANSI_BEEP
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
|
@ -110,7 +84,6 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual("foo", parser.convert_linebreaks("foo"))
|
||||
self.assertEqual("a<br> redfoo<br>", parser.convert_linebreaks("a\n redfoo\n"))
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_convert_urls(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.convert_urls("foo"))
|
||||
|
|
@ -118,7 +91,6 @@ class TestText2Html(TestCase):
|
|||
'a <a href="http://redfoo" target="_blank">http://redfoo</a> runs',
|
||||
parser.convert_urls("a http://redfoo runs"),
|
||||
)
|
||||
# TODO: doesn't URL encode correctly
|
||||
|
||||
def test_sub_mxp_links(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
|
|
@ -186,22 +158,22 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual("foo", text2html.parse_html("foo"))
|
||||
self.maxDiff = None
|
||||
self.assertEqual(
|
||||
# TODO: note that the blink is currently *not* correctly aborted
|
||||
# with |n here! This is probably not possible to correctly handle
|
||||
# with regex - a stateful parser may be needed.
|
||||
# blink back-cyan normal underline red green yellow blue magenta cyan back-green
|
||||
text2html.parse_html("|^|[CHello|n|u|rW|go|yr|bl|md|c!|[G!"),
|
||||
'<span class="blink">'
|
||||
'<span class="bgcolor-006">Hello</span>' # noqa
|
||||
'<span class="underline">'
|
||||
'<span class="color-009">W</span>' # noqa
|
||||
'<span class="color-010">o</span>'
|
||||
'<span class="color-011">r</span>'
|
||||
'<span class="color-012">l</span>'
|
||||
'<span class="color-013">d</span>'
|
||||
'<span class="color-014">!'
|
||||
'<span class="bgcolor-002">!</span>' # noqa
|
||||
"</span>"
|
||||
"</span>"
|
||||
"</span>",
|
||||
'<span class="blink bgcolor-006">'
|
||||
'Hello'
|
||||
'</span><span class="underline color-009">'
|
||||
'W'
|
||||
'</span><span class="underline color-010">'
|
||||
'o'
|
||||
'</span><span class="underline color-011">'
|
||||
'r'
|
||||
'</span><span class="underline color-012">'
|
||||
'l'
|
||||
'</span><span class="underline color-013">'
|
||||
'd'
|
||||
'</span><span class="underline color-014">'
|
||||
'!'
|
||||
'</span><span class="underline bgcolor-002 color-014">'
|
||||
'!'
|
||||
'</span>',
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue