mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-06 10:25:17 +08:00
0493c66303
* Split test/test_components.py into test/components/test_*.py * Remove test/components/conftest.py because what it configures is already defined in pyproject.toml
33 lines
853 B
Python
33 lines
853 B
Python
import gradio as gr
|
|
|
|
|
|
class TestHTML:
|
|
def test_component_functions(self):
|
|
"""
|
|
get_config
|
|
"""
|
|
html_component = gr.components.HTML("#Welcome onboard", label="HTML Input")
|
|
assert html_component.get_config() == {
|
|
"value": "#Welcome onboard",
|
|
"label": "HTML Input",
|
|
"show_label": True,
|
|
"visible": True,
|
|
"elem_id": None,
|
|
"elem_classes": [],
|
|
"proxy_url": None,
|
|
"name": "html",
|
|
"_selectable": False,
|
|
"key": None,
|
|
}
|
|
|
|
def test_in_interface(self):
|
|
"""
|
|
Interface, process
|
|
"""
|
|
|
|
def bold_text(text):
|
|
return f"<strong>{text}</strong>"
|
|
|
|
iface = gr.Interface(bold_text, "text", "html")
|
|
assert iface("test") == "<strong>test</strong>"
|