Exemplo n.º 1
0
    def test_with_exceptions(self):
        """
        It should raise V8 exceptions
        """
        code_error = platform_module.lib.E_V8_JS_ERROR
        code_ok = platform_module.lib.E_V8_OK

        with patch('v8cffi.platform.lib', autospec=True) as r:
            r.v8cffi_platform_new = Mock(return_value=code_error)
            r.E_V8_OK = code_ok
            self.assertRaises(exceptions.V8JSError, _Platform().__enter__)
Exemplo n.º 2
0
    def test_with_exceptions(self):
        """
        It should raise V8 exceptions
        """
        code_error = platform_module.lib.E_V8_JS_ERROR
        code_ok = platform_module.lib.E_V8_OK

        with patch('v8cffi.platform.lib', autospec=True) as r:
            r.v8cffi_platform_new = Mock(return_value=code_error)
            r.E_V8_OK = code_ok
            self.assertRaises(exceptions.V8JSError, _Platform().__enter__)
Exemplo n.º 3
0
    def test_allocate_and_free(self):
        """
        It should allocate and free the C platform
        """
        code_ok = platform_module.lib.E_V8_OK

        with patch('v8cffi.platform.lib', autospec=True) as r:
            platform_ = _Platform()

            platform_new = Mock(return_value=code_ok)
            r.v8cffi_platform_new = platform_new
            r.E_V8_OK = code_ok
            platform_.__enter__()
            self.assertTrue(platform_new.called)

            platform_free = Mock()
            r.v8cffi_platform_free = platform_free
            platform_.__exit__()
            self.assertTrue(platform_free.called)

            self.assertTrue(platform_._is_dead)
            self.assertFalse(platform_.is_alive())
            self.assertRaises(AssertionError, platform_.__exit__)
Exemplo n.º 4
0
    def test_allocate_and_free(self):
        """
        It should allocate and free the C platform
        """
        code_ok = platform_module.lib.E_V8_OK

        with patch('v8cffi.platform.lib', autospec=True) as r:
            platform_ = _Platform()

            platform_new = Mock(return_value=code_ok)
            r.v8cffi_platform_new = platform_new
            r.E_V8_OK = code_ok
            platform_.__enter__()
            self.assertTrue(platform_new.called)

            platform_free = Mock()
            r.v8cffi_platform_free = platform_free
            platform_.__exit__()
            self.assertTrue(platform_free.called)

            self.assertTrue(platform_._is_dead)
            self.assertFalse(platform_.is_alive())
            self.assertRaises(AssertionError, platform_.__exit__)
Exemplo n.º 5
0
 def test_is_alive(self):
     """
     It should be initialized for these tests (see runtests.py)
     """
     self.assertTrue(platform.is_alive())
     self.assertFalse(_Platform().is_alive())
Exemplo n.º 6
0
 def test_is_alive(self):
     """
     It should be initialized for these tests (see runtests.py)
     """
     self.assertTrue(platform.is_alive())
     self.assertFalse(_Platform().is_alive())