mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Proxyfy MegaHAL and rexrite a (still broken) test case
This commit is contained in:
parent
07710b47ce
commit
cbc129417a
@ -29,12 +29,13 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
|
||||||
import random
|
import random
|
||||||
from cStringIO import StringIO
|
import supybot.conf as conf
|
||||||
import mh_python as megahal
|
import mh_python as megahal
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
from cStringIO import StringIO
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
@ -57,13 +58,23 @@ class MegaHAL(callbacks.Plugin):
|
|||||||
callBefore = ['Dunno']
|
callBefore = ['Dunno']
|
||||||
|
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
|
# Call Supybot's scripts
|
||||||
self.__parent = super(MegaHAL, self)
|
self.__parent = super(MegaHAL, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
# UTILISER UN CHANGEMENT DE RÉPERTOIRE DE TRAVAIL !
|
|
||||||
stdout = sys.stdout
|
# Save state
|
||||||
sys.stdout = StringIO() # Don't display MegaHAL welcome message twice
|
saved = (sys.stdout, os.getcwd())
|
||||||
|
|
||||||
|
# Create proxy for MegaHAL
|
||||||
|
os.chdir(conf.supybot.directories.data())
|
||||||
|
sys.stdout = StringIO()
|
||||||
|
|
||||||
|
# Initialize MegaHAL
|
||||||
megahal.initbrain()
|
megahal.initbrain()
|
||||||
sys.stdout = stdout
|
|
||||||
|
# Restore state
|
||||||
|
sys.stdout, cwd = saved
|
||||||
|
os.chdir(cwd)
|
||||||
|
|
||||||
random.seed()
|
random.seed()
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class MegaHALTestCase(PluginTestCase):
|
|||||||
self.assertNotError('cleanup')
|
self.assertNotError('cleanup')
|
||||||
|
|
||||||
def testAnswer(self):
|
def testAnswer(self):
|
||||||
self.assertNotError('foo')
|
self.assertNotRegexp('foo', '.*not a valid.*')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
|
||||||
|
Loading…
Reference in New Issue
Block a user