def build_tests(self, templates, tag=None):

        skels = self._parse_tests(tag)
        tests = []

        for test_defaults, test_overrides in skels:
            testconf = templates.get(test_overrides['test'], None)
            if testconf is None:
                raise errors.InitError(
                        "Test template '%s' not found in config!"
                        % test_overrides['test'])

            # Copy the config so we can add instance specific values
            # such as host, port, etc.
            testconf = testconf.copy()

            for key, val in test_defaults.iteritems():
                testconf.setdefault(key, val)

            for key, val in test_overrides.iteritems():
                testconf[key] = val

            try:
                testobj = self.new_test(testconf)
            except (errors.InitError, CoilError), ex:
                raise errors.InitError(
                        "Error in test %s: %s" % (test_overrides['test'], ex))
            except Exception:
                log.error("Unknown error while loading test.")
                log.error("Test config: %s" % repr(testconf))
                log.error(str(errors.Failure()))
                raise errors.InitError(
                        "Error in test %s" % test_overrides['test'])

            testobj.addReportCallback(self._send_report,
                    test_defaults['host'], test_defaults['description'])
            tests.append(testobj)

        return tests
Setup tests based on the loaded Nagios config
dataset/ETHPy150Open marineam/nagcat/python/nagcat/nagios.py/NagcatNagios.build_tests