aboutsummaryrefslogblamecommitdiffstats
path: root/src/tests/test_plugin_syntax.py
blob: b3a8ca9ac88585db73513714de2535e46655587b (plain) (tree)




















                                                                        
                               











                                                                              
import unittest
import sys
import os
import sos.policyredhat
from sos.helpers import *

class testPluginSanity(unittest.TestCase):
    """ tests plugins don't fail due to indentation errors
        etc.
    """
    def setUp(self):
        self.policy = sos.policyredhat.SosPolicy()
        # build plugins list
        paths = sys.path
        for path in paths:
            if path.strip()[-len("site-packages"):] == "site-packages" \
            and os.path.isdir(path + "/sos/plugins"):
                pluginpath = path + "/sos/plugins"
        self.plugins = os.listdir(pluginpath)
        self.plugins.sort()

    def test_plugin_load(self):
        for plug in self.plugins:
            plugbase = plug[:-3]
            if not plug[-3:] == '.py' or plugbase == "__init__":
                continue
            try:
                loadPlugin = importPlugin("sos.plugins." + plugbase, plugbase)
            except:
                self.fail("Plugin exception on %s" % (plugbase,))

if __name__=="__main__":
    unittest.main()