aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-01-22 19:49:52 +0000
committerastokes <astokes@ef72aa8b-4018-0410-8976-d6e080ef94d8>2010-01-22 19:49:52 +0000
commitb73cd69caebe5d14a11acb8fea83a7c1c23de500 (patch)
tree21792d34df4e5b99adfbc6bc2aed2d989b2936c8
parentfb62ba4f394f4a32803d3a25784d041aa2af93ab (diff)
downloadsos-b73cd69caebe5d14a11acb8fea83a7c1c23de500.tar.gz
- unittest for plugin import failure
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@698 ef72aa8b-4018-0410-8976-d6e080ef94d8
-rw-r--r--src/tests/test_plugin_syntax.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/tests/test_plugin_syntax.py b/src/tests/test_plugin_syntax.py
new file mode 100644
index 00000000..573fa8fe
--- /dev/null
+++ b/src/tests/test_plugin_syntax.py
@@ -0,0 +1,34 @@
+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 testPluginLoad(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()
+