本文整理汇总了Python中spyne.util.test.show函数的典型用法代码示例。如果您正苦于以下问题:Python show函数的具体用法?Python show怎么用?Python show使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了show函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_string_array_no_header
def test_string_array_no_header(self):
class SomeService(ServiceBase):
@srpc(String(max_occurs='unbounded'), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlRowTable(produce_header=False))
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(('s', '1'), ('s', '2')) )
#FIXME: Needs a proper test with xpaths and all.
show(html.fromstring(out_string), 'TestHtmlRowTable.test_string_array_no_header')
assert out_string == \
'<div>' \
'<table class="some_callResponse">' \
'<tr>' \
'<td>' \
'<table>' \
'<tr>' \
'<td>1</td>' \
'</tr>' \
'<tr>' \
'<td>2</td>' \
'</tr>' \
'</table>' \
'</td>' \
'</tr>' \
'</table>' \
'</div>'
示例2: _test_type
def _test_type(cls, inst, prot_cls=HtmlFormTable):
from spyne.util import appreg; appreg._applications.clear()
class SomeService(ServiceBase):
@rpc(_returns=cls, _body_style='bare')
def some_call(ctx):
return inst
prot = prot_cls(cloth=T_TEST, doctype='<!DOCTYPE html>')
app = Application([SomeService], 'some_ns', out_protocol=prot)
null = NullServer(app, ostr=True)
ret = ''.join(null.service.some_call())
try:
elt = html.fromstring(ret)
except:
print(ret)
raise
show(elt)
elt = elt.xpath('//form')[0]
elt = strip_ns(elt) # get rid of namespaces to simplify xpaths in tests
print(R("========== fragment =========="))
print(etree.tostring(elt, pretty_print=True))
print(R("========== fragment =========="))
return elt
示例3: test_string_array_no_header
def test_string_array_no_header(self):
class SomeService(ServiceBase):
@srpc(String(max_occurs="unbounded"), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], "tns", in_protocol=HttpRpc(), out_protocol=HtmlRowTable(header=False))
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(("s", "1"), ("s", "2")))
# FIXME: Needs a proper test with xpaths and all.
show(html.fromstring(out_string), "TestHtmlRowTable.test_string_array_no_header")
assert (
out_string == "<div>"
'<table class="some_callResponse">'
"<tr>"
"<td>"
"<table>"
"<tr>"
"<td>1</td>"
"</tr>"
"<tr>"
"<td>2</td>"
"</tr>"
"</table>"
"</td>"
"</tr>"
"</table>"
"</div>"
)
示例4: test_string_array
def test_string_array(self):
class SomeService(ServiceBase):
@srpc(String(max_occurs='unbounded'), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlRowTable())
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(('s', '1'), ('s', '2')) )
show(html.fromstring(out_string), 'TestHtmlRowTable.test_string_array')
assert out_string == \
'<div xmlns="http://www.w3.org/1999/xhtml">' \
'<table xmlns="http://www.w3.org/1999/xhtml" class="some_callResponse">' \
'<tr>' \
'<th>string</th>' \
'<td>' \
'<table>' \
'<tr>' \
'<td>1</td>' \
'</tr>' \
'<tr>' \
'<td>2</td>' \
'</tr>' \
'</table>' \
'</td>' \
'</tr>' \
'</table>' \
'</div>'
示例5: _test_type
def _test_type(cls, inst):
# silence bogus warnings
from spyne.util import appreg; appreg.applications.clear()
class SomeService(ServiceBase):
@rpc(_returns=cls, _body_style='bare')
def some_call(ctx):
return inst
prot = HtmlForm(cloth=T_TEST)
app = Application([SomeService], 'some_ns', out_protocol=prot)
null = NullServer(app, ostr=True)
ret = ''.join(null.service.some_call())
try:
elt = html.fromstring(ret)
except:
print(ret)
raise
show(elt, stdout=False)
elt = elt.xpath('//form')[0] # get the form tag inside the body tag
elt = strip_ns(elt) # get rid of namespaces to simplify xpaths in tests
print(etree.tostring(elt, pretty_print=True))
return elt
示例6: test_string_array
def test_string_array(self):
class SomeService(ServiceBase):
@srpc(String(max_occurs='unbounded'), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlRowTable(field_name_attr=None,
field_type_name_attr=None))
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(('s', '1'), ('s', '2')) )
show(html.fromstring(out_string), 'TestHtmlRowTable.test_string_array')
assert out_string.decode('utf8') == \
'<div>' \
'<table class="some_callResponse">' \
'<tr>' \
'<th>string</th>' \
'<td>' \
'<table>' \
'<tr>' \
'<td>1</td>' \
'</tr>' \
'<tr>' \
'<td>2</td>' \
'</tr>' \
'</table>' \
'</td>' \
'</tr>' \
'</table>' \
'</div>'
示例7: test_complex_array
def test_complex_array(self):
class CM(ComplexModel):
i = Integer
s = String
class CCM(ComplexModel):
c = CM
i = Integer
s = String
class SomeService(ServiceBase):
@srpc(CCM, _returns=Array(CCM))
def some_call(ccm):
return [CCM(c=ccm.c,i=ccm.i, s=ccm.s)] * 2
app = Application([SomeService], 'tns',
in_protocol=HttpRpc(hier_delim='_'),
out_protocol=HtmlMicroFormat())
server = WsgiApplication(app)
out_string = call_wsgi_app_kwargs(server,
ccm_c_s='abc', ccm_c_i=123, ccm_i=456, ccm_s='def')
#
# Here's what this is supposed to return:
#
# <div class="some_callResponse"><div class="some_callResult">
# <div class="CCM">
# <div class="i">456</div>
# <div class="c">
# <div class="i">123</div>
# <div class="s">abc</div>
# </div>
# <div class="s">def</div>
# </div>
# <div class="CCM">
# <div class="i">456</div>
# <div class="c">
# <div class="i">123</div>
# <div class="s">abc</div>
# </div>
# <div class="s">def</div>
# </div>
# </div></div>
#
print(out_string)
elt = html.fromstring(out_string)
show(elt, "TestHtmlMicroFormat.test_complex_array")
resp = elt.find_class('some_callResponse')
assert len(resp) == 1
res = resp[0].find_class('some_callResult')
assert len(res) == 1
assert len(res[0].find_class("CCM")) == 2
示例8: _test_type_no_root_cloth
def _test_type_no_root_cloth(cls, inst):
from spyne.util import appreg; appreg.applications.clear()
class SomeService(ServiceBase):
@rpc(_returns=cls, _body_style='bare')
def some_call(ctx):
return inst
prot = HtmlForm()
app = Application([SomeService], 'some_ns', out_protocol=prot)
null = NullServer(app, ostr=True)
elt = etree.fromstring(''.join(null.service.some_call()))
show(elt)
return elt
示例9: test_complex_array
def test_complex_array(self):
class SomeService(ServiceBase):
@srpc(CCM, _returns=Array(CCM))
def some_call(ccm):
return [ccm] * 5
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlColumnTable(field_name_attr='class'))
server = WsgiApplication(app)
out_string = call_wsgi_app_kwargs(server,
ccm_i='456',
ccm_s='def',
ccm_c_i='123',
ccm_c_s='abc',
)
elt = etree.fromstring(out_string)
show(elt, 'TestHtmlColumnTable.test_complex_array')
elt = html.fromstring(out_string)
row, = elt[0] # thead
cell = row.findall('th[@class="i"]')
assert len(cell) == 1
assert cell[0].text == 'i'
cell = row.findall('th[@class="s"]')
assert len(cell) == 1
assert cell[0].text == 's'
for row in elt[1]: # tbody
cell = row.xpath('td[@class="i"]')
assert len(cell) == 1
assert cell[0].text == '456'
cell = row.xpath('td[@class="c"]//td[@class="i"]')
assert len(cell) == 1
assert cell[0].text == '123'
cell = row.xpath('td[@class="c"]//td[@class="s"]')
assert len(cell) == 1
assert cell[0].text == 'abc'
cell = row.xpath('td[@class="s"]')
assert len(cell) == 1
assert cell[0].text == 'def'
示例10: test_string_array
def test_string_array(self):
class SomeService(ServiceBase):
@srpc(String(max_occurs="unbounded"), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], "tns", in_protocol=HttpRpc(), out_protocol=HtmlColumnTable())
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(("s", "1"), ("s", "2")))
elt = etree.fromstring(out_string)
show(elt, "TestHtmlColumnTable.test_string_array")
assert (
out_string == '<table class="string">'
'<thead><tr><th class="some_callResponse">some_callResponse</th></tr></thead>'
"<tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody>"
"</table>"
)
示例11: _test_type
def _test_type(cls, inst):
from spyne.util import appreg; appreg._applications.clear()
class SomeService(ServiceBase):
@rpc(_returns=cls, _body_style='bare')
def some_call(ctx):
return inst
prot = HtmlFormTable(cloth=T_TEST)
app = Application([SomeService], 'some_ns', out_protocol=prot)
null = NullServer(app, ostr=True)
elt = etree.fromstring(''.join(null.service.some_call()))
show(elt, stdout=False)
elt = elt.xpath('//*[@spyne]')[0]
elt = strip_ns(elt) # get rid of namespaces to simplify xpaths in tests
print(etree.tostring(elt, pretty_print=True))
return elt
示例12: test_anyuri_string
def test_anyuri_string(self):
_link = "http://arskom.com.tr/"
class C(ComplexModel):
c = AnyUri
class SomeService(ServiceBase):
@srpc(_returns=Array(C))
def some_call():
return [C(c=_link)]
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlColumnTable(field_name_attr='class'))
server = WsgiApplication(app)
out_string = call_wsgi_app_kwargs(server)
elt = html.fromstring(out_string)
show(elt, "TestHtmlColumnTable.test_anyuri_string")
assert elt.xpath('//td[@class="c"]')[0][0].tag == 'a'
assert elt.xpath('//td[@class="c"]')[0][0].attrib['href'] == _link
示例13: test_string_array
def test_string_array(self):
class SomeService(Service):
@srpc(String(max_occurs='unbounded'), _returns=Array(String))
def some_call(s):
return s
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlColumnTable(
field_name_attr=None, field_type_name_attr=None))
server = WsgiApplication(app)
out_string = call_wsgi_app(server, body_pairs=(('s', '1'), ('s', '2')))
elt = etree.fromstring(out_string)
show(elt, "TestHtmlColumnTable.test_string_array")
assert out_string.decode('utf8') == \
'<table class="string">' \
'<thead>' \
'<tr><th>some_callResponse</th></tr>' \
'</thead>' \
'<tbody>' \
'<tr><td>1</td></tr>' \
'<tr><td>2</td></tr>' \
'</tbody>' \
'</table>'
示例14: test_complex_array
def test_complex_array(self):
v = [
CM(i=1, s='a'),
CM(i=2, s='b'),
CM(i=3, s='c'),
CM(i=4, s='d'),
]
class SomeService(ServiceBase):
@srpc(_returns=Array(CM))
def some_call():
return v
app = Application([SomeService], 'tns', in_protocol=HttpRpc(),
out_protocol=HtmlRowTable())
server = WsgiApplication(app)
out_string = call_wsgi_app_kwargs(server)
show(html.fromstring(out_string), 'TestHtmlRowTable.test_complex_array')
#FIXME: Needs a proper test with xpaths and all.
assert out_string == \
'<div xmlns="http://www.w3.org/1999/xhtml">' \
'<table xmlns="http://www.w3.org/1999/xhtml" class="CM">' \
'<tbody>' \
'<tr>' \
'<th class="i">i</th>' \
'<td class="i">1</td>' \
'</tr>' \
'<tr>' \
'<th class="s">s</th>' \
'<td class="s">a</td>' \
'</tr>' \
'</tbody>' \
'</table>' \
'<table xmlns="http://www.w3.org/1999/xhtml" class="CM">' \
'<tbody>' \
'<tr>' \
'<th class="i">i</th>' \
'<td class="i">2</td>' \
'</tr>' \
'<tr>' \
'<th class="s">s</th>' \
'<td class="s">b</td>' \
'</tr>' \
'</tbody>' \
'</table>' \
'<table xmlns="http://www.w3.org/1999/xhtml" class="CM">' \
'<tbody>' \
'<tr>' \
'<th class="i">i</th>' \
'<td class="i">3</td>' \
'</tr>' \
'<tr>' \
'<th class="s">s</th>' \
'<td class="s">c</td>' \
'</tr>' \
'</tbody>' \
'</table>' \
'<table xmlns="http://www.w3.org/1999/xhtml" class="CM">' \
'<tbody>' \
'<tr>' \
'<th class="i">i</th>' \
'<td class="i">4</td>' \
'</tr>' \
'<tr>' \
'<th class="s">s</th>' \
'<td class="s">d</td>' \
'</tr>' \
'</tbody>' \
'</table>' \
'</div>'
示例15: test_complex_array
def test_complex_array(self):
v = [CM(i=1, s="a"), CM(i=2, s="b"), CM(i=3, s="c"), CM(i=4, s="d")]
class SomeService(ServiceBase):
@srpc(_returns=Array(CM))
def some_call():
return v
app = Application([SomeService], "tns", in_protocol=HttpRpc(), out_protocol=HtmlRowTable())
server = WsgiApplication(app)
out_string = call_wsgi_app_kwargs(server)
show(html.fromstring(out_string), "TestHtmlRowTable.test_complex_array")
# FIXME: Needs a proper test with xpaths and all.
assert (
out_string == "<div>"
'<table class="CM">'
"<tbody>"
"<tr>"
'<th class="i">i</th>'
'<td class="i">1</td>'
"</tr>"
"<tr>"
'<th class="s">s</th>'
'<td class="s">a</td>'
"</tr>"
"</tbody>"
"</table>"
'<table class="CM">'
"<tbody>"
"<tr>"
'<th class="i">i</th>'
'<td class="i">2</td>'
"</tr>"
"<tr>"
'<th class="s">s</th>'
'<td class="s">b</td>'
"</tr>"
"</tbody>"
"</table>"
'<table class="CM">'
"<tbody>"
"<tr>"
'<th class="i">i</th>'
'<td class="i">3</td>'
"</tr>"
"<tr>"
'<th class="s">s</th>'
'<td class="s">c</td>'
"</tr>"
"</tbody>"
"</table>"
'<table class="CM">'
"<tbody>"
"<tr>"
'<th class="i">i</th>'
'<td class="i">4</td>'
"</tr>"
"<tr>"
'<th class="s">s</th>'
'<td class="s">d</td>'
"</tr>"
"</tbody>"
"</table>"
"</div>"
)