Make scripts/objects lists use EvMore. Change EvMore to not justify by default.
This commit is contained in:
parent
b5aee2c41e
commit
69d85bd184
221 changed files with 2190 additions and 6810 deletions
|
|
@ -37,8 +37,7 @@ class TestBatchCommandProcessor(TestCase):
|
|||
)
|
||||
commands = batchprocessors.BATCHCMD.parse_file("foopath")
|
||||
self.assertEqual(
|
||||
["@create rock", "@set rock/desc =\nA big rock. You can tell is ancient."],
|
||||
commands,
|
||||
["@create rock", "@set rock/desc =\nA big rock. You can tell is ancient."], commands
|
||||
)
|
||||
|
||||
@mock.patch.object(batchprocessors, "read_batchfile")
|
||||
|
|
@ -64,15 +63,10 @@ class TestBatchCommandProcessor(TestCase):
|
|||
),
|
||||
]
|
||||
commands = batchprocessors.BATCHCMD.parse_file("foopath")
|
||||
self.assertEqual(
|
||||
commands, ["@create sky", "@create bird", "@create cloud", "@create sun"]
|
||||
)
|
||||
self.assertEqual(commands, ["@create sky", "@create bird", "@create cloud", "@create sun"])
|
||||
self.assertEqual(
|
||||
mocked_read.mock_calls,
|
||||
[
|
||||
mock.call("foopath", file_ending=".ev"),
|
||||
mock.call("another.ev", file_ending=".ev"),
|
||||
],
|
||||
[mock.call("foopath", file_ending=".ev"), mock.call("another.ev", file_ending=".ev")],
|
||||
)
|
||||
|
||||
@mock.patch.object(batchprocessors, "read_batchfile")
|
||||
|
|
@ -94,10 +88,7 @@ class TestBatchCommandProcessor(TestCase):
|
|||
batchprocessors.BATCHCMD.parse_file("foopath")
|
||||
self.assertEqual(
|
||||
mocked_read.mock_calls,
|
||||
[
|
||||
mock.call("foopath", file_ending=".ev"),
|
||||
mock.call("x", file_ending=".ev"),
|
||||
],
|
||||
[mock.call("foopath", file_ending=".ev"), mock.call("x", file_ending=".ev")],
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -187,10 +178,7 @@ class TestBatchCodeProcessor(TestCase):
|
|||
)
|
||||
self.assertEqual(
|
||||
mocked_read.mock_calls,
|
||||
[
|
||||
mock.call("foopath", file_ending=".py"),
|
||||
mock.call("another.py", file_ending=".py"),
|
||||
],
|
||||
[mock.call("foopath", file_ending=".py"), mock.call("another.py", file_ending=".py")],
|
||||
)
|
||||
|
||||
@mock.patch.object(batchprocessors, "read_batchfile")
|
||||
|
|
@ -207,10 +195,7 @@ class TestBatchCodeProcessor(TestCase):
|
|||
batchprocessors.BATCHCODE.parse_file("foopath")
|
||||
self.assertEqual(
|
||||
mocked_read.mock_calls,
|
||||
[
|
||||
mock.call("foopath", file_ending=".py"),
|
||||
mock.call("x", file_ending=".py"),
|
||||
],
|
||||
[mock.call("foopath", file_ending=".py"), mock.call("x", file_ending=".py")],
|
||||
)
|
||||
|
||||
@mock.patch("builtins.exec")
|
||||
|
|
@ -223,8 +208,7 @@ class TestBatchCodeProcessor(TestCase):
|
|||
@mock.patch("builtins.exec")
|
||||
def test_execs_codeblock_with_extra_environ(self, mocked_exec):
|
||||
err = batchprocessors.BATCHCODE.code_exec(
|
||||
'# batchcode code:\n\nprint("Hello")\n',
|
||||
extra_environ={"foo": "bar", "baz": True},
|
||||
'# batchcode code:\n\nprint("Hello")\n', extra_environ={"foo": "bar", "baz": True}
|
||||
)
|
||||
self.assertIsNone(err)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,9 +38,7 @@ class TestEvEditor(CommandTest):
|
|||
raw_string="Second test line",
|
||||
msg="02Second test line",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line"
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line")
|
||||
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -71,33 +69,18 @@ class TestEvEditor(CommandTest):
|
|||
)
|
||||
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"",
|
||||
cmdstring=":dd",
|
||||
msg="Deleted line 3.", # delete line
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":dd", msg="Deleted line 3." # delete line
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line")
|
||||
self.call(eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step.") # undo
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line"
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line\n:"
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step."
|
||||
) # undo
|
||||
self.call(eveditor.CmdEditorGroup(), "", cmdstring=":uu", msg="Redid one step.") # redo
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line")
|
||||
self.call(eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step.") # undo
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(),
|
||||
"First test line\nSecond test line\n:",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":uu", msg="Redid one step."
|
||||
) # redo
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line"
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step."
|
||||
) # undo
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(),
|
||||
"First test line\nSecond test line\n:",
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line\n:"
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -113,24 +96,17 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":dw", # delete by word
|
||||
msg="Removed Second for lines 1-4.",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step."
|
||||
) # undo
|
||||
self.call(eveditor.CmdEditorGroup(), "", cmdstring=":u", msg="Undid one step.") # undo
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"2 Second",
|
||||
cmdstring=":dw", # delete by word/line
|
||||
msg="Removed Second for line 2.",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\n test line\n:"
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "First test line\n test line\n:")
|
||||
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"2",
|
||||
cmdstring=":p",
|
||||
msg="Copy buffer is empty.", # paste
|
||||
eveditor.CmdEditorGroup(), "2", cmdstring=":p", msg="Copy buffer is empty." # paste
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -145,15 +121,11 @@ class TestEvEditor(CommandTest):
|
|||
msg="Pasted buffer [' test line'] to line 2.",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(),
|
||||
"First test line\n test line\n test line\n:",
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\n test line\n test line\n:"
|
||||
)
|
||||
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"3",
|
||||
cmdstring=":x",
|
||||
msg="Line 3, [' test line'] cut.", # cut
|
||||
eveditor.CmdEditorGroup(), "3", cmdstring=":x", msg="Line 3, [' test line'] cut." # cut
|
||||
)
|
||||
|
||||
self.call(
|
||||
|
|
@ -207,8 +179,7 @@ class TestEvEditor(CommandTest):
|
|||
msg="02Second 'line' .",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(),
|
||||
"First test \"line\".\nSecond 'line'.",
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test \"line\".\nSecond 'line'."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -226,15 +197,9 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":",
|
||||
msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3."
|
||||
)
|
||||
self.call(eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1.")
|
||||
self.call(eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2.")
|
||||
self.call(eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3.")
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"2:3",
|
||||
|
|
@ -247,18 +212,14 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":s",
|
||||
msg="Search-replaced line -> LINE for lines 1-2.",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "LINE 1.\nLINE 2.\nline 3."
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "LINE 1.\nLINE 2.\nline 3.")
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"line MINE",
|
||||
cmdstring=":s",
|
||||
msg="Search-replaced line -> MINE for lines 1-3.",
|
||||
)
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(), "LINE 1.\nLINE 2.\nMINE 3."
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "LINE 1.\nLINE 2.\nMINE 3.")
|
||||
|
||||
def test_eveditor_COLON_DD(self):
|
||||
eveditor.EvEditor(self.char1)
|
||||
|
|
@ -268,20 +229,11 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":",
|
||||
msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
|
||||
)
|
||||
self.call(eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1.")
|
||||
self.call(eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2.")
|
||||
self.call(eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3.")
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"",
|
||||
cmdstring=":DD",
|
||||
msg="Cleared 3 lines from buffer.",
|
||||
eveditor.CmdEditorGroup(), "", cmdstring=":DD", msg="Cleared 3 lines from buffer."
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "")
|
||||
|
||||
|
|
@ -293,15 +245,8 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":",
|
||||
msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1"
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"1:2",
|
||||
cmdstring=":f",
|
||||
msg="Flood filled lines 1-2.",
|
||||
)
|
||||
self.call(eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1")
|
||||
self.call(eveditor.CmdEditorGroup(), "1:2", cmdstring=":f", msg="Flood filled lines 1-2.")
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "line 1")
|
||||
|
||||
def test_eveditor_COLON_J(self):
|
||||
|
|
@ -312,30 +257,13 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":",
|
||||
msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1"
|
||||
)
|
||||
self.call(eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1")
|
||||
self.call(eveditor.CmdLineInput(), "l 2", raw_string="l 2", msg="02l 2")
|
||||
self.call(eveditor.CmdLineInput(), "l 3", raw_string="l 3", msg="03l 3")
|
||||
self.call(eveditor.CmdLineInput(), "l 4", raw_string="l 4", msg="04l 4")
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"2 r",
|
||||
cmdstring=":j",
|
||||
msg="Right-justified line 2.",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"3 c",
|
||||
cmdstring=":j",
|
||||
msg="Center-justified line 3.",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"4 f",
|
||||
cmdstring=":j",
|
||||
msg="Full-justified line 4.",
|
||||
)
|
||||
self.call(eveditor.CmdEditorGroup(), "2 r", cmdstring=":j", msg="Right-justified line 2.")
|
||||
self.call(eveditor.CmdEditorGroup(), "3 c", cmdstring=":j", msg="Center-justified line 3.")
|
||||
self.call(eveditor.CmdEditorGroup(), "4 f", cmdstring=":j", msg="Full-justified line 4.")
|
||||
l1, l2, l3, l4 = tuple(self.char1.ndb._eveditor.get_buffer().split("\n"))
|
||||
self.assertEqual(l1, "line 1")
|
||||
self.assertEqual(l2, " " * 75 + "l 2")
|
||||
|
|
@ -350,9 +278,7 @@ class TestEvEditor(CommandTest):
|
|||
cmdstring=":",
|
||||
msg="Line Editor []\n01\n[l:01 w:000 c:0000](:h for help)",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1.")
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"",
|
||||
|
|
|
|||
|
|
@ -81,9 +81,7 @@ class TestEvMenu(TestCase):
|
|||
node_text = menu.test_nodetext
|
||||
self.assertIsNotNone(
|
||||
bool(node_text),
|
||||
"node: {}: node-text is None, which was not expected.".format(
|
||||
nodename
|
||||
),
|
||||
"node: {}: node-text is None, which was not expected.".format(nodename),
|
||||
)
|
||||
if isinstance(node_text, tuple):
|
||||
node_text, helptext = node_text
|
||||
|
|
@ -99,9 +97,7 @@ class TestEvMenu(TestCase):
|
|||
self.assertEqual(
|
||||
len(options),
|
||||
compare_options_count,
|
||||
"Not the right number of options returned from node {}.".format(
|
||||
nodename
|
||||
),
|
||||
"Not the right number of options returned from node {}.".format(nodename),
|
||||
)
|
||||
compare_options = self.expected_node_options.get(nodename, None)
|
||||
if compare_options:
|
||||
|
|
@ -147,9 +143,7 @@ class TestEvMenu(TestCase):
|
|||
|
||||
if menu.close_menu.called:
|
||||
# this was an end node
|
||||
self._debug_output(
|
||||
indent, " .. menu exited! Back to previous node."
|
||||
)
|
||||
self._debug_output(indent, " .. menu exited! Back to previous node.")
|
||||
menu = backup_menu
|
||||
menu.close_menu = MagicMock()
|
||||
visited.append(nodename)
|
||||
|
|
@ -162,9 +156,7 @@ class TestEvMenu(TestCase):
|
|||
else:
|
||||
subtree.append(nodename)
|
||||
# self._debug_output( indent, " -> arrived at {} (circular call)".format(nodename))
|
||||
self._debug_output(
|
||||
indent, "-- {} ({}) -> {}".format(key, desc, goto)
|
||||
)
|
||||
self._debug_output(indent, "-- {} ({}) -> {}".format(key, desc, goto))
|
||||
|
||||
if subtree:
|
||||
tree.append(subtree)
|
||||
|
|
|
|||
|
|
@ -32,27 +32,7 @@ class ANSIStringTestCase(TestCase):
|
|||
clean = "This isA|r testTest"
|
||||
encoded = "\x1b[1m\x1b[32mThis is\x1b[1m\x1b[31mA|r test\x1b[0mTest\x1b[0m"
|
||||
target = ANSIString(r"|gThis is|rA||r test|nTest|n")
|
||||
char_table = [
|
||||
9,
|
||||
10,
|
||||
11,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
25,
|
||||
26,
|
||||
27,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
32,
|
||||
37,
|
||||
38,
|
||||
39,
|
||||
40,
|
||||
]
|
||||
char_table = [9, 10, 11, 12, 13, 14, 15, 25, 26, 27, 28, 29, 30, 31, 32, 37, 38, 39, 40]
|
||||
code_table = [
|
||||
0,
|
||||
1,
|
||||
|
|
@ -102,9 +82,7 @@ class ANSIStringTestCase(TestCase):
|
|||
result = target[:4]
|
||||
self.checker(result, "\x1b[1m\x1b[32mTest\x1b[1m\x1b[31m", "Test")
|
||||
result = target[:]
|
||||
self.checker(
|
||||
result, "\x1b[1m\x1b[32mTest\x1b[1m\x1b[31mTest\x1b[0m", "TestTest"
|
||||
)
|
||||
self.checker(result, "\x1b[1m\x1b[32mTest\x1b[1m\x1b[31mTest\x1b[0m", "TestTest")
|
||||
result = target[:-1]
|
||||
self.checker(result, "\x1b[1m\x1b[32mTest\x1b[1m\x1b[31mTes", "TestTes")
|
||||
result = target[0:0]
|
||||
|
|
@ -185,30 +163,7 @@ class ANSIStringTestCase(TestCase):
|
|||
result = "\x1b[1m\x1b[32mTest\x1b[1m\x1b[36mString\x1b[0m"
|
||||
self.checker(c, result, "TestString")
|
||||
char_table = [9, 10, 11, 12, 22, 23, 24, 25, 26, 27]
|
||||
code_table = [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5,
|
||||
6,
|
||||
7,
|
||||
8,
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
17,
|
||||
18,
|
||||
19,
|
||||
20,
|
||||
21,
|
||||
28,
|
||||
29,
|
||||
30,
|
||||
31,
|
||||
]
|
||||
code_table = [0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 16, 17, 18, 19, 20, 21, 28, 29, 30, 31]
|
||||
self.table_check(c, char_table, code_table)
|
||||
|
||||
def test_strip(self):
|
||||
|
|
@ -218,12 +173,8 @@ class ANSIStringTestCase(TestCase):
|
|||
a = ANSIString(" |r Test of stuff |b with spaces |n ")
|
||||
b = ANSIString("|r|b")
|
||||
self.assertEqual(a.strip(), ANSIString("|rTest of stuff |b with spaces|n"))
|
||||
self.assertEqual(
|
||||
a.lstrip(), ANSIString("|rTest of stuff |b with spaces |n ")
|
||||
)
|
||||
self.assertEqual(
|
||||
a.rstrip(), ANSIString(" |r Test of stuff |b with spaces|n")
|
||||
)
|
||||
self.assertEqual(a.lstrip(), ANSIString("|rTest of stuff |b with spaces |n "))
|
||||
self.assertEqual(a.rstrip(), ANSIString(" |r Test of stuff |b with spaces|n"))
|
||||
self.assertEqual(b.strip(), b)
|
||||
|
||||
|
||||
|
|
@ -279,9 +230,7 @@ class TestTextToHTMLparser(TestCase):
|
|||
|
||||
def test_url_chars_querystring(self):
|
||||
self.assertEqual(
|
||||
self.parser.convert_urls(
|
||||
"https://example.com/submitform?field1=val1+val3&field2=val2"
|
||||
),
|
||||
self.parser.convert_urls("https://example.com/submitform?field1=val1+val3&field2=val2"),
|
||||
'<a href="https://example.com/submitform?field1=val1+val3&field2=val2" target="_blank">'
|
||||
"https://example.com/submitform?field1=val1+val3&field2=val2</a>",
|
||||
)
|
||||
|
|
@ -296,8 +245,7 @@ class TestTextToHTMLparser(TestCase):
|
|||
def test_url_chars_exclam(self):
|
||||
self.assertEqual(
|
||||
self.parser.convert_urls(
|
||||
"https://groups.google.com/forum/"
|
||||
"?fromgroups#!categories/evennia/ainneve"
|
||||
"https://groups.google.com/forum/" "?fromgroups#!categories/evennia/ainneve"
|
||||
),
|
||||
'<a href="https://groups.google.com/forum/?fromgroups#!categories/evennia/ainneve"'
|
||||
' target="_blank">https://groups.google.com/forum/?fromgroups#!categories/evennia/ainneve</a>',
|
||||
|
|
@ -365,9 +313,7 @@ class TestInlineFuncs(TestCase):
|
|||
|
||||
def test_single_func(self):
|
||||
self.assertEqual(
|
||||
inlinefuncs.parse_inlinefunc(
|
||||
"this is a test with $pad(centered, 20) text in it."
|
||||
),
|
||||
inlinefuncs.parse_inlinefunc("this is a test with $pad(centered, 20) text in it."),
|
||||
"this is a test with centered text in it.",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual("foo", parser.re_color("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.re_color(ansi.ANSI_UNHILITE + ansi.ANSI_RED + "red" + ansi.ANSI_NORMAL + "foo"),
|
||||
)
|
||||
self.assertEqual(
|
||||
'<span class="bgcolor-001">red</span>foo',
|
||||
|
|
@ -39,9 +37,7 @@ class TestText2Html(TestCase):
|
|||
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"
|
||||
),
|
||||
parser.re_bold("a " + ansi.ANSI_HILITE + "red" + ansi.ANSI_UNHILITE + "foo"),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
|
|
@ -149,11 +145,7 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual("foo", parser.sub_text(mocked_match))
|
||||
mocked_match.groupdict.return_value = {"htmlchars": "", "lineend": "foo"}
|
||||
self.assertEqual("<br>", parser.sub_text(mocked_match))
|
||||
mocked_match.groupdict.return_value = {
|
||||
"htmlchars": "",
|
||||
"lineend": "",
|
||||
"firstspace": "foo",
|
||||
}
|
||||
mocked_match.groupdict.return_value = {"htmlchars": "", "lineend": "", "firstspace": "foo"}
|
||||
self.assertEqual(" ", parser.sub_text(mocked_match))
|
||||
parser.tabstop = 2
|
||||
mocked_match.groupdict.return_value = {
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ class TestCrop(TestCase):
|
|||
# No text, return no text
|
||||
self.assertEqual("", utils.crop("", width=10, suffix="[...]"))
|
||||
# Input length equal to max width, no crop
|
||||
self.assertEqual(
|
||||
"0123456789", utils.crop("0123456789", width=10, suffix="[...]")
|
||||
)
|
||||
self.assertEqual("0123456789", utils.crop("0123456789", width=10, suffix="[...]"))
|
||||
# Input length greater than max width, crop (suffix included in width)
|
||||
self.assertEqual("0123[...]", utils.crop("0123456789", width=9, suffix="[...]"))
|
||||
# Input length less than desired width, no crop
|
||||
|
|
@ -68,13 +66,10 @@ class TestListToString(TestCase):
|
|||
|
||||
def test_list_to_string(self):
|
||||
self.assertEqual("1, 2, 3", utils.list_to_string([1, 2, 3], endsep=""))
|
||||
self.assertEqual(
|
||||
'"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep="", addquote=True)
|
||||
)
|
||||
self.assertEqual('"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep="", addquote=True))
|
||||
self.assertEqual("1, 2 and 3", utils.list_to_string([1, 2, 3]))
|
||||
self.assertEqual(
|
||||
'"1", "2" and "3"',
|
||||
utils.list_to_string([1, 2, 3], endsep="and", addquote=True),
|
||||
'"1", "2" and "3"', utils.list_to_string([1, 2, 3], endsep="and", addquote=True)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -162,15 +157,9 @@ class TestTimeformat(TestCase):
|
|||
self.assertEqual(utils.time_format(3600, 3), "1 hour, 0 minutes")
|
||||
self.assertEqual(utils.time_format(3725, 3), "1 hour, 2 minutes 5 seconds")
|
||||
self.assertEqual(utils.time_format(86350, 3), "23 hours, 59 minutes 10 seconds")
|
||||
self.assertEqual(
|
||||
utils.time_format(86800, 3), "1 day, 0 hours, 6 minutes 40 seconds"
|
||||
)
|
||||
self.assertEqual(
|
||||
utils.time_format(130800, 3), "1 day, 12 hours, 20 minutes 0 seconds"
|
||||
)
|
||||
self.assertEqual(
|
||||
utils.time_format(530800, 3), "6 days, 3 hours, 26 minutes 40 seconds"
|
||||
)
|
||||
self.assertEqual(utils.time_format(86800, 3), "1 day, 0 hours, 6 minutes 40 seconds")
|
||||
self.assertEqual(utils.time_format(130800, 3), "1 day, 12 hours, 20 minutes 0 seconds")
|
||||
self.assertEqual(utils.time_format(530800, 3), "6 days, 3 hours, 26 minutes 40 seconds")
|
||||
|
||||
def test_style_4(self):
|
||||
"""Test the style 4 of time_format."""
|
||||
|
|
|
|||
|
|
@ -30,9 +30,7 @@ class TestValidatorFuncs(TestCase):
|
|||
def test_datetime_ok(self):
|
||||
for dt in ["Oct 12 1:00 1492", "Jan 2 12:00 2020", "Dec 31 00:00 2018"]:
|
||||
self.assertTrue(
|
||||
isinstance(
|
||||
validatorfuncs.datetime(dt, from_tz=pytz.UTC), datetime.datetime
|
||||
)
|
||||
isinstance(validatorfuncs.datetime(dt, from_tz=pytz.UTC), datetime.datetime)
|
||||
)
|
||||
|
||||
def test_datetime_raises_ValueError(self):
|
||||
|
|
@ -50,9 +48,7 @@ class TestValidatorFuncs(TestCase):
|
|||
)
|
||||
# values may be duplicated
|
||||
self.assertEqual(
|
||||
datetime.timedelta(
|
||||
(1 + 7) + (6 + 12) * 365, 2 + 8, 0, 0, 3 + 9, 4 + 10, 5 + 11
|
||||
),
|
||||
datetime.timedelta((1 + 7) + (6 + 12) * 365, 2 + 8, 0, 0, 3 + 9, 4 + 10, 5 + 11),
|
||||
validatorfuncs.duration("1d 2s 3m 4h 5w 6y 7d 8s 9m 10h 11w 12y"),
|
||||
)
|
||||
|
||||
|
|
@ -65,9 +61,7 @@ class TestValidatorFuncs(TestCase):
|
|||
year = int(datetime.datetime.utcnow().strftime("%Y"))
|
||||
for f in [f"Jan 2 12:00 {year+1}", f"Dec 31 00:00 {year+1}"]:
|
||||
self.assertTrue(
|
||||
isinstance(
|
||||
validatorfuncs.future(f, from_tz=pytz.UTC), datetime.datetime
|
||||
)
|
||||
isinstance(validatorfuncs.future(f, from_tz=pytz.UTC), datetime.datetime)
|
||||
)
|
||||
|
||||
def test_future_raises_ValueError(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue