Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion aiohttp_devtools/runserver/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ async def src_reload(app: web.Application, path: Optional[str] = None) -> int:

is_html = None
if path:
path = str(Path(app[STATIC_URL]) / Path(path).relative_to(app[STATIC_PATH]))
try:
path = str(Path(app[STATIC_URL]) / Path(path).relative_to(app[STATIC_PATH]))
except ValueError as e:
aux_logger.warning('error resolving relative path: %s', e)
return 0
is_html = mimetypes.guess_type(path)[0] == 'text/html'

reloads = 0
Expand Down
12 changes: 12 additions & 0 deletions tests/test_runserver_serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ async def test_aux_reload_html_different():
assert ws.send_str.call_count == 0


async def test_aux_reload_no_static_path():
aux_app = Application()
ws = MagicMock()
ws.send_str = MagicMock(return_value=create_future())
aux_app[LAST_RELOAD] = [0, 0.]
aux_app[STATIC_PATH] = "."
aux_app[STATIC_URL] = "/static/"
aux_app[WS] = set(((ws, "/foo/bar"),)) # type: ignore[misc]
assert 0 == await src_reload(aux_app, '/path/to/static_files/foo/.bar.html.kate-swp')
assert ws.send_str.call_count == 0


async def test_aux_reload_runtime_error(smart_caplog):
aux_app = Application()
ws = MagicMock()
Expand Down