コード例 #1
0
    def test_rpc(self):
        remote = PhantomJSRemote()

        result = yield remote.call('debugEcho', 'hello!')

        self.assertEqual('hello!', result)

        yield remote.eval('var myvalue;')
        yield remote.set('myvalue', 123)

        result = yield remote.eval('myvalue')

        self.assertEqual(123, result)

        yield remote.set('myvalue', 'abc')

        result = yield remote.eval('myvalue')

        self.assertEqual('abc', result)
コード例 #2
0
    def test_rpc(self):
        remote = PhantomJSRemote()

        result = yield remote.call('debugEcho', 'hello!')

        self.assertEqual('hello!', result)

        yield remote.eval('var myvalue;')
        yield remote.set('myvalue', 123)

        result = yield remote.eval('myvalue')

        self.assertEqual(123, result)

        yield remote.set('myvalue', 'abc')

        result = yield remote.eval('myvalue')

        self.assertEqual('abc', result)
コード例 #3
0
    def test_timeouts(self):
        remote = PhantomJSRemote()

        try:
            yield remote.wait_page_event('invalid_event', timeout=0.1)
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.eval('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.set('blah', 123, timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.call('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()
コード例 #4
0
    def test_timeouts(self):
        remote = PhantomJSRemote()

        try:
            yield remote.wait_page_event('invalid_event', timeout=0.1)
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.eval('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.set('blah', 123, timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()

        try:
            future = remote.call('blah', timeout=0.1)
            remote._rpc_reply_map.clear()
            yield future
        except PhantomJSRPCTimedOut:
            pass
        else:
            self.fail()