<commit_before>import os
from unittest import TestCase
from servequnit.factory import ServerFactory
from servequnit.tester import QunitSeleniumTester, TestFailedError

class QunitSeleniumTesterTestCase(TestCase):
    def _make_tester(self, server, suffix=None):
        suffix = suffix or "oneshot/"
        url = server.url + suffix
        hub = "http://127.0.0.1:4444/wd/hub"
        tester = QunitSeleniumTester(url=url, hub=hub)
        return tester

    def test_passing_test_passes(self):
        passing = os.path.join(os.path.dirname(__file__), "data", "passes.js")
        factory = ServerFactory()
        factory.bind_script("test", passing)
        with factory.run() as server:
            tester = self._make_tester(server)
            tester.run()

    def test_failing_test_reports_failure(self):
        passing = os.path.join(os.path.dirname(__file__), "data", "fails.js")
        factory = ServerFactory()
        factory.bind_script("test", passing)
        with factory.run() as server:
            tester = self._make_tester(server)
            self.assertRaises(TestFailedError, tester.run)
<commit_msg>Test the an empty document results in a test failure.<commit_after>import os
from unittest import TestCase
from servequnit.factory import ServerFactory
from servequnit.tester import QunitSeleniumTester, TestFailedError

class QunitSeleniumTesterTestCase(TestCase):
    def _make_tester(self, server, suffix=None):
        suffix = suffix or "oneshot/"
        url = server.url + suffix
        hub = "http://127.0.0.1:4444/wd/hub"
        tester = QunitSeleniumTester(url=url, hub=hub)
        return tester

    def test_passing_test_passes(self):
        test_file = os.path.join(os.path.dirname(__file__), "data", "passes.js")
        factory = ServerFactory().bind_script("test", test_file)
        with factory.run() as server:
            tester = self._make_tester(server)
            tester.run()

    def test_failing_test_reports_failure(self):
        test_file = os.path.join(os.path.dirname(__file__), "data", "fails.js")
        factory = ServerFactory().bind_script("test", test_file)
        with factory.run() as server:
            tester = self._make_tester(server)
            self.assertRaises(TestFailedError, tester.run)

    def test_failing_test_reports_no_tests(self):
        factory = ServerFactory().bind_script("test", "/dev/null")
        with factory.run() as server:
            tester = self._make_tester(server)
            self.assertRaises(TestFailedError, tester.run)

{'fraction_non_alphanumeric': 0.10655090765588003, 'fraction_numerical': 0.007892659826361484, 'mean_word_length': 3.11525974025974, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4285009', 'n_tokens_mistral': 789, 'n_tokens_neox': 769, 'n_words': 160}