|
@@ -1,4 +1,3 @@
|
|
|
-import pytest
|
|
|
from pytest import mark, raises
|
|
|
from bottle import template
|
|
|
|
|
@@ -6,7 +5,7 @@ from bottle import template
|
|
|
("""<optgroup label="Group">
|
|
|
<option value="val-to-backend" selected>val-displayed</option>
|
|
|
</optgroup>""", {
|
|
|
- "name": "Group", "options": [
|
|
|
+ "optgroup": "Group", "options": [
|
|
|
{
|
|
|
"value": "val-to-backend",
|
|
|
"selected": True,
|
|
@@ -14,7 +13,7 @@ from bottle import template
|
|
|
}, ] }),
|
|
|
("""<optgroup label="Group">
|
|
|
<option value="val-to-backend" disabled >val-to-backend</option>
|
|
|
-</optgroup>""", { "name": "Group", "options": [
|
|
|
+</optgroup>""", { "optgroup": "Group", "options": [
|
|
|
{
|
|
|
"value": "val-to-backend",
|
|
|
"disabled": True,
|
|
@@ -22,7 +21,7 @@ from bottle import template
|
|
|
("""<optgroup label="Group">
|
|
|
<option value="val1-to-backend" >val1</option>
|
|
|
<option value="val2-to-backend" disabled >val2-to-backend</option>
|
|
|
-</optgroup>""", { "name": "Group", "options": [
|
|
|
+</optgroup>""", { "optgroup": "Group", "options": [
|
|
|
{
|
|
|
"value": "val1-to-backend",
|
|
|
"display": "val1",
|
|
@@ -33,7 +32,7 @@ from bottle import template
|
|
|
}, ] }),
|
|
|
])
|
|
|
def test_optgroup_render_exact(expected, params):
|
|
|
- assert template('optgroup', **params) == expected
|
|
|
+ assert template('options', **params) == expected
|
|
|
|
|
|
|
|
|
@mark.parametrize('name', [
|
|
@@ -68,21 +67,21 @@ def test_optgroup_render_includes(name, value, selected, disabled, display):
|
|
|
exp_exceptions.append(ex)
|
|
|
|
|
|
if not exp_exceptions:
|
|
|
- assert template('optgroup', name=name, options=[ options, ]) is not None
|
|
|
- assert template('optgroup', name=name, options=[ options, options ]) is not None
|
|
|
+ assert template('options', optgroup=name, options=[ options, ]) is not None
|
|
|
+ assert template('options', optgroup=name, options=[ options, options ]) is not None
|
|
|
return
|
|
|
|
|
|
with raises(tuple(exp_exceptions)):
|
|
|
- template('optgroup', name=name, options=[ options, ]) is not None
|
|
|
+ template('options', optgroup=name, options=[ options, ]) is not None
|
|
|
|
|
|
with raises(tuple(exp_exceptions)):
|
|
|
- template('optgroup', name=name, options=[ options, options ]) is not None
|
|
|
+ template('options', optgroup=name, options=[ options, options ]) is not None
|
|
|
|
|
|
return
|
|
|
|
|
|
@mark.parametrize('name', [
|
|
|
- ({}, NameError, "name 'name' is not defined"),
|
|
|
- *[ { "name": v } for v in ("", "group", None)],
|
|
|
+ {},
|
|
|
+ *[ { "optgroup": v } for v in ("", "group", None)],
|
|
|
])
|
|
|
@mark.parametrize('options', [
|
|
|
({}, NameError, "name 'options' is not defined"),
|
|
@@ -100,10 +99,10 @@ def test_optgroup_render(name, options):
|
|
|
exp_exceptions.append(ex)
|
|
|
|
|
|
if not exp_exceptions:
|
|
|
- assert template('optgroup', **params) is not None
|
|
|
+ assert template('options', **params) is not None
|
|
|
return
|
|
|
|
|
|
with raises(tuple(exp_exceptions)):
|
|
|
- assert template('optgroup', **params) is not None
|
|
|
+ assert template('options', **params) is not None
|
|
|
|
|
|
return
|