Ran black on branc
This commit is contained in:
parent
6effb6f456
commit
4ea6209123
230 changed files with 7108 additions and 2395 deletions
|
|
@ -37,7 +37,8 @@ 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")
|
||||
|
|
@ -63,10 +64,15 @@ 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")
|
||||
|
|
@ -88,7 +94,10 @@ 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"),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -178,7 +187,10 @@ 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")
|
||||
|
|
@ -195,7 +207,10 @@ 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")
|
||||
|
|
@ -208,7 +223,8 @@ 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,7 +38,9 @@ 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(),
|
||||
|
|
@ -69,18 +71,33 @@ 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\n:"
|
||||
self.char1.ndb._eveditor.get_buffer(), "First test line\nSecond test line"
|
||||
)
|
||||
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.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(), "", 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(),
|
||||
|
|
@ -96,17 +113,24 @@ 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(),
|
||||
|
|
@ -121,11 +145,15 @@ 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(
|
||||
|
|
@ -168,9 +196,9 @@ class TestEvEditor(CommandTest):
|
|||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(),
|
||||
"First test \"line\".",
|
||||
raw_string="First test \"line\".",
|
||||
msg="01First test \"line\" .",
|
||||
'First test "line".',
|
||||
raw_string='First test "line".',
|
||||
msg='01First test "line" .',
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(),
|
||||
|
|
@ -178,7 +206,10 @@ class TestEvEditor(CommandTest):
|
|||
raw_string="Second 'line'.",
|
||||
msg="02Second 'line' .",
|
||||
)
|
||||
self.assertEqual(self.char1.ndb._eveditor.get_buffer(), "First test \"line\".\nSecond 'line'.")
|
||||
self.assertEqual(
|
||||
self.char1.ndb._eveditor.get_buffer(),
|
||||
"First test \"line\".\nSecond 'line'.",
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
"",
|
||||
|
|
@ -196,19 +227,13 @@ class TestEvEditor(CommandTest):
|
|||
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.",
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 2.",
|
||||
raw_string="line 2.",
|
||||
msg="02line 2.",
|
||||
eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 3.",
|
||||
raw_string="line 3.",
|
||||
msg="03line 3.",
|
||||
eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -222,16 +247,18 @@ 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)
|
||||
|
|
@ -242,19 +269,13 @@ class TestEvEditor(CommandTest):
|
|||
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.",
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 2.",
|
||||
raw_string="line 2.",
|
||||
msg="02line 2.",
|
||||
eveditor.CmdLineInput(), "line 2.", raw_string="line 2.", msg="02line 2."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdLineInput(), "line 3.",
|
||||
raw_string="line 3.",
|
||||
msg="03line 3.",
|
||||
eveditor.CmdLineInput(), "line 3.", raw_string="line 3.", msg="03line 3."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -273,9 +294,7 @@ class TestEvEditor(CommandTest):
|
|||
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",
|
||||
eveditor.CmdLineInput(), "line 1", raw_string="line 1", msg="01line 1"
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
@ -294,25 +313,11 @@ class TestEvEditor(CommandTest):
|
|||
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(), "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",
|
||||
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",
|
||||
|
|
@ -346,9 +351,7 @@ class TestEvEditor(CommandTest):
|
|||
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.",
|
||||
eveditor.CmdLineInput(), "line 1.", raw_string="line 1.", msg="01line 1."
|
||||
)
|
||||
self.call(
|
||||
eveditor.CmdEditorGroup(),
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ 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
|
||||
|
|
@ -97,7 +99,9 @@ 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:
|
||||
|
|
@ -143,7 +147,9 @@ 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)
|
||||
|
|
@ -156,7 +162,9 @@ 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,7 +32,27 @@ 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,
|
||||
|
|
@ -82,7 +102,9 @@ 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]
|
||||
|
|
@ -163,7 +185,30 @@ 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):
|
||||
|
|
@ -173,8 +218,12 @@ 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)
|
||||
|
||||
|
||||
|
|
@ -230,7 +279,9 @@ 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>",
|
||||
)
|
||||
|
|
@ -245,7 +296,8 @@ 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>',
|
||||
|
|
@ -313,7 +365,9 @@ 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.",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,19 +7,30 @@ import mock
|
|||
|
||||
|
||||
class TestText2Html(TestCase):
|
||||
|
||||
def test_re_color(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
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"))
|
||||
'<span class="color-001">red</span>foo',
|
||||
parser.re_color(
|
||||
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"))
|
||||
'<span class="bgcolor-001">red</span>foo',
|
||||
parser.re_color(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(ansi.ANSI_BACK_RED + ansi.ANSI_UNHILITE + ansi.ANSI_GREEN + "red" + ansi.ANSI_NORMAL + "foo"))
|
||||
'<span class="bgcolor-001"><span class="color-002">red</span></span>foo',
|
||||
parser.re_color(
|
||||
ansi.ANSI_BACK_RED
|
||||
+ ansi.ANSI_UNHILITE
|
||||
+ ansi.ANSI_GREEN
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_re_bold(self):
|
||||
|
|
@ -29,40 +40,54 @@ class TestText2Html(TestCase):
|
|||
# "a <strong>red</strong>foo", # TODO: why not?
|
||||
"a <strong>redfoo</strong>",
|
||||
parser.re_bold(
|
||||
"a " + ansi.ANSI_HILITE + "red" + ansi.ANSI_UNHILITE + "foo"))
|
||||
"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",
|
||||
'a <span class="underline">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_underline(
|
||||
"a " + ansi.ANSI_UNDERLINE + "red"
|
||||
"a "
|
||||
+ ansi.ANSI_UNDERLINE
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ "foo"))
|
||||
+ "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",
|
||||
'a <span class="blink">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_blinking(
|
||||
"a " + ansi.ANSI_BLINK + "red"
|
||||
"a "
|
||||
+ ansi.ANSI_BLINK
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ "foo"))
|
||||
+ "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",
|
||||
'a <span class="inverse">red</span>' + ansi.ANSI_NORMAL + "foo",
|
||||
parser.re_inversing(
|
||||
"a " + ansi.ANSI_INVERSE + "red"
|
||||
"a "
|
||||
+ ansi.ANSI_INVERSE
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ "foo"))
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
@unittest.skip("parser issues")
|
||||
def test_remove_bells(self):
|
||||
|
|
@ -71,38 +96,40 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual(
|
||||
"a red" + ansi.ANSI_NORMAL + "foo",
|
||||
parser.remove_bells(
|
||||
"a " + ansi.ANSI_BEEP + "red"
|
||||
"a "
|
||||
+ ansi.ANSI_BEEP
|
||||
+ "red"
|
||||
+ ansi.ANSI_NORMAL # TODO: why does it keep it?
|
||||
+ "foo"))
|
||||
+ "foo"
|
||||
),
|
||||
)
|
||||
|
||||
def test_remove_backspaces(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.remove_backspaces("foo"))
|
||||
self.assertEqual("redfoo",
|
||||
parser.remove_backspaces("a\010redfoo"))
|
||||
self.assertEqual("redfoo", parser.remove_backspaces("a\010redfoo"))
|
||||
|
||||
def test_convert_linebreaks(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.convert_linebreaks("foo"))
|
||||
self.assertEqual(
|
||||
"a<br> redfoo<br>",
|
||||
parser.convert_linebreaks("a\n redfoo\n"))
|
||||
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"))
|
||||
self.assertEqual(
|
||||
"a <a href=\"http://redfoo\" target=\"_blank\">http://redfoo</a> runs",
|
||||
parser.convert_urls("a http://redfoo runs"))
|
||||
# TODO: doesn't URL encode correctly
|
||||
'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_re_double_space(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
self.assertEqual("foo", parser.re_double_space("foo"))
|
||||
self.assertEqual(
|
||||
"a red foo",
|
||||
parser.re_double_space("a red foo"))
|
||||
"a red foo", parser.re_double_space("a red foo")
|
||||
)
|
||||
|
||||
def test_sub_mxp_links(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
|
|
@ -112,63 +139,47 @@ class TestText2Html(TestCase):
|
|||
r"""<a id="mxplink" href="#" """
|
||||
"""onclick="Evennia.msg("text",["cmd"],{});"""
|
||||
"""return false;">text</a>""",
|
||||
parser.sub_mxp_links(mocked_match))
|
||||
parser.sub_mxp_links(mocked_match),
|
||||
)
|
||||
|
||||
def test_sub_text(self):
|
||||
parser = text2html.HTML_PARSER
|
||||
mocked_match = mock.Mock()
|
||||
mocked_match.groupdict.return_value = {
|
||||
"htmlchars": "foo"
|
||||
}
|
||||
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": "foo"}
|
||||
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"
|
||||
"firstspace": "foo",
|
||||
}
|
||||
self.assertEqual(
|
||||
" ",
|
||||
parser.sub_text(mocked_match))
|
||||
self.assertEqual(" ", parser.sub_text(mocked_match))
|
||||
parser.tabstop = 2
|
||||
mocked_match.groupdict.return_value = {
|
||||
"htmlchars": "",
|
||||
"lineend": "",
|
||||
"firstspace": "",
|
||||
"space": "\t"
|
||||
"space": "\t",
|
||||
}
|
||||
self.assertEqual(
|
||||
" ",
|
||||
parser.sub_text(mocked_match))
|
||||
self.assertEqual(" ", parser.sub_text(mocked_match))
|
||||
mocked_match.groupdict.return_value = {
|
||||
"htmlchars": "",
|
||||
"lineend": "",
|
||||
"firstspace": "",
|
||||
"space": " ",
|
||||
"spacestart": " "
|
||||
"spacestart": " ",
|
||||
}
|
||||
mocked_match.group.return_value = " \t "
|
||||
self.assertEqual(
|
||||
" ",
|
||||
parser.sub_text(mocked_match))
|
||||
self.assertEqual(" ", parser.sub_text(mocked_match))
|
||||
mocked_match.groupdict.return_value = {
|
||||
"htmlchars": "",
|
||||
"lineend": "",
|
||||
"firstspace": "",
|
||||
"space": "",
|
||||
"spacestart": ""
|
||||
"spacestart": "",
|
||||
}
|
||||
self.assertEqual(
|
||||
None,
|
||||
parser.sub_text(mocked_match))
|
||||
self.assertEqual(None, parser.sub_text(mocked_match))
|
||||
|
||||
def test_parse_html(self):
|
||||
self.assertEqual("foo", text2html.parse_html("foo"))
|
||||
|
|
@ -176,12 +187,24 @@ class TestText2Html(TestCase):
|
|||
self.assertEqual(
|
||||
"""<span class="blink"><span class="bgcolor-006">Hello </span><span class="underline"><span class="err">W</span><span class="err">o</span><span class="err">r</span><span class="err">l</span><span class="err">d</span><span class="err">!<span class="bgcolor-002">!</span></span></span></span>""",
|
||||
text2html.parse_html(
|
||||
ansi.ANSI_BLINK + ansi.ANSI_BACK_CYAN + "Hello " + ansi.ANSI_NORMAL
|
||||
+ ansi.ANSI_UNDERLINE + ansi.ANSI_RED + "W"
|
||||
+ ansi.ANSI_GREEN + "o"
|
||||
+ ansi.ANSI_YELLOW + "r"
|
||||
+ ansi.ANSI_BLUE + "l"
|
||||
+ ansi.ANSI_MAGENTA + "d"
|
||||
+ ansi.ANSI_CYAN + "!"
|
||||
+ ansi.ANSI_BACK_GREEN + "!"))
|
||||
|
||||
ansi.ANSI_BLINK
|
||||
+ ansi.ANSI_BACK_CYAN
|
||||
+ "Hello "
|
||||
+ ansi.ANSI_NORMAL
|
||||
+ ansi.ANSI_UNDERLINE
|
||||
+ ansi.ANSI_RED
|
||||
+ "W"
|
||||
+ ansi.ANSI_GREEN
|
||||
+ "o"
|
||||
+ ansi.ANSI_YELLOW
|
||||
+ "r"
|
||||
+ ansi.ANSI_BLUE
|
||||
+ "l"
|
||||
+ ansi.ANSI_MAGENTA
|
||||
+ "d"
|
||||
+ ansi.ANSI_CYAN
|
||||
+ "!"
|
||||
+ ansi.ANSI_BACK_GREEN
|
||||
+ "!"
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ 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
|
||||
|
|
@ -66,10 +68,13 @@ 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),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -157,9 +162,15 @@ 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."""
|
||||
|
|
|
|||
|
|
@ -8,20 +8,19 @@ import pytz
|
|||
|
||||
|
||||
class TestValidatorFuncs(TestCase):
|
||||
|
||||
def test_text_ok(self):
|
||||
for val in [None, -123, 'abc', 1.234, {1:True, 2:False}, ['a', 1]]:
|
||||
for val in [None, -123, "abc", 1.234, {1: True, 2: False}, ["a", 1]]:
|
||||
self.assertEqual(str(val), validatorfuncs.text(val))
|
||||
|
||||
@mock.patch('builtins.str')
|
||||
@mock.patch("builtins.str")
|
||||
def test_text_raises_ValueError(self, mocked_str):
|
||||
mocked_str.side_effect = Exception
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.text(None)
|
||||
|
||||
def test_color_ok(self):
|
||||
for color in ['r', 'g', 'b', 'H', 'R', 'M', '^']:
|
||||
self.assertEqual(color, validatorfuncs.color(color))
|
||||
for color in ["r", "g", "b", "H", "R", "M", "^"]:
|
||||
self.assertEqual(color, validatorfuncs.color(color))
|
||||
|
||||
def test_color_falsy_raises_ValueError(self):
|
||||
for color in [None, (), [], False, True, {}]:
|
||||
|
|
@ -29,126 +28,131 @@ class TestValidatorFuncs(TestCase):
|
|||
validatorfuncs.color(color)
|
||||
|
||||
def test_datetime_ok(self):
|
||||
for dt in ['Oct 12 1:00 1492', 'Jan 2 12:00 2020', 'Dec 31 00:00 2018']:
|
||||
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):
|
||||
for dt in ['', 'January 1, 2019', '1/1/2019', 'Jan 1 2019']:
|
||||
for dt in ["", "January 1, 2019", "1/1/2019", "Jan 1 2019"]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.datetime(dt)
|
||||
|
||||
def test_duration_ok(self):
|
||||
for d in ['1d', '2w', '3h', '4s', '5m', '6y']:
|
||||
self.assertTrue(
|
||||
isinstance(validatorfuncs.duration(d), datetime.timedelta))
|
||||
for d in ["1d", "2w", "3h", "4s", "5m", "6y"]:
|
||||
self.assertTrue(isinstance(validatorfuncs.duration(d), datetime.timedelta))
|
||||
|
||||
self.assertEqual(
|
||||
datetime.timedelta(1+6*365, 2, 0, 0, 3, 4, 5),
|
||||
validatorfuncs.duration('1d 2s 3m 4h 5w 6y'))
|
||||
datetime.timedelta(1 + 6 * 365, 2, 0, 0, 3, 4, 5),
|
||||
validatorfuncs.duration("1d 2s 3m 4h 5w 6y"),
|
||||
)
|
||||
# values may be duplicated
|
||||
self.assertEqual(
|
||||
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'))
|
||||
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"),
|
||||
)
|
||||
|
||||
def test_duration_raises_ValueError(self):
|
||||
for d in ['', '1', '5days', '1Week']:
|
||||
for d in ["", "1", "5days", "1Week"]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.duration(d)
|
||||
|
||||
def test_future_ok(self):
|
||||
year = int(datetime.datetime.utcnow().strftime("%Y"))
|
||||
for f in [f'Jan 2 12:00 {year+1}', f'Dec 31 00:00 {year+1}']:
|
||||
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):
|
||||
year = int(datetime.datetime.utcnow().strftime("%Y"))
|
||||
for f in [f'Jan 2 12:00 {year-1}', f'Dec 31 00:00 {year-1}']:
|
||||
for f in [f"Jan 2 12:00 {year-1}", f"Dec 31 00:00 {year-1}"]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.future(f, from_tz=pytz.UTC)
|
||||
|
||||
def test_signed_integer_ok(self):
|
||||
for si in ['123', '4567890', '001', '-123', '-45', '0']:
|
||||
self.assertEqual(int(si), validatorfuncs.signed_integer(si))
|
||||
for si in ["123", "4567890", "001", "-123", "-45", "0"]:
|
||||
self.assertEqual(int(si), validatorfuncs.signed_integer(si))
|
||||
|
||||
@mock.patch('builtins.int')
|
||||
@mock.patch("builtins.int")
|
||||
def test_signed_integer_raises_ValueError(self, mocked_int):
|
||||
for si in ['', '000', 'abc']:
|
||||
for si in ["", "000", "abc"]:
|
||||
mocked_int.side_effect = ValueError
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.signed_integer(si)
|
||||
|
||||
def test_positive_integer_ok(self):
|
||||
for pi in ['123', '4567890', '001']:
|
||||
self.assertEqual(int(pi), validatorfuncs.positive_integer(pi))
|
||||
for pi in ["123", "4567890", "001"]:
|
||||
self.assertEqual(int(pi), validatorfuncs.positive_integer(pi))
|
||||
|
||||
@mock.patch('builtins.int')
|
||||
@mock.patch("builtins.int")
|
||||
def test_positive_integer_raises_ValueError(self, mocked_int):
|
||||
mocked_int.return_value = -1
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.positive_integer(str(-1))
|
||||
for pi in ['', '000', 'abc', '-1']:
|
||||
for pi in ["", "000", "abc", "-1"]:
|
||||
mocked_int.side_effect = ValueError
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.positive_integer(pi)
|
||||
|
||||
def test_unsigned_integer_ok(self):
|
||||
for ui in ['123', '4567890', '001', '0']:
|
||||
self.assertEqual(int(ui), validatorfuncs.unsigned_integer(ui))
|
||||
for ui in ["123", "4567890", "001", "0"]:
|
||||
self.assertEqual(int(ui), validatorfuncs.unsigned_integer(ui))
|
||||
|
||||
@mock.patch('builtins.int')
|
||||
@mock.patch("builtins.int")
|
||||
def test_unsigned_integer_raises_ValueError(self, mocked_int):
|
||||
mocked_int.return_value = -1
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.unsigned_integer(str(-1))
|
||||
for ui in ['', '000', 'abc', '-1', '0']:
|
||||
for ui in ["", "000", "abc", "-1", "0"]:
|
||||
mocked_int.side_effect = ValueError
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.unsigned_integer(ui)
|
||||
|
||||
def test_boolean(self):
|
||||
for b in ['true', '1', 'on', 'ENABLED']:
|
||||
for b in ["true", "1", "on", "ENABLED"]:
|
||||
self.assertTrue(validatorfuncs.boolean(b))
|
||||
for b in ['FalSe', '0', 'oFF', 'disabled']:
|
||||
for b in ["FalSe", "0", "oFF", "disabled"]:
|
||||
self.assertFalse(validatorfuncs.boolean(b))
|
||||
|
||||
def test_boolean_raises_ValueError(self):
|
||||
for b in ['', None, 1, 0, True, False, [None], {True:True}]:
|
||||
for b in ["", None, 1, 0, True, False, [None], {True: True}]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.boolean(b)
|
||||
|
||||
def test_timezone_ok(self):
|
||||
for tz in ['America/Chicago', 'GMT', 'UTC']:
|
||||
for tz in ["America/Chicago", "GMT", "UTC"]:
|
||||
self.assertEqual(tz, validatorfuncs.timezone(tz).zone)
|
||||
|
||||
def test_timezone_raises_ValueError(self):
|
||||
for tz in ['America', None, '', 'Mars', 'DT']:
|
||||
for tz in ["America", None, "", "Mars", "DT"]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.timezone(tz)
|
||||
|
||||
def test_email_ok(self):
|
||||
for e in ['a@a.aa', 'zeus@olympus.net']:
|
||||
for e in ["a@a.aa", "zeus@olympus.net"]:
|
||||
self.assertEqual(e, validatorfuncs.email(e))
|
||||
|
||||
def test_email_raises_ValueError(self):
|
||||
for e in ['', None, ['abc@abc.com'], 123]:
|
||||
for e in ["", None, ["abc@abc.com"], 123]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.email(e)
|
||||
|
||||
def test_lock_ok(self):
|
||||
for l in ['do:true;look:no', 'a:t']:
|
||||
for l in ["do:true;look:no", "a:t"]:
|
||||
self.assertEqual(l, validatorfuncs.lock(l))
|
||||
|
||||
def test_lock_raises_ValueError(self):
|
||||
for l in [';;;', '', ':', ':::', ';:;:', 'x:', ':y']:
|
||||
for l in [";;;", "", ":", ":::", ";:;:", "x:", ":y"]:
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.lock(l)
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.lock('view:',
|
||||
access_options=())
|
||||
validatorfuncs.lock("view:", access_options=())
|
||||
with self.assertRaises(ValueError):
|
||||
validatorfuncs.lock('view:',
|
||||
access_options=('look'))
|
||||
validatorfuncs.lock("view:", access_options=("look"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue