예제 #1
0
class JavaScriptTests(TestCase):
    """
    Tests for the JavaScript UnitTest runner, L{JavaScriptTestCase}.
    """
    def setUp(self):
        """
        Create a L{JavaScriptTestCase} and verify that its dependencies are
        present (otherwise, skip the test).
        """
        self.case = JavaScriptTestCase()
        try:
            self.case.checkDependencies()
        except NotSupported:
            raise SkipTest("Missing JS dependencies")


    def test_unsuccessfulExit(self):
        """
        Verify that an unsuccessful exit status results in an error.
        """
        result = TestResult()
        self.case.createSource = lambda testMethod: "throw new TypeError();"
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertTrue(
            result.errors[0][1].startswith(
                'Exception: JavaScript interpreter had error exit: '))


    def test_signalledExit(self):
        """
        An error should be reported if the JavaScript interpreter exits because
        it received a signal.
        """
        segfault = FilePath(__file__).sibling('segfault.py')

        def stubFinder():
            return sys.executable
        def stubScript(testModule):
            return segfault.path
        self.case.findJavascriptInterpreter = stubFinder
        self.case.makeScript = stubScript
        result = TestResult()
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertEquals(
            result.errors[0][1],
            'Exception: JavaScript interpreter exited due to signal 11\n')


    def test_missingJavaScriptClass(self):
        """
        If a JavaScript class required by the test code is unavailable, an
        error is added to the result object by L{JavaScriptTestCase.run}.
        """
        result = TestResult()
        self.case.testMethod = lambda: "Nevow.Test.NoSuchModule"
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
예제 #2
0
class JavaScriptTests(TestCase):
    """
    Tests for the JavaScript UnitTest runner, L{JavaScriptTestCase}.
    """
    def setUp(self):
        """
        Create a L{JavaScriptTestCase} and verify that its dependencies are
        present (otherwise, skip the test).
        """
        self.case = JavaScriptTestCase()
        try:
            self.case.checkDependencies()
        except NotSupported:
            raise SkipTest("Missing JS dependencies")

    def test_unsuccessfulExit(self):
        """
        Verify that an unsuccessful exit status results in an error.
        """
        result = TestResult()
        self.case.createSource = lambda testMethod: "throw new TypeError();"
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertTrue(result.errors[0][1].startswith(
            'Exception: JavaScript interpreter had error exit: '))

    def test_signalledExit(self):
        """
        An error should be reported if the JavaScript interpreter exits because
        it received a signal.
        """
        segfault = FilePath(__file__).sibling('segfault.py')

        def stubFinder():
            return sys.executable

        def stubScript(testModule):
            return segfault.path

        self.case.findJavascriptInterpreter = stubFinder
        self.case.makeScript = stubScript
        result = TestResult()
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
        self.assertEquals(
            result.errors[0][1],
            'Exception: JavaScript interpreter exited due to signal 11\n')

    def test_missingJavaScriptClass(self):
        """
        If a JavaScript class required by the test code is unavailable, an
        error is added to the result object by L{JavaScriptTestCase.run}.
        """
        result = TestResult()
        self.case.testMethod = lambda: "Nevow.Test.NoSuchModule"
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)
예제 #3
0
class JavaScriptTests(TestCase):
    """
    Tests for the JavaScript UnitTest runner, L{JavaScriptTestCase}.
    """
    def setUp(self):
        """
        Create a L{JavaScriptTestCase} and verify that its dependencies are
        present (otherwise, skip the test).
        """
        self.case = JavaScriptTestCase()
        try:
            self.case.checkDependencies()
        except NotSupported:
            raise SkipTest("Missing JS dependencies")


    def test_unsuccessfulExit(self):
        """
        Verify that an unsuccessful exit status results in an error.
        """
        result = TestResult()
        self.case.createSource = lambda testMethod: "throw new TypeError();"
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)


    def test_signalledExit(self):
        """
        An error should be reported if the JavaScript interpreter exits because
        it received a signal.
        """
        def stubFinder():
            return FilePath(__file__).sibling('segfault.py').path
        self.case.findJavascriptInterpreter = stubFinder
        self.case.createSource = lambda testMethod: ""
        result = TestResult()
        self.case.run(result)
        self.assertEqual(len(result.errors), 1)