Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced get/setattr in test_widgets with regular accesses #484

Merged
merged 1 commit into from
May 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TestBasicWidgets:

def test_input_type(self):
with pytest.raises(AttributeError):
getattr(Input(), "input_type")
Input().input_type

test_input = Input(input_type="test")
assert test_input.input_type == "test"
Expand Down Expand Up @@ -116,9 +116,9 @@ def test_checkbox_input(self, basic_widget_dummy_field):
== '<input checked id="id" name="bar" type="checkbox" value="v">'
)
# set falsy value to dummy field
setattr(basic_widget_dummy_field, "data", "")
basic_widget_dummy_field.data = ""
assert "checked" not in CheckboxInput()(basic_widget_dummy_field)
setattr(basic_widget_dummy_field, "data", False)
basic_widget_dummy_field.data = False
assert "checked" not in CheckboxInput()(basic_widget_dummy_field)

def test_radio_input(self, basic_widget_dummy_field):
Expand All @@ -132,9 +132,9 @@ def test_radio_input(self, basic_widget_dummy_field):

def test_textarea(self, basic_widget_dummy_field):
# Make sure textareas escape properly and render properly
setattr(basic_widget_dummy_field, "data", "hi<>bye")
setattr(basic_widget_dummy_field, "name", "f")
setattr(basic_widget_dummy_field, "id", "")
basic_widget_dummy_field.data = "hi<>bye"
basic_widget_dummy_field.name = "f"
basic_widget_dummy_field.id = ""
assert (
TextArea()(basic_widget_dummy_field)
== '<textarea id="" name="f">\r\nhi&lt;&gt;bye</textarea>'
Expand All @@ -153,7 +153,7 @@ def test_file(self, basic_widget_dummy_field):

class TestSelect:
def test_select(self, select_dummy_field):
setattr(select_dummy_field, "name", "f")
select_dummy_field.name = "f"

assert (
Select()(select_dummy_field)
Expand Down