raise ValueError when trying to tokenise without a command

This commit is contained in:
jesopo 2020-07-24 10:38:37 +00:00
parent e0c97963df
commit b9a2b6c1de
2 changed files with 12 additions and 0 deletions

View File

@ -85,6 +85,8 @@ def _tokenise(
if params[0][0] == ":":
source = params.pop(0)[1:]
if not params:
raise ValueError("Cannot tokenise command-less line")
command = params.pop(0).upper()
if trailing_sep:

View File

@ -76,3 +76,13 @@ class TokenTestNul(unittest.TestCase):
line = irctokens.tokenise(
":nick!user@host PRIVMSG #channel :hello\x00 world")
self.assertEqual(line.params, ["#channel", "hello"])
class TokenTestNoCommand(unittest.TestCase):
def test(self):
def _test1():
line = irctokens.tokenise(":n!u@h")
def _test2():
line = irctokens.tokenise("@tag=1 :n!u@h")
self.assertRaises(ValueError, _test1)
self.assertRaises(ValueError, _test2)