def test_set_selected_option__deselect_others(self): select = Select() option1 = select.create_option("L1", selected=True) option2 = select.create_option("L2") select.selected_option = option2 assert_false(option1.selected) assert_is(option2, select.selected_option)
def test_set_selected_option(self): select = Select() select.create_option("L1") option = select.create_option("L2") select.create_option("L3") select.selected_option = option assert_true(option.selected) assert_is(option, select.selected_option)
def test_custom_title_element(self): head = Head() old_title = head.title old_child_count = len(head) new_title = Title() head.title = new_title assert_equal(old_child_count, len(head)) assert_is_not(old_title, head.title) assert_is(new_title, head.title)
def test_create_option__selected(self): select = Select() option = select.create_option("Option Label", "test-value", selected=True) assert_is(option, select.selected_option) assert_equal( '<select><option selected="selected" value="test-value">' 'Option Label</option></select>', str(select))
def test_set_selected_value(self): select = Select() select.create_option("L1", "v1") option = select.create_option("L2", "v2") select.create_option("L3", "v3") select.selected_value = "v2" assert_equal("v2", select.selected_value) assert_is(option, select.selected_option) assert_true(option.selected)
def test_get_selected_option__return_first(self): select = Select() option1 = Option("L1") option1.selected = True option2 = Option("L2") option2.selected = True select.append(option1) select.append(option2) assert_is(option1, select.selected_option)
def attributes(self) -> None: handler = StubHandler(self.environ, self.start_response) assert_is(self.environ, handler.request.environ) assert_is_instance(handler.request, Request) assert_is(self.start_response, handler.start_response)
def test_do_not_wrap_generator(self): other_gen = Generator() generator = generate_html_string(other_gen) assert_is(other_gen, generator)
def test_get_selected_option__in_option_group(self): select = Select() group = select.create_group("") option = group.create_option("") option.selected = True assert_is(option, select.selected_option)
def test_get_selected_option(self): select = Select() select.create_option("L1", "v1") option = select.create_option("L2", "v2", selected=True) select.create_option("L3", "v3") assert_is(option, select.selected_option)