mirror of https://github.com/jesopo/irctokens
don't try to parse Line.source from Line.hostmask when it is None
This commit is contained in:
parent
c52c4143ce
commit
e41a58842b
|
@ -54,7 +54,8 @@ class Line(object):
|
|||
_hostmask: Optional[Hostmask] = None
|
||||
@property
|
||||
def hostmask(self):
|
||||
self._hostmask = self._hostmask or Hostmask(self.source)
|
||||
if self.source:
|
||||
self._hostmask = self._hostmask or Hostmask(self.source)
|
||||
return self._hostmask
|
||||
|
||||
def format(self) -> str:
|
||||
|
|
|
@ -33,3 +33,7 @@ class HostmaskTest(unittest.TestCase):
|
|||
self.assertEqual(line.hostmask.nickname, "nick")
|
||||
self.assertEqual(line.hostmask.username, "user")
|
||||
self.assertEqual(line.hostmask.hostname, "host")
|
||||
|
||||
def test_none_source(self):
|
||||
line = irctokens.tokenise("PRIVMSG #channel hello")
|
||||
self.assertIsNone(line.hostmask)
|
||||
|
|
Loading…
Reference in New Issue