[test] do not run PyLintChecker tests if pylint is not available
authorDavid Douard <david.douard@logilab.fr>
Wed, 30 Apr 2014 12:03:56 +0200
changeset 1497 25ba735e3a43
parent 1496 179e9ef1af32
child 1498 32dff855539f
[test] do not run PyLintChecker tests if pylint is not available
test/unittest_checkers.py
--- a/test/unittest_checkers.py	Wed Apr 30 11:21:51 2014 +0200
+++ b/test/unittest_checkers.py	Wed Apr 30 12:03:56 2014 +0200
@@ -244,14 +244,19 @@
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_success'))
 
     ##### PyLintChecker #####
-    pylint = PyLintChecker(WRITER, {'pylint.threshold': 7})
-    addTest(ModuleCheckerTest(pylint, ['pylint_ok.py'], 'chks_test_success'))
-    addTest(ModuleCheckerTest(pylint, ['pylint_bad.py'], 'chks_test_failure'))
+    try:
+        import pylint as _pylint
+    except ImportError:
+        pass
+    else:
+        pylint = PyLintChecker(WRITER, {'pylint.threshold': 7})
+        addTest(ModuleCheckerTest(pylint, ['pylint_ok.py'], 'chks_test_success'))
+        addTest(ModuleCheckerTest(pylint, ['pylint_bad.py'], 'chks_test_failure'))
 
-    pylint_rc = PyLintChecker(WRITER, {'pylint_threshold': 7,
-                                       'pylintrc':input_path("pylintrc"),
-                                       "pylint.show_categories": "F,E,W,C"})
-    addTest(ModuleCheckerTest(pylint_rc, ['pylint_bad.py'], 'chks_test_success'))
+        pylint_rc = PyLintChecker(WRITER, {'pylint_threshold': 7,
+                                           'pylintrc':input_path("pylintrc"),
+                                           "pylint.show_categories": "F,E,W,C"})
+        addTest(ModuleCheckerTest(pylint_rc, ['pylint_bad.py'], 'chks_test_success'))
 
     # xml_syntax = XmlFormChecker(WRITER)
     # addTest(FileCheckerTest(xml_syntax, ['invalid.xml'], 'chks_test_file_success'))