Skip to content

Commit

Permalink
Added test of config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
natfarleydev committed Feb 1, 2017
1 parent 8de0c8c commit d842319
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""The purpose of this test is too test that the config and beards imports
properly before the bot is run."""
import unittest
import importlib
from skybeard.utils import PythonPathContext

import config

class TestConfig(unittest.TestCase):
def test_import_all_beards_return_None(self):
for path in config.beard_paths:
with PythonPathContext(path):
for beard in config.beards:
try:
importlib.import_module(beard)
except ImportError:
pass

# Once the modules are imported (or not), reimporting will return only
# the module. If we get an ImportError here, then one of them has gone
# wrong

successfully_imported_modules = []
import_exceptions = []
for beard in config.beards:
try:
mod = importlib.import_module(beard)
successfully_imported_modules.append(mod)
except ImportError as e:
import_exceptions.append(e)

if import_exceptions:
self.fail("We got problems: {}".format("\n".join(str(e) for e in import_exceptions)))


if __name__ == '__main__':
unittest.main()

0 comments on commit d842319

Please sign in to comment.