Commits

masklinn committed 053f553

Test errors in QUnitSuite

Comments (0)

Files changed (4)

qunitsuite/tests/test_errors.py

+# -*- coding: utf-8 -*-
+import unittest
+
+from ..suite import QUnitSuite
+
+from utils import path_to
+
+class TestErrors(unittest.TestCase):
+    def test_notfound(self):
+        result = unittest.TestResult()
+        suite = QUnitSuite('bullshit_file.html')
+        suite(result)
+
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.failures, [])
+        self.assertEqual(len(result.errors), 1)
+        test, message = result.errors[0]
+        self.assertEqual(str(test), "phantomjs: startup")
+        self.assertTrue(message.startswith("PhantomJS unable to load "))
+
+    def test_timeout(self):
+        result = unittest.TestResult()
+        # lower timeout to not blow up test suite runtime worse than now
+        suite = QUnitSuite(path_to('timeout.html'), timeout=500)
+        suite(result)
+
+        self.assertEqual(result.testsRun, 1)
+        self.assertEqual(result.failures, [])
+        self.assertEqual(len(result.errors), 1)
+        test, message = result.errors[0]
+        self.assertEqual(str(test), "phantomjs: startup")
+        self.assertTrue(message.startswith("PhantomJS timed out"))

qunitsuite/tests/test_reporting.py

 # -*- coding: utf-8 -*-
-import os
 import unittest
+
 from ..suite import QUnitSuite
 
-ROOT = os.path.abspath(os.path.dirname(__file__))
-def path_to(*fpath):
-    return os.path.join(ROOT, 'testfiles', *fpath)
+from utils import path_to
 
 class TestSuccess(unittest.TestCase):
     def test_various(self):

qunitsuite/tests/testfiles/timeout.html

+<!DOCTYPE html>
+<html>
+<head>
+    <title></title>
+</head>
+<body>
+
+</body>
+</html>

qunitsuite/tests/utils.py

+# -*- coding: utf-8 -*-
+import os
+
+ROOT = os.path.abspath(os.path.dirname(__file__))
+def path_to(*fpath):
+    return os.path.join(ROOT, 'testfiles', *fpath)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.