Commits

masklinn committed 7291c23

Skip QUnit suite (and report as skipped) if no phantomjs on path

Comments (0)

Files changed (3)

qunitsuite/suite.py

         return iter([self])
 
     def run(self, result):
+        try:
+            subprocess.call(['phantomjs'],
+                            stdout=open(os.devnull, 'w'),
+                            stderr=subprocess.STDOUT)
+        except OSError:
+            test = QUnitTest('phantomjs', 'javascript tests')
+            result.startTest(test)
+            result.startTest(test)
+            result.addSkip(test , "phantomjs command not found")
+            result.stopTest(test)
+            return
+
         result._exc_info_to_string = _exc_info_to_string
         try:
             self._run(result)

qunitsuite/tests/test_errors.py

         suite = QUnitSuite('bullshit_file.html')
         suite(result)
 
+        self.assertEqual(result.skipped, [])
         self.assertEqual(result.testsRun, 1)
         self.assertEqual(result.failures, [])
         self.assertEqual(len(result.errors), 1)
         suite = QUnitSuite(path_to('timeout.html'), timeout=500)
         suite(result)
 
+        self.assertEqual(result.skipped, [])
         self.assertEqual(result.testsRun, 1)
         self.assertEqual(result.failures, [])
         self.assertEqual(len(result.errors), 1)

qunitsuite/tests/test_reporting.py

         suite = QUnitSuite(path_to('success.html'))
         suite(result)
 
+        self.assertEqual(result.skipped, [])
         self.assertEqual(result.errors, [])
         self.assertEqual(result.failures, [])
         self.assertEqual(result.testsRun, 6)
         suite = QUnitSuite(path_to('failure.html'))
         suite(result)
 
+        self.assertEqual(result.skipped, [])
         self.assertEqual(result.errors, [])
         self.assertEqual(len(result.failures), 10)
         # check messages