gradio/test/test_reload.py
Freddy Boulton 5c32ba31ba
Fix reload mode (#2992)
* Fix reload mode

* Add unit test

* Add to changelog
2023-01-16 12:17:41 -05:00

21 lines
671 B
Python

from pathlib import Path
from unittest.mock import patch
import gradio
from gradio.reload import run_in_reload_mode
@patch("gradio.reload.os.system")
@patch("gradio.reload.sys")
def test_run_in_reload_mode(mock_sys, mock_system_call):
mock_sys.argv = ["gradio", "demo/calculator/run.py"]
run_in_reload_mode()
reload_command = mock_system_call.call_args[0][0]
gradio_dir = Path(gradio.__file__).parent
demo_dir = Path("demo/calculator/run.py").resolve().parent
assert "uvicorn demo.calculator.run:demo.app" in reload_command
assert f'--reload-dir "{gradio_dir}"' in reload_command
assert f'--reload-dir "{demo_dir}"' in reload_command