mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
classes: fixes for the test API
- fakeirc: drop dummyhook, call hooks in run() - the protocol module doesn't do this for us anymore - Irc: don't thread if we're in test mode (temp. hack for now)
This commit is contained in:
parent
973aba6de7
commit
adb9ef13a6
18
classes.py
18
classes.py
@ -70,8 +70,12 @@ class Irc():
|
||||
|
||||
self.initVars()
|
||||
|
||||
self.connection_thread = threading.Thread(target = self.connect)
|
||||
self.connection_thread.start()
|
||||
if world.testing:
|
||||
# HACK: Don't thread if we're running tests.
|
||||
self.connect()
|
||||
else:
|
||||
self.connection_thread = threading.Thread(target = self.connect)
|
||||
self.connection_thread.start()
|
||||
self.pingTimer = None
|
||||
|
||||
def connect(self):
|
||||
@ -327,7 +331,10 @@ class FakeIRC(Irc):
|
||||
def run(self, data):
|
||||
"""Queues a message to the fake IRC server."""
|
||||
log.debug('<- ' + data)
|
||||
self.proto.handle_events(self, data)
|
||||
hook_args = self.proto.handle_events(self, data)
|
||||
if hook_args is not None:
|
||||
self.hookmsgs.append(hook_args)
|
||||
self.callHooks(hook_args)
|
||||
|
||||
def send(self, data):
|
||||
self.messages.append(data)
|
||||
@ -359,11 +366,6 @@ class FakeIRC(Irc):
|
||||
self.hookmsgs = []
|
||||
return hookmsgs
|
||||
|
||||
@staticmethod
|
||||
def dummyhook(irc, source, command, parsed_args):
|
||||
"""Dummy function to bind to hooks. This is what allows takeHooks() to work."""
|
||||
irc.hookmsgs.append(parsed_args)
|
||||
|
||||
class FakeProto():
|
||||
"""Dummy protocol module for testing purposes."""
|
||||
def __init__(self):
|
||||
|
Loading…
Reference in New Issue
Block a user