mirror of
https://github.com/gradio-app/gradio.git
synced 2025-03-31 12:20:26 +08:00
Allow gr.ClearButton
and gr.DuplicateButton
to be made hidden (and otherwise updated) (#6932)
* clear visible * test * other buttons * add changeset * move resource to block cache * revert * Revert "revert" This reverts commit 9830f253ac64fb747e3af2bb7ec7f2f565518eae. * notebook --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
c00da89c3e
commit
e671e5415f
5
.changeset/all-aliens-fetch.md
Normal file
5
.changeset/all-aliens-fetch.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Allow `gr.ClearButton` and `gr.DuplicateButton` to be made hidden (and otherwise updated)
|
File diff suppressed because one or more lines are too long
@ -164,15 +164,16 @@ with gr.Blocks() as demo:
|
||||
result = gr.Textbox(label="Are all cleared?")
|
||||
hide = gr.Button(value="Hide")
|
||||
reveal = gr.Button(value="Reveal")
|
||||
clear_button_and_components = components + [clear]
|
||||
hide.click(
|
||||
lambda: [c.__class__(visible=False) for c in components],
|
||||
lambda: [c.__class__(visible=False) for c in clear_button_and_components],
|
||||
inputs=[],
|
||||
outputs=components
|
||||
outputs=clear_button_and_components
|
||||
)
|
||||
reveal.click(
|
||||
lambda: [c.__class__(visible=True) for c in components],
|
||||
lambda: [c.__class__(visible=True) for c in clear_button_and_components],
|
||||
inputs=[],
|
||||
outputs=components
|
||||
outputs=clear_button_and_components
|
||||
)
|
||||
get_value = gr.Button(value="Get Values")
|
||||
get_value.click(evaluate_values, components, result)
|
||||
|
@ -9,6 +9,7 @@ from typing import Any, Literal
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
|
||||
from gradio.components import Button, Component
|
||||
from gradio.context import Context
|
||||
from gradio.data_classes import GradioModel, GradioRootModel
|
||||
from gradio.utils import resolve_singleton
|
||||
|
||||
@ -62,7 +63,9 @@ class ClearButton(Button):
|
||||
)
|
||||
self.api_name = api_name
|
||||
self.show_api = show_api
|
||||
self.add(components)
|
||||
|
||||
if Context.root_block:
|
||||
self.add(components)
|
||||
|
||||
def add(self, components: None | Component | list[Component]) -> ClearButton:
|
||||
"""
|
||||
|
@ -7,6 +7,7 @@ from typing import Literal
|
||||
from gradio_client.documentation import document, set_documentation_group
|
||||
|
||||
from gradio.components import Button
|
||||
from gradio.context import Context
|
||||
from gradio.utils import get_space
|
||||
|
||||
set_documentation_group("component")
|
||||
@ -71,7 +72,7 @@ class DuplicateButton(Button):
|
||||
scale=scale,
|
||||
min_width=min_width,
|
||||
)
|
||||
if _activate:
|
||||
if _activate and Context.root_block:
|
||||
self.activate()
|
||||
|
||||
def activate(self):
|
||||
|
@ -320,7 +320,7 @@ class ImageEditor(Component):
|
||||
# If an externally hosted image or a URL, don't convert to absolute path
|
||||
if self.proxy_url or client_utils.is_http_url_like(input_data):
|
||||
return input_data
|
||||
return str(utils.abspath(input_data))
|
||||
return self.move_resource_to_block_cache(input_data)
|
||||
|
||||
if input_data is None:
|
||||
return None
|
||||
|
@ -62,7 +62,7 @@ class LoginButton(Button):
|
||||
scale=scale,
|
||||
min_width=min_width,
|
||||
)
|
||||
if Context.root_block is not None:
|
||||
if Context.root_block:
|
||||
self.activate()
|
||||
else:
|
||||
warnings.warn(
|
||||
|
@ -20,3 +20,11 @@ test("gr.ClearButton clears every component's value", async ({ page }) => {
|
||||
await page.click("text=Get Values");
|
||||
await expect(page.getByLabel("Are all cleared?")).toHaveValue("True");
|
||||
});
|
||||
|
||||
test("gr.ClearButton can be made hidden and unhidden", async ({ page }) => {
|
||||
await page.click("text=Hide");
|
||||
const button = await page.locator("button", { hasText: "Clear" });
|
||||
await expect(button).toBeHidden();
|
||||
await page.click("text=Reveal");
|
||||
await expect(button).not.toBeHidden();
|
||||
});
|
||||
|
162
pnpm-lock.yaml
generated
162
pnpm-lock.yaml
generated
@ -1,4 +1,4 @@
|
||||
lockfileVersion: '6.0'
|
||||
lockfileVersion: '6.1'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
@ -262,16 +262,16 @@ importers:
|
||||
version: 2.0.0(@sveltejs/kit@1.26.0)
|
||||
'@sveltejs/kit':
|
||||
specifier: ^1.5.0
|
||||
version: 1.26.0(svelte@4.2.3)(vite@4.5.0)
|
||||
version: 1.26.0(svelte@4.2.2)(vite@4.5.0)
|
||||
prettier:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
prettier-plugin-svelte:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0(prettier@3.0.0)(svelte@4.2.3)
|
||||
version: 3.0.0(prettier@3.0.0)(svelte@4.2.2)
|
||||
svelte-check:
|
||||
specifier: ^3.0.1
|
||||
version: 3.4.4(@babel/core@7.23.3)(less@4.2.0)(postcss@8.4.27)(svelte@4.2.3)
|
||||
version: 3.4.4(@babel/core@7.23.3)(less@4.2.0)(postcss@8.4.27)(svelte@4.2.2)
|
||||
typescript:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.2
|
||||
@ -292,7 +292,7 @@ importers:
|
||||
version: 3.0.0
|
||||
mdsvex:
|
||||
specifier: ^0.11.0
|
||||
version: 0.11.0(svelte@4.2.3)
|
||||
version: 0.11.0(svelte@4.2.2)
|
||||
postcss:
|
||||
specifier: '>=8.3.3 <9.0.0'
|
||||
version: 8.4.27
|
||||
@ -305,7 +305,7 @@ importers:
|
||||
version: 2.0.2(@sveltejs/kit@1.27.6)
|
||||
'@sveltejs/kit':
|
||||
specifier: ^1.27.6
|
||||
version: 1.27.6(svelte@4.2.3)(vite@4.5.0)
|
||||
version: 1.27.6(svelte@4.2.2)(vite@4.5.0)
|
||||
'@tailwindcss/forms':
|
||||
specifier: ^0.5.0
|
||||
version: 0.5.0(tailwindcss@3.1.6)
|
||||
@ -6749,7 +6749,7 @@ packages:
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.0.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.26.0(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/kit': 1.26.0(svelte@4.2.2)(vite@4.5.0)
|
||||
import-meta-resolve: 2.2.2
|
||||
dev: true
|
||||
|
||||
@ -6758,7 +6758,7 @@ packages:
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.0.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.2)(vite@4.5.0)
|
||||
import-meta-resolve: 2.2.2
|
||||
dev: true
|
||||
|
||||
@ -6767,7 +6767,7 @@ packages:
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.5.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.2)(vite@4.5.0)
|
||||
dev: true
|
||||
|
||||
/@sveltejs/adapter-vercel@3.0.3(@sveltejs/kit@1.27.6):
|
||||
@ -6775,7 +6775,7 @@ packages:
|
||||
peerDependencies:
|
||||
'@sveltejs/kit': ^1.5.0
|
||||
dependencies:
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/kit': 1.27.6(svelte@4.2.2)(vite@4.5.0)
|
||||
'@vercel/nft': 0.23.1
|
||||
esbuild: 0.18.20
|
||||
transitivePeerDependencies:
|
||||
@ -6783,7 +6783,7 @@ packages:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@sveltejs/kit@1.26.0(svelte@4.2.3)(vite@4.5.0):
|
||||
/@sveltejs/kit@1.26.0(svelte@4.2.2)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-CV/AlTziC05yrz7UjVqEd0pH6+2dnrbmcnHGr2d3jXtmOgzNnlDkXtX8g3BfJ6nntsPD+0jtS2PzhvRHblRz4A==}
|
||||
engines: {node: ^16.14 || >=18}
|
||||
hasBin: true
|
||||
@ -6792,7 +6792,7 @@ packages:
|
||||
svelte: ^3.54.0 || ^4.0.0-next.0
|
||||
vite: ^4.0.0
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte': 2.5.2(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/vite-plugin-svelte': 2.5.2(svelte@4.2.2)(vite@4.5.0)
|
||||
'@types/cookie': 0.5.4
|
||||
cookie: 0.5.0
|
||||
devalue: 4.3.2
|
||||
@ -6803,7 +6803,7 @@ packages:
|
||||
sade: 1.8.1
|
||||
set-cookie-parser: 2.6.0
|
||||
sirv: 2.0.3
|
||||
svelte: 4.2.3
|
||||
svelte: 4.2.2
|
||||
tiny-glob: 0.2.9
|
||||
undici: 5.26.5
|
||||
vite: 4.5.0(@types/node@20.3.2)(less@4.2.0)(lightningcss@1.21.7)(sass@1.66.1)(stylus@0.62.0)(sugarss@4.0.1)
|
||||
@ -6811,7 +6811,7 @@ packages:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@sveltejs/kit@1.27.6(svelte@4.2.3)(vite@4.5.0):
|
||||
/@sveltejs/kit@1.27.6(svelte@4.2.2)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-GsjTkMbKzXdbeRg0tk8S7HNShQ4879ftRr0ZHaZfjbig1xQwG57Bvcm9U9/mpLJtCapLbLWUnygKrgcLISLC8A==}
|
||||
engines: {node: ^16.14 || >=18}
|
||||
hasBin: true
|
||||
@ -6820,7 +6820,7 @@ packages:
|
||||
svelte: ^3.54.0 || ^4.0.0-next.0 || ^5.0.0-next.0
|
||||
vite: ^4.0.0
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte': 2.5.2(svelte@4.2.3)(vite@4.5.0)
|
||||
'@sveltejs/vite-plugin-svelte': 2.5.2(svelte@4.2.2)(vite@4.5.0)
|
||||
'@types/cookie': 0.5.4
|
||||
cookie: 0.5.0
|
||||
devalue: 4.3.2
|
||||
@ -6831,7 +6831,7 @@ packages:
|
||||
sade: 1.8.1
|
||||
set-cookie-parser: 2.6.0
|
||||
sirv: 2.0.3
|
||||
svelte: 4.2.3
|
||||
svelte: 4.2.2
|
||||
tiny-glob: 0.2.9
|
||||
undici: 5.26.5
|
||||
vite: 4.5.0(@types/node@20.3.2)(less@4.2.0)(lightningcss@1.21.7)(sass@1.66.1)(stylus@0.62.0)(sugarss@4.0.1)
|
||||
@ -6853,6 +6853,21 @@ packages:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@sveltejs/vite-plugin-svelte-inspector@1.0.4(@sveltejs/vite-plugin-svelte@2.5.2)(svelte@4.2.2)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-zjiuZ3yydBtwpF3bj0kQNV0YXe+iKE545QGZVTaylW3eAzFr+pJ/cwK8lZEaRp4JtaJXhD5DyWAV4AxLh6DgaQ==}
|
||||
engines: {node: ^14.18.0 || >= 16}
|
||||
peerDependencies:
|
||||
'@sveltejs/vite-plugin-svelte': ^2.2.0
|
||||
svelte: ^3.54.0 || ^4.0.0
|
||||
vite: ^4.0.0
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte': 2.5.2(svelte@4.2.2)(vite@4.5.0)
|
||||
debug: 4.3.4
|
||||
svelte: 4.2.2
|
||||
vite: 4.5.0(@types/node@20.3.2)(less@4.2.0)(lightningcss@1.21.7)(sass@1.66.1)(stylus@0.62.0)(sugarss@4.0.1)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@sveltejs/vite-plugin-svelte-inspector@1.0.4(@sveltejs/vite-plugin-svelte@2.5.2)(svelte@4.2.3)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-zjiuZ3yydBtwpF3bj0kQNV0YXe+iKE545QGZVTaylW3eAzFr+pJ/cwK8lZEaRp4JtaJXhD5DyWAV4AxLh6DgaQ==}
|
||||
engines: {node: ^14.18.0 || >= 16}
|
||||
@ -6867,6 +6882,7 @@ packages:
|
||||
vite: 4.5.0(@types/node@20.3.2)(less@4.2.0)(lightningcss@1.21.7)(sass@1.66.1)(stylus@0.62.0)(sugarss@4.0.1)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@sveltejs/vite-plugin-svelte@2.5.2(svelte@4.2.2)(vite@4.3.9):
|
||||
resolution: {integrity: sha512-Dfy0Rbl+IctOVfJvWGxrX/3m6vxPLH8o0x+8FA5QEyMUQMo4kGOVIojjryU7YomBAexOTAuYf1RT7809yDziaA==}
|
||||
@ -6887,6 +6903,25 @@ packages:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@sveltejs/vite-plugin-svelte@2.5.2(svelte@4.2.2)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-Dfy0Rbl+IctOVfJvWGxrX/3m6vxPLH8o0x+8FA5QEyMUQMo4kGOVIojjryU7YomBAexOTAuYf1RT7809yDziaA==}
|
||||
engines: {node: ^14.18.0 || >= 16}
|
||||
peerDependencies:
|
||||
svelte: ^3.54.0 || ^4.0.0 || ^5.0.0-next.0
|
||||
vite: ^4.0.0
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte-inspector': 1.0.4(@sveltejs/vite-plugin-svelte@2.5.2)(svelte@4.2.2)(vite@4.5.0)
|
||||
debug: 4.3.4
|
||||
deepmerge: 4.3.1
|
||||
kleur: 4.1.5
|
||||
magic-string: 0.30.5
|
||||
svelte: 4.2.2
|
||||
svelte-hmr: 0.15.3(svelte@4.2.2)
|
||||
vite: 4.5.0(@types/node@20.3.2)(less@4.2.0)(lightningcss@1.21.7)(sass@1.66.1)(stylus@0.62.0)(sugarss@4.0.1)
|
||||
vitefu: 0.2.5(vite@4.5.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
/@sveltejs/vite-plugin-svelte@2.5.2(svelte@4.2.3)(vite@4.5.0):
|
||||
resolution: {integrity: sha512-Dfy0Rbl+IctOVfJvWGxrX/3m6vxPLH8o0x+8FA5QEyMUQMo4kGOVIojjryU7YomBAexOTAuYf1RT7809yDziaA==}
|
||||
engines: {node: ^14.18.0 || >= 16}
|
||||
@ -6905,6 +6940,7 @@ packages:
|
||||
vitefu: 0.2.5(vite@4.5.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/@tailwindcss/forms@0.5.0(tailwindcss@3.1.6):
|
||||
resolution: {integrity: sha512-KzWugryEBFkmoaYcBE18rs6gthWCFHHO7cAZm2/hv3hwD67AzwP7udSCa22E7R1+CEJL/FfhYsJWrc0b1aeSzw==}
|
||||
@ -12136,7 +12172,7 @@ packages:
|
||||
/mdn-data@2.0.30:
|
||||
resolution: {integrity: sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==}
|
||||
|
||||
/mdsvex@0.11.0(svelte@4.2.3):
|
||||
/mdsvex@0.11.0(svelte@4.2.2):
|
||||
resolution: {integrity: sha512-gJF1s0N2nCmdxcKn8HDn0LKrN8poStqAicp6bBcsKFd/zkUBGLP5e7vnxu+g0pjBbDFOscUyI1mtHz+YK2TCDw==}
|
||||
peerDependencies:
|
||||
svelte: '>=3 <5'
|
||||
@ -12144,7 +12180,7 @@ packages:
|
||||
'@types/unist': 2.0.10
|
||||
prism-svelte: 0.4.7
|
||||
prismjs: 1.29.0
|
||||
svelte: 4.2.3
|
||||
svelte: 4.2.2
|
||||
vfile-message: 2.0.4
|
||||
dev: false
|
||||
|
||||
@ -13275,17 +13311,6 @@ packages:
|
||||
dependencies:
|
||||
prettier: 3.0.0
|
||||
svelte: 4.2.2
|
||||
dev: false
|
||||
|
||||
/prettier-plugin-svelte@3.0.0(prettier@3.0.0)(svelte@4.2.3):
|
||||
resolution: {integrity: sha512-l3RQcPty2UBCoRh3yb9c5XCAmxkrc4BptAnbd5acO1gmSJtChOWkiEjnOvh7hvmtT4V80S8gXCOKAq8RNeIzSw==}
|
||||
peerDependencies:
|
||||
prettier: ^3.0.0
|
||||
svelte: ^3.2.0 || ^4.0.0-next.0
|
||||
dependencies:
|
||||
prettier: 3.0.0
|
||||
svelte: 4.2.3
|
||||
dev: true
|
||||
|
||||
/prettier@2.8.8:
|
||||
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
|
||||
@ -14639,34 +14664,6 @@ packages:
|
||||
- sass
|
||||
- stylus
|
||||
- sugarss
|
||||
dev: false
|
||||
|
||||
/svelte-check@3.4.4(@babel/core@7.23.3)(less@4.2.0)(postcss@8.4.27)(svelte@4.2.3):
|
||||
resolution: {integrity: sha512-Uys9+R65cj8TmP8f5UpS7B2xKpNLYNxEWJsA5ZoKcWq/uwvABFF7xS6iPQGLoa7hxz0DS6xU60YFpmq06E4JxA==}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
svelte: ^3.55.0 || ^4.0.0-next.0 || ^4.0.0
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.20
|
||||
chokidar: 3.5.3
|
||||
fast-glob: 3.3.2
|
||||
import-fresh: 3.3.0
|
||||
picocolors: 1.0.0
|
||||
sade: 1.8.1
|
||||
svelte: 4.2.3
|
||||
svelte-preprocess: 5.0.4(@babel/core@7.23.3)(less@4.2.0)(postcss@8.4.27)(svelte@4.2.3)(typescript@5.2.2)
|
||||
typescript: 5.2.2
|
||||
transitivePeerDependencies:
|
||||
- '@babel/core'
|
||||
- coffeescript
|
||||
- less
|
||||
- postcss
|
||||
- postcss-load-config
|
||||
- pug
|
||||
- sass
|
||||
- stylus
|
||||
- sugarss
|
||||
dev: true
|
||||
|
||||
/svelte-eslint-parser@0.32.2(svelte@4.2.2):
|
||||
resolution: {integrity: sha512-Ok9D3A4b23iLQsONrjqtXtYDu5ZZ/826Blaw2LeFZVTg1pwofKDG4mz3/GYTax8fQ0plRGHI6j+d9VQYy5Lo/A==}
|
||||
@ -14831,57 +14828,6 @@ packages:
|
||||
strip-indent: 3.0.0
|
||||
svelte: 4.2.2
|
||||
typescript: 5.2.2
|
||||
dev: false
|
||||
|
||||
/svelte-preprocess@5.0.4(@babel/core@7.23.3)(less@4.2.0)(postcss@8.4.27)(svelte@4.2.3)(typescript@5.2.2):
|
||||
resolution: {integrity: sha512-ABia2QegosxOGsVlsSBJvoWeXy1wUKSfF7SWJdTjLAbx/Y3SrVevvvbFNQqrSJw89+lNSsM58SipmZJ5SRi5iw==}
|
||||
engines: {node: '>= 14.10.0'}
|
||||
requiresBuild: true
|
||||
peerDependencies:
|
||||
'@babel/core': ^7.10.2
|
||||
coffeescript: ^2.5.1
|
||||
less: ^3.11.3 || ^4.0.0
|
||||
postcss: ^7 || ^8
|
||||
postcss-load-config: ^2.1.0 || ^3.0.0 || ^4.0.0
|
||||
pug: ^3.0.0
|
||||
sass: ^1.26.8
|
||||
stylus: ^0.55.0
|
||||
sugarss: ^2.0.0 || ^3.0.0 || ^4.0.0
|
||||
svelte: ^3.23.0 || ^4.0.0-next.0 || ^4.0.0
|
||||
typescript: '>=3.9.5 || ^4.0.0 || ^5.0.0'
|
||||
peerDependenciesMeta:
|
||||
'@babel/core':
|
||||
optional: true
|
||||
coffeescript:
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
postcss:
|
||||
optional: true
|
||||
postcss-load-config:
|
||||
optional: true
|
||||
pug:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
typescript:
|
||||
optional: true
|
||||
dependencies:
|
||||
'@babel/core': 7.23.3
|
||||
'@types/pug': 2.0.9
|
||||
detect-indent: 6.1.0
|
||||
less: 4.2.0
|
||||
magic-string: 0.27.0
|
||||
postcss: 8.4.27
|
||||
sorcery: 0.11.0
|
||||
strip-indent: 3.0.0
|
||||
svelte: 4.2.3
|
||||
typescript: 5.2.2
|
||||
dev: true
|
||||
|
||||
/svelte-range-slider-pips@2.0.1:
|
||||
resolution: {integrity: sha512-sCHvcTgi0ZYE4c/mwSsdALRsfuqEmpwTsSUdL+PUrumZ8u2gv1GKwZ3GohcAcTB6gfmqRBkyn6ujRXrOIga1gw==}
|
||||
|
@ -638,6 +638,16 @@ class TestImageEditor:
|
||||
"name": "imageeditor",
|
||||
}
|
||||
|
||||
def test_as_example(self):
|
||||
test_image_path = "test/test_files/bus.png"
|
||||
image_editor = gr.ImageEditor()
|
||||
example_value = image_editor.as_example(test_image_path)
|
||||
assert isinstance(example_value, dict)
|
||||
assert example_value["background"]
|
||||
assert utils.is_in_or_equal(
|
||||
example_value["background"], image_editor.GRADIO_CACHE
|
||||
)
|
||||
|
||||
|
||||
class TestImage:
|
||||
def test_component_functions(self, gradio_temp_dir):
|
||||
|
Loading…
x
Reference in New Issue
Block a user