def testGetByFQNImportable(self): with utils.tempdir() as tmp: path = os.path.join(tmp, 'fluffypants') os.mkdir(path) with open(os.path.join(path, '__init__.py'), 'w') as f: f.write("\n") with open(os.path.join(path, 'happydance.py'), 'w') as f: f.write("\n") sys.path.insert(0, tmp) try: result = util.get_by_fqn('fluffypants.happydance') self.assertEqual('fluffypants.happydance', result.__name__) finally: sys.path.pop(0)
def get_callable(self, target): return util.get_by_fqn(target)
def testGetByFQNBadImport(self): self.assertRaises(ImportError, lambda: util.get_by_fqn('mandrel.fluffypants'))
def testGetByFQNGettable(self, mock_utils): result = util.get_by_fqn('mandrel.test.utils.foofy') self.assertEqual(mock_utils.foofy, result)