本文整理汇总了Python中test_utils.TestUtils类的典型用法代码示例。如果您正苦于以下问题:Python TestUtils类的具体用法?Python TestUtils怎么用?Python TestUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestUtils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: echo
def echo(self, binary):
@server.websocket_handler
def websocket_handler(ws):
tu.check_context()
@ws.data_handler
def data_handler(buff):
tu.check_context()
ws.write_buffer(buff)
server.listen(8080)
if binary:
self.buff = TestUtils.gen_buffer(1000)
else:
self.str_ = TestUtils.random_unicode_string(1000)
def connect_handler(ws):
tu.check_context()
received = Buffer.create()
@ws.data_handler
def data_handler(buff):
tu.check_context()
received.append_buffer(buff)
if received.length == buff.length:
tu.azzert(TestUtils.buffers_equal(buff, received))
tu.test_complete()
if binary:
ws.write_binary_frame(self.buff)
else:
ws.write_text_frame(self.str_)
client.connect_web_socket("/someurl", connect_handler)
开发者ID:Findekano,项目名称:vert.x,代码行数:33,代码来源:test_client.py
示例2: test_hash
def test_hash(self):
hash1 = SharedData.get_hash("map1")
tu.azzert(hash1 != None)
hash2 = SharedData.get_hash("map1")
tu.azzert(hash2 != None)
tu.azzert(hash1 == hash2)
hash3 = SharedData.get_hash("map3")
tu.azzert(hash3 != None)
tu.azzert(hash1 != hash3)
key = 'wibble'
hash1[key] = 'hello'
tu.azzert(hash1[key] == 'hello')
tu.azzert(hash2[key] == 'hello')
tu.azzert(isinstance(hash1[key], unicode)) # Make sure it's not a Java String
hash1[key] = 12
tu.azzert(hash1[key] == 12)
tu.azzert(hash2[key] == 12)
hash1[key] = 1.2344
tu.azzert(hash1[key] == 1.2344)
tu.azzert(hash2[key] == 1.2344)
hash1[key] = True
tu.azzert(hash1[key] == True)
tu.azzert(hash2[key] == True)
hash1[key] = False
tu.azzert(hash1[key] == False)
tu.azzert(hash2[key] == False)
succeeded = False
try:
hash1[key] = SomeOtherClass()
succeeded = True
except:
pass # OK
tu.azzert(not succeeded, 'Should throw exception')
# Make sure it deals with Ruby buffers ok, and copies them
buff1 = TestUtils.gen_buffer(100)
hash1[key] = buff1
buff2 = hash1[key]
tu.azzert(isinstance(buff2, Buffer))
tu.azzert(buff1 != buff2)
tu.azzert(TestUtils.buffers_equal(buff1, buff2))
tu.azzert(SharedData.remove_hash("map1"))
tu.azzert(not SharedData.remove_hash("map1"))
tu.azzert(SharedData.remove_hash("map3"))
tu.test_complete()
开发者ID:aaronwalker,项目名称:vert.x,代码行数:57,代码来源:test_client.py
示例3: end_handler
def end_handler(stream):
tu.check_context()
tu.azzert(TestUtils.buffers_equal(sent_buff, body))
if chunked:
tu.azzert('vtrailer1' == resp.trailers['trailer1'])
tu.azzert('vtrailer2' == resp.trailers['trailer2'])
tu.test_complete()
开发者ID:Findekano,项目名称:vert.x,代码行数:7,代码来源:test_client.py
示例4: data_handler
def data_handler(data):
tu.check_context()
received.append_buffer(data)
if received.length == sends * size:
tu.azzert(TestUtils.buffers_equal(sent, received))
tu.test_complete()
开发者ID:Findekano,项目名称:vert.x,代码行数:7,代码来源:test_client.py
示例5: client_connect_handler
def client_connect_handler(socket):
tu.check_context()
sends = 10
size = 100
sent = Buffer.create()
received = Buffer.create()
@socket.data_handler
def data_handler(data):
tu.check_context()
received.append_buffer(data)
if received.length == sends * size:
tu.azzert(TestUtils.buffers_equal(sent, received))
tu.test_complete()
@socket.drain_handler
def drain_handler(stream):
tu.check_context()
#print "drained\n"
@socket.end_handler
def end_handler(stream):
tu.check_context()
#print "end\n"
socket.pause()
socket.resume()
socket.write_queue_full
socket.write_queue_max_size = 100000
for i in range(0, sends):
data = TestUtils.gen_buffer(size)
sent.append_buffer(data)
socket.write_buffer(data)
开发者ID:Findekano,项目名称:vert.x,代码行数:34,代码来源:test_client.py
示例6: open_handler
def open_handler(err, file):
tu.check_context()
tu.azzert(err == None)
num_chunks = 100;
chunk_size = 1000;
tot_buff = Buffer.create()
self.written = 0
for i in range(0, num_chunks):
buff = TestUtils.gen_buffer(chunk_size)
tot_buff.append_buffer(buff)
def write_handler(err, res):
tu.check_context()
self.written += 1
if self.written == num_chunks:
# all written
tot_read = Buffer.create()
self.read = 0
for j in range(0, num_chunks):
pos = j * chunk_size
def read_handler(err, buff):
tu.check_context
tu.azzert(err == None)
self.read += 1
if self.read == num_chunks:
# all read
tu.azzert(TestUtils.buffers_equal(tot_buff, tot_read))
def close_handler(err, res):
tu.check_context()
tu.test_complete()
file.close(close_handler)
file.read(tot_read, pos, pos, chunk_size, read_handler)
file.write(buff, i * chunk_size, write_handler)
开发者ID:aaronwalker,项目名称:vert.x,代码行数:32,代码来源:test_client.py
示例7: end_handler
def end_handler(stream):
tu.azzert(TestUtils.buffers_equal(tot_buff, tot_read))
tu.check_context
def close_handler2(err, result):
tu.check_context()
tu.test_complete()
file.close(close_handler2)
开发者ID:aaronwalker,项目名称:vert.x,代码行数:7,代码来源:test_client.py
示例8: end_handler
def end_handler(stream):
tu.check_context()
if method != "HEAD" and method != "CONNECT":
tu.azzert(TestUtils.buffers_equal(sent_buff, body))
if chunked:
tu.azzert("vtrailer1" == resp.trailers["trailer1"])
tu.azzert("vtrailer2" == resp.trailers["trailer2"])
tu.test_complete()
开发者ID:jdonnerstag,项目名称:vert.x,代码行数:8,代码来源:test_client.py
示例9: data_handler
def data_handler(data):
tu.check_thread()
tu.azzert(TestUtils.buffers_equal(buffer, data.data))
def send_handler(err, sock):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(sock == peer2)
peer2.send('127.0.0.1', 1235, data.data, send_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:10,代码来源:test_client.py
示例10: read_handler
def read_handler(err, buff):
tu.check_context
tu.azzert(err == None)
self.read += 1
if self.read == num_chunks:
# all read
tu.azzert(TestUtils.buffers_equal(tot_buff, tot_read))
def close_handler(err, res):
tu.check_context()
tu.test_complete()
file.close(close_handler)
开发者ID:aaronwalker,项目名称:vert.x,代码行数:11,代码来源:test_client.py
示例11: end_handler
def end_handler():
tu.check_thread()
if method != 'HEAD' and method != 'CONNECT':
tu.azzert(TestUtils.buffers_equal(sent_buff, body))
if chunked:
tu.azzert('vtrailer1' == resp.trailers['trailer1'])
tu.azzert('vtrailer2' == resp.trailers['trailer2'])
resp.headers.clear()
tu.azzert(resp.headers.is_empty)
tu.test_complete()
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:11,代码来源:test_client.py
示例12: listen_handler
def listen_handler(err, sock):
tu.azzert(err is None)
tu.azzert(sock == peer2)
buffer = TestUtils.gen_buffer(128)
@peer2.data_handler
def data_handler(data):
tu.check_thread()
tu.azzert(TestUtils.buffers_equal(buffer, data.data))
tu.test_complete()
def send_handler(err, sock):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(sock == peer1)
peer1.send('255.255.255.255', 1234, buffer, send_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:17,代码来源:test_client.py
示例13: client_connect_handler
def client_connect_handler(err, socket):
tu.azzert(err == None)
tu.check_thread()
tu.azzert(socket.local_address[0] is not None)
tu.azzert(socket.local_address[1] > -1)
tu.azzert(socket.remote_address[0] is not None)
tu.azzert(socket.remote_address[1] > -1)
sends = 10
size = 100
sent = Buffer.create()
received = Buffer.create()
@socket.data_handler
def data_handler(data):
tu.check_thread()
received.append_buffer(data)
if received.length == sends * size:
tu.azzert(TestUtils.buffers_equal(sent, received))
tu.test_complete()
#Just call the methods. Real testing is done in java tests
@socket.drain_handler
def drain_handler():
tu.check_thread()
@socket.end_handler
def end_handler():
tu.check_thread()
@socket.close_handler
def close_handler():
tu.check_thread()
socket.pause()
socket.resume()
socket.write_queue_full
socket.write_queue_max_size = 100000
for i in range(0, sends):
data = TestUtils.gen_buffer(size)
sent.append_buffer(data)
socket.write(data)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:45,代码来源:test_client.py
示例14: peer2_listen_handler
def peer2_listen_handler(err, serv):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(serv == peer2)
buffer = TestUtils.gen_buffer(128)
@peer2.data_handler
def data_handler(data):
tu.check_thread()
tu.azzert(TestUtils.buffers_equal(buffer, data.data))
tu.test_complete()
def send_handler(err, result):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(result == peer1)
peer1.send('127.0.0.1', 1234, buffer, send_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:19,代码来源:test_client.py
示例15: test_echo
def test_echo(self):
@peer1.exception_handler
def exception_handler(err):
tu.azzert(False)
@peer2.exception_handler
def exception_handler(err):
tu.azzert(False)
buffer = TestUtils.gen_buffer(128)
def peer2_listen_handler(err, sock):
@peer2.data_handler
def data_handler(data):
tu.check_thread()
tu.azzert(TestUtils.buffers_equal(buffer, data.data))
def send_handler(err, sock):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(sock == peer2)
peer2.send('127.0.0.1', 1235, data.data, send_handler)
def peer1_listen_handler(err, sock):
@peer1.data_handler
def data_handler(data):
tu.check_thread()
tu.azzert(TestUtils.buffers_equal(buffer, data.data))
tu.test_complete()
def send_handler(err, sock):
tu.check_thread()
tu.azzert(err is None)
tu.azzert(sock == peer1)
peer1.send('127.0.0.1', 1234, buffer, send_handler)
peer1.listen(1235, '127.0.0.1', peer1_listen_handler)
peer2.listen(1234, '127.0.0.1', peer2_listen_handler)
开发者ID:fregaham,项目名称:mod-lang-jython,代码行数:41,代码来源:test_client.py
示例16: TestUtils
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
from test_utils import TestUtils
from core.event_bus import EventBus
tu = TestUtils()
class DeployTest(object):
handler_id = None
def test_deploy(self):
global handler_id
def handler(message):
if message.body == "started":
tu.test_complete()
handler_id = EventBus.register_handler("test-handler", False, handler)
conf = {'foo' : 'bar'}
vertx.deploy_verticle("core/deploy/child.py", conf)
开发者ID:emangchi,项目名称:vert.x,代码行数:31,代码来源:test_client.py
示例17: TestUtils
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
from test_utils import TestUtils
tu = TestUtils()
execfile("src/test/python_scripts/core/scriptloading/script1.py")
class ScriptingLoadingTest(object):
def test_scriptloading(self):
tu.azzert(Foo.func1(tu) == "foo")
tu.test_complete()
def vertx_stop():
tu.unregister_all()
tu.app_stopped()
tu.register_all(ScriptingLoadingTest())
tu.app_ready()
开发者ID:dimzava,项目名称:vert.x,代码行数:30,代码来源:test_client.py
示例18: TestUtils
# Copyright 2011-2012 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
from test_utils import TestUtils
from core.event_bus import EventBus
tu = TestUtils()
config = vertx.config()
tu.azzert(config['foo'] == 'bar')
EventBus.send("test-handler", "started")
def vertx_stop():
EventBus.send("test-handler", "stopped")
开发者ID:Findekano,项目名称:vert.x,代码行数:27,代码来源:child.py
示例19: TestUtils
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import vertx
from test_utils import TestUtils
from core.event_bus import EventBus
tu = TestUtils()
tu.check_thread()
class EventBusTest(object):
def test_simple_send(self):
json = {'message' : 'hello world!'}
address = "some-address"
def handler(msg):
tu.azzert(msg.body['message'] == json['message'])
EventBus.unregister_handler(id)
tu.test_complete()
id = EventBus.register_handler(address, handler=handler)
tu.azzert(id != None)
EventBus.send(address, json)
开发者ID:johnkewforks,项目名称:mod-lang-jython,代码行数:31,代码来源:test_client.py
示例20: TestUtils
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from test_utils import TestUtils
tu = TestUtils()
test_global = None
class IsolationTest(object):
def test_isolation(self):
global test_global
# Make sure global variables aren't visible between applications
tu.azzert(test_global == None)
test_global = 123
tu.test_complete()
def vertx_stop():
tu.unregister_all()
tu.app_stopped()
开发者ID:Findekano,项目名称:vert.x,代码行数:30,代码来源:test_client.py
注:本文中的test_utils.TestUtils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论