bots: Correctly set paths to bot modules for testing.
This commit is contained in:
parent
107bbff769
commit
94587db657
|
@ -36,8 +36,8 @@ class BotTestCase(TestCase):
|
||||||
# handler class. Eventually, we want bot's handler classes to
|
# handler class. Eventually, we want bot's handler classes to
|
||||||
# inherit from a common prototype specifying the handle_message
|
# inherit from a common prototype specifying the handle_message
|
||||||
# function.
|
# function.
|
||||||
bot_module_path = os.path.join(
|
bot_module_path = os.path.normpath(os.path.join(
|
||||||
current_dir, "bots", self.bot_name, self.bot_name + ".py")
|
current_dir, '..', 'bots', self.bot_name, self.bot_name + '.py'))
|
||||||
lib_module = get_lib_module(bot_module_path)
|
lib_module = get_lib_module(bot_module_path)
|
||||||
return lib_module.handler_class()
|
return lib_module.handler_class()
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ def get_lib_module(bots_fn):
|
||||||
print('Please use a .py extension for library files.')
|
print('Please use a .py extension for library files.')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
base_bots_fn = os.path.basename(os.path.splitext(bots_fn)[0])
|
base_bots_fn = os.path.basename(os.path.splitext(bots_fn)[0])
|
||||||
sys.path.append(os.path.dirname(bots_fn))
|
sys.path.insert(1, os.path.dirname(bots_fn))
|
||||||
module_name = base_bots_fn
|
module_name = base_bots_fn
|
||||||
module = importlib.import_module(module_name)
|
module = importlib.import_module(module_name)
|
||||||
return module
|
return module
|
||||||
|
|
Loading…
Reference in a new issue