def test_getInfosDictFromPlugin(self): analyzer = PluginFileAnalyzerWithInfoFile("mouf") info_dict,cf_parser = analyzer.getInfosDictFromPlugin(self.plugin_directory, os.path.basename(self.yapsy_plugin_path)) self.assertEqual(info_dict, {'website': 'http://mathbench.sourceforge.net', 'description': 'A simple plugin usefull for basic testing', 'author': 'Thibauld Nion', 'version': '0.1', 'path': '%s' % os.path.join(self.plugin_directory,"SimplePlugin"), 'name': 'Simple Plugin', 'copyright': '2014'}) self.assertTrue(isinstance(cf_parser,ConfigParser))
def getInfosDictFromPlugin(self, dirpath, filename): path = os.path.join(dirpath, filename) key = "%s_get_docstring" % os.path.splitext(filename)[0] log.debug(path) module = None infos = None, None try: module = imp.load_source(key, path) docstring = module.__doc__ infos = PluginFileAnalyzerWithInfoFile.getInfosDictFromPlugin( self, path, StringIO(docstring)) except Exception as e: log.debug(e) finally: if not module is None: del module if key in sys.modules: del sys.modules[key] return infos
def test_getInfosDictFromPlugin(self): analyzer = PluginFileAnalyzerWithInfoFile("mouf") info_dict,cf_parser = analyzer.getInfosDictFromPlugin(self.plugin_directory, os.path.basename(self.yapsy_plugin_path)) self.assertEqual(info_dict,{'website': 'http://mathbench.sourceforge.net', 'description': 'A simple plugin usefull for basic testing', 'author': 'Thibauld Nion', 'version': '0.1', 'path': '%s/SimplePlugin' % self.plugin_directory, 'name': 'Simple Plugin', 'copyright': '2014'}) self.assertTrue(isinstance(cf_parser,ConfigParser))