mirror of https://github.com/jesopo/irctokens
raise ValueError when trying to tokenise without a command
This commit is contained in:
parent
e0c97963df
commit
b9a2b6c1de
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue