File: qunit_test.py

package info (click to toggle)
privacybadger 2026.2.20-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,040 kB
  • sloc: javascript: 56,619; python: 2,214; sh: 406; makefile: 57; xml: 6
file content (38 lines) | stat: -rw-r--r-- 1,019 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python

import unittest

import pbtest

from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By


class QUnitTest(pbtest.PBSeleniumTest):

    def test_run_qunit_tests(self):
        self.load_url(self.test_url)

        try:
            # this text appears when tests finish running
            self.txt_by_css(
                "#qunit-testresult-display > span.total",
                timeout=120
            )
        except TimeoutException as exc:
            self.fail(f"Cannot find the results of QUnit tests {exc}")

        print("\nQUnit summary:")
        print(self.txt_by_css("#qunit-testresult-display"))

        failed_test_els = self.driver.find_elements(By.CSS_SELECTOR,
            ".fail .test-name")
        fail_msg = "The following QUnit tests failed:\n  * {}".format(
            "\n  * ".join([el.text for el in failed_test_els])
        )

        assert not failed_test_els, fail_msg


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