本文整理汇总了Python中oasis.lib.General.gen_q_html方法的典型用法代码示例。如果您正苦于以下问题:Python General.gen_q_html方法的具体用法?Python General.gen_q_html怎么用?Python General.gen_q_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oasis.lib.General
的用法示例。
在下文中一共展示了General.gen_q_html方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_instance_generate_multif_answer
# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q_html [as 别名]
def test_instance_generate_multif_answer():
""" Convert some html templates + variables into resulting instance HTML
and make sure it's doing it right. Focus on multif choice "ANSWER"
No side effects.
"""
tmpl = "blah<ANSWER1 MULTIF f,g,h,i>blah"
qvars = {'f': 7, 'g': "joe", "h": "3.4", "i": 33}
html = """blah<table border=0><tr><td>Please choose one:</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='1' Oa_CHK_1_1>7</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='2' Oa_CHK_1_2>joe</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='3' Oa_CHK_1_3>3.4</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='4' Oa_CHK_1_4>33</td></tr></table><br />
blah"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "blah<ANSWER1 MULTIF f,g,h,i,j>blah"
qvars = {'f': 7, 'g': "joe", "h": "3.4", "i": 33, "j": "&"}
html = """blah<table border=0><tr><td>Please choose one:</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='1' Oa_CHK_1_1>7</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='2' Oa_CHK_1_2>joe</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='3' Oa_CHK_1_3>3.4</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='4' Oa_CHK_1_4>33</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='5' Oa_CHK_1_5>&</td></tr></table><br />
blah"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "blah<ANSWER1 MULTIF f,g,h,"
qvars = {'f': 7, 'g': "joe", "h": "3.4", "i": 33, "j": "&"}
html = """blah<ANSWER1 MULTIF f,g,h,"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "blah<ANSWER1 MULTIF f,g,h,i,j>"
qvars = {'f': 7, 'g': "joe"}
html = """blah<table border=0><tr><td>Please choose one:</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='1' Oa_CHK_1_1>7</td><td CLASS='multichoicecell'><INPUT class='auto_save' TYPE='radio' NAME='ANS_1' VALUE='2' Oa_CHK_1_2>joe</td><FONT COLOR="red">ERROR IN QUESTION DATA</FONT><FONT COLOR="red">ERROR IN QUESTION DATA</FONT><FONT COLOR="red">ERROR IN QUESTION DATA</FONT></tr></table><br />\n"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
示例2: test_instance_generate_simple_answer
# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q_html [as 别名]
def test_instance_generate_simple_answer():
""" Convert some html templates + variables into resulting instance HTML
and make sure it's doing it right. Focus on simple "ANSWER"
No side effects.
"""
tmpl = "blah<ANSWER1>blah"
qvars = {}
html = """blah<INPUT class='auto_save' TYPE='text' NAME='ANS_1' VALUE="VAL_1"/>blah"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "blah<ANSWER2>blah"
qvars = {}
html = """blah<INPUT class='auto_save' TYPE='text' NAME='ANS_2' VALUE="VAL_2"/>blah"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "foo<ANSWER1>blah<ANSWER2>blah"
qvars = {}
html = """foo<INPUT class='auto_save' TYPE='text' NAME='ANS_1' VALUE="VAL_1"/>blah<INPUT class='auto_save' TYPE='text' NAME='ANS_2' VALUE="VAL_2"/>blah"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
示例3: test_instance_generate_variable
# 需要导入模块: from oasis.lib import General [as 别名]
# 或者: from oasis.lib.General import gen_q_html [as 别名]
def test_instance_generate_variable():
""" Convert some html templates + variables into resulting instance HTML
and make sure it's doing it right. Focus on variable subs.
No side effects.
"""
tmpl = "The value is <VAL A>"
qvars = {"A": 7, "a": 5, "Arthur": 3}
html = """The value is 7"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "The value is <VAL A> <VAL Arthur>"
qvars = {"A": 7, "a": 5, "Arthur": 3}
html = """The value is 7 3"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "The value is <VAL A> <VAL Arthur>"
qvars = {"A": "&", "a": 5, "Arthur": 3}
html = """The value is & 3"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "The value is <VAL A> <VAL Arthur>"
qvars = {"A": "<blink>annoying</blink>", "a": 5, "Arthur": 3}
html = """The value is <blink>annoying</blink> 3"""
res = General.gen_q_html(qvars, tmpl)
assert res == html
tmpl = "The value is <VAL A> <VAL Arthur>"
qvars = {"A": u"\x9f", "a": 5, "Arthur": 3}
html = u"""The value is \x9f 3"""
res = General.gen_q_html(qvars, tmpl)
assert res == html