summaryrefslogtreecommitdiffstats
path: root/tests/HosterPluginTester.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/HosterPluginTester.py')
-rw-r--r--tests/HosterPluginTester.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/tests/HosterPluginTester.py b/tests/HosterPluginTester.py
index 32b67d93e..bc802ec18 100644
--- a/tests/HosterPluginTester.py
+++ b/tests/HosterPluginTester.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
+import __main__
+
from os import remove
from os.path import dirname
from logging import log, DEBUG
@@ -19,7 +21,6 @@ from module.utils.fs import save_join, join, exists
DL_DIR = join("Downloads", "tmp")
class HosterPluginTester(PluginTester):
-
files = {}
def setUp(self):
@@ -31,7 +32,6 @@ class HosterPluginTester(PluginTester):
@nottest
def test_plugin(self, name, url, flag):
-
# Print to stdout to see whats going on
print "%s: %s, %s" % (name, url, flag)
log(DEBUG, "%s: %s, %s", name, url, flag)
@@ -47,13 +47,12 @@ class HosterPluginTester(PluginTester):
a = time()
pyfile.plugin.preprocessing(self.thread)
- log(DEBUG, "downloading took %ds" % (time()-a))
+ log(DEBUG, "downloading took %ds" % (time() - a))
log(DEBUG, "size %d kb" % (pyfile.size / 1024))
if flag == "offline":
raise Exception("No offline Exception raised.")
-
if pyfile.name not in self.files:
raise Exception("Filename %s not recognized." % pyfile.name)
@@ -103,26 +102,38 @@ for l in links:
name, hash = l.rsplit(" ", 1)
HosterPluginTester.files[name] = hash
-
hoster, c = c.pluginManager.parseUrls(urls)
plugins = accumulate(hoster)
for plugin, urls in plugins.iteritems():
+ # closure functions to retain local scope
+ def meta_class(plugin):
+ class _testerClass(HosterPluginTester):
+ pass
+ _testerClass.__name__ = plugin
+ return _testerClass
- for i, url in enumerate(urls):
+ _testerClass = meta_class(plugin)
- def meta(plugin, url, flag, sig):
+ for i, url in enumerate(urls):
+ def meta(__plugin, url, flag, sig):
def _test(self):
- self.test_plugin(plugin, url, flag)
+ self.test_plugin(__plugin, url, flag)
_test.func_name = sig
return _test
tmp_flag = flags.get(url, None)
if flags.get(url, None):
- sig = "test_%s_LINK%d_%s" % (plugin, i, tmp_flag)
+ sig = "test_LINK%d_%s" % (i, tmp_flag)
else:
- sig = "test_%s_LINK%d" % (plugin, i)
+ sig = "test_LINK%d" % i
+
+ # set test method
+ setattr(_testerClass, sig, meta(plugin, url, tmp_flag, sig))
- setattr(HosterPluginTester, sig, meta(plugin, url, flags.get(url, None), sig)) \ No newline at end of file
+ #register class
+ locals()[plugin] = _testerClass
+ # remove from locals, or tested twice
+ del _testerClass \ No newline at end of file