本文整理汇总了Python中chisel.Application.pretty_output方法的典型用法代码示例。如果您正苦于以下问题:Python Application.pretty_output方法的具体用法?Python Application.pretty_output怎么用?Python Application.pretty_output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chisel.Application
的用法示例。
在下文中一共展示了Application.pretty_output方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_doc_group
# 需要导入模块: from chisel import Application [as 别名]
# 或者: from chisel.Application import pretty_output [as 别名]
def test_doc_group(self):
spec_parser = SpecParser('''\
action my_action1
group "My Group 1"
action my_action2
group "My Group 1"
action my_action3
group "My Group 2"
action my_action4
group
action my_action5
''')
app = Application()
app.pretty_output = True
app.add_request(DocAction())
app.add_request(Action(lambda ctx, req: {}, name='my_action1', spec=spec_parser))
app.add_request(Action(lambda ctx, req: {}, name='my_action2', spec=spec_parser))
app.add_request(Action(lambda ctx, req: {}, name='my_action3', spec=spec_parser))
app.add_request(Action(lambda ctx, req: {}, name='my_action4', spec=spec_parser))
app.add_request(Action(lambda ctx, req: {}, name='my_action5', spec=spec_parser))
app.add_request(Request(lambda environ, start_response: [], name='my_request1'))
app.add_request(Request(lambda environ, start_response: [], name='my_request2', doc_group='My Group 2'))
status, unused_headers, response = app.request('GET', '/doc')
html = response.decode('utf-8')
self.assertEqual(status, '200 OK')
html_expected = '''\
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>localhost:80</title>
<style type="text/css">
html, body, div, span, h1, h2, h3 p, a, table, tr, th, td, ul, li, p {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 1em;
vertical-align: baseline;
}
body, td, th {
background-color: white;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 10pt;
line-height: 1.2em;
color: black;
}
body {
margin: 1em;
}
h1, h2, h3 {
font-weight: bold;
}
h1 {
font-size: 1.6em;
margin: 1em 0 1em 0;
}
h2 {
font-size: 1.4em;
margin: 1.4em 0 1em 0;
}
h3 {
font-size: 1.2em;
margin: 1.5em 0 1em 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin: 1.2em 0 0 0;
}
th, td {
padding: 0.5em 1em 0.5em 1em;
text-align: left;
background-color: #ECF0F3;
border-color: white;
border-style: solid;
border-width: 2px;
}
th {
font-weight: bold;
}
p {
margin: 0.5em 0 0 0;
}
p:first-child {
margin: 0;
}
a {
color: #004B91;
#.........这里部分代码省略.........
示例2: test_page_enum
# 需要导入模块: from chisel import Application [as 别名]
# 或者: from chisel.Application import pretty_output [as 别名]
def test_page_enum(self):
parser = SpecParser('''\
# This is my enum
enum MyEnum
A
B
''')
app = Application()
app.pretty_output = True
app.add_request(DocAction())
app.add_request(DocPage(parser.types['MyEnum']))
status, unused_headers, response = app.request('GET', '/doc_MyEnum')
html = response.decode('utf-8')
self.assertEqual(status, '200 OK')
html_expected = '''\
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>MyEnum</title>
<style type="text/css">
html, body, div, span, h1, h2, h3 p, a, table, tr, th, td, ul, li, p {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 1em;
vertical-align: baseline;
}
body, td, th {
background-color: white;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 10pt;
line-height: 1.2em;
color: black;
}
body {
margin: 1em;
}
h1, h2, h3 {
font-weight: bold;
}
h1 {
font-size: 1.6em;
margin: 1em 0 1em 0;
}
h2 {
font-size: 1.4em;
margin: 1.4em 0 1em 0;
}
h3 {
font-size: 1.2em;
margin: 1.5em 0 1em 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin: 1.2em 0 0 0;
}
th, td {
padding: 0.5em 1em 0.5em 1em;
text-align: left;
background-color: #ECF0F3;
border-color: white;
border-style: solid;
border-width: 2px;
}
th {
font-weight: bold;
}
p {
margin: 0.5em 0 0 0;
}
p:first-child {
margin: 0;
}
a {
color: #004B91;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:active {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a.linktarget {
color: black;
}
a.linktarget:hover {
text-decoration: none;
}
#.........这里部分代码省略.........
示例3: test_page_urls
# 需要导入模块: from chisel import Application [as 别名]
# 或者: from chisel.Application import pretty_output [as 别名]
def test_page_urls(self):
app = Application()
app.pretty_output = True
@action(spec='''\
action my_action
input
int a
int b
output
int c
''')
def my_action(unused_ctx, req):
return {'c': req['a'] + req['b']}
app.add_request(DocPage(my_action, request_urls=[('GET', 'https://foo.com/my_action')]))
status, unused_headers, response = app.request('GET', '/doc_my_action')
html = response.decode('utf-8')
self.assertEqual(status, '200 OK')
html_expected = '''\
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>my_action</title>
<style type="text/css">
html, body, div, span, h1, h2, h3 p, a, table, tr, th, td, ul, li, p {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 1em;
vertical-align: baseline;
}
body, td, th {
background-color: white;
font-family: 'Helvetica', 'Arial', sans-serif;
font-size: 10pt;
line-height: 1.2em;
color: black;
}
body {
margin: 1em;
}
h1, h2, h3 {
font-weight: bold;
}
h1 {
font-size: 1.6em;
margin: 1em 0 1em 0;
}
h2 {
font-size: 1.4em;
margin: 1.4em 0 1em 0;
}
h3 {
font-size: 1.2em;
margin: 1.5em 0 1em 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin: 1.2em 0 0 0;
}
th, td {
padding: 0.5em 1em 0.5em 1em;
text-align: left;
background-color: #ECF0F3;
border-color: white;
border-style: solid;
border-width: 2px;
}
th {
font-weight: bold;
}
p {
margin: 0.5em 0 0 0;
}
p:first-child {
margin: 0;
}
a {
color: #004B91;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:active {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a.linktarget {
color: black;
#.........这里部分代码省略.........