def setUp(self): self.tmp_dir = './tmp' if not os.path.exists(self.tmp_dir): os.mkdir(self.tmp_dir) self.path = MethodPath() with suppress_stderr(): # silence 'MESS.DB created' message self.path._db = MessDB(database='%s/test.db' % self.tmp_dir) self.path._graph = DirectedGraph()
def test_load_method(self): class DB(object): def dummy(): pass db = DB() with self.assertRaises(SystemExit) as context: with suppress_stderr(): utils.load_method('not_a_valid_method', DB()) self.assertRegexpMatches(context.exception.message, 'not a valid method') sys.path.insert(1, os.path.join(os.path.dirname(__file__), '../..')) method = utils.load_method('_import', DB()) self.assertRegexpMatches(str(method), 'import')
def setUp(self): self.tmp_dir = './tmp' if not os.path.exists(self.tmp_dir): os.mkdir(self.tmp_dir) with suppress_stderr(): # silence 'MESS.DB created' message self.db = MessDB(database='%s/test.db' % self.tmp_dir)