File: test_plugins.py

package info (click to toggle)
gamera 1:3.4.2+git20160808.1725654-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,312 kB
  • ctags: 24,991
  • sloc: xml: 122,324; ansic: 52,869; cpp: 50,664; python: 35,034; makefile: 118; sh: 101
file content (30 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from gamera.core import *
init_gamera()
from gamera import gendoc
from gamera import plugin

# This is a fairly complex test harness, which generates
# a "wrapper" call around every plugin so each plugin can
# be tested separately by py.test

class PluginTester(gendoc.PluginDocumentationGenerator):
   def __init__(self):
      self.images = self.get_generic_images()
      self.methods = plugin._methods_flatten(plugin.plugin_methods)

class TestPlugins:
   pass

def make_test(tester, method):
   def test(self):
      tester.run_example(method, tester.images)
   return test

tester = PluginTester()
for name, method in tester.methods:
   f = make_test(tester, method)
   f.__name__ = "test_plugin_" + name
   setattr(TestPlugins, f.__name__, f)
del f

del make_test