gradio/test/test_buttons.py
Abubakar Abid 4729457929
Add a gr.ClearButton (#4456)
* clear button

* restore

* button in interface

* changelog

* fixes

* simplify

* changes

* components

* changed dropdown behavior

* fix label

* add tests

* update demos

* changelog

* changelog

* restore

* formatting

* revert dropdown

* frontend changes

* other fixes

* changelog

* update guide

* future

* fix tests

* fix tests

* fix tests

* changelog

* update guide
2023-06-13 19:18:14 -05:00

16 lines
565 B
Python

import gradio as gr
class TestClearButton:
def test_clear_event_setup_correctly(self):
with gr.Blocks() as demo:
chatbot = gr.Chatbot([("Hello", "How are you?")])
with gr.Row():
textbox = gr.Textbox(scale=3, interactive=True)
gr.ClearButton([textbox, chatbot], scale=1)
clear_event_trigger = demo.dependencies.pop()
assert not clear_event_trigger["backend_fn"]
assert clear_event_trigger["js"]
assert clear_event_trigger["outputs"] == [textbox._id, chatbot._id]