Download test/test_reload.py from Asukaa02/Gradio: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/Asukaa02/Gradio/resolve/main/test/test_reload.py
- Command line
-
hf download hf://Asukaa02/Gradio/test/test_reload.py
-
curl -L -o test_reload.py https://huggingface.co/Asukaa02/Gradio/resolve/main/test/test_reload.py
1.51 kB
| import dataclasses | |
| from pathlib import Path | |
| from typing import List | |
| import pytest | |
| import gradio | |
| import gradio as gr | |
| from gradio.networking import Server | |
| from gradio.reload import _setup_config | |
| def build_demo(): | |
| with gr.Blocks() as demo: | |
| gr.Textbox("") | |
| return demo | |
| class Config: | |
| filename: str | |
| path: Path | |
| watch_dirs: List[str] | |
| demo_name: str | |
| class TestReload: | |
| def argv(self): | |
| return ["demo/calculator/run.py"] | |
| def config(self, monkeypatch, argv) -> Config: | |
| monkeypatch.setattr("sys.argv", ["gradio"] + argv) | |
| return Config(*_setup_config()) | |
| def reloader(self, config): | |
| reloader = Server(config) | |
| reloader.should_exit = True | |
| yield reloader | |
| reloader.close() | |
| def test_config_default_app(self, config): | |
| assert config.filename == "demo.calculator.run" | |
| def test_config_custom_app(self, config): | |
| assert config.filename == "demo.calculator.run" | |
| assert config.demo_name == "test" | |
| def test_config_watch_gradio(self, config): | |
| gradio_dir = str(Path(gradio.__file__).parent) | |
| assert gradio_dir in config.watch_dirs | |
| def test_config_watch_app(self, config): | |
| demo_dir = str(Path("demo/calculator/run.py").resolve().parent) | |
| assert demo_dir in config.watch_dirs | |