From cff6db0039825acfffe5747259862aba9d7885f3 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 19 Nov 2018 11:39:00 +0000 Subject: [PATCH] tweak runserver when using --root (#211) * tweak runserver when using --root * uprev, assert message * tweak _find_app_path for backwards compatibility * fix tests --- HISTORY.rst | 5 +++++ aiohttp_devtools/runserver/config.py | 5 ++++- aiohttp_devtools/version.py | 2 +- tests/test_cli.py | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 89be6aca..84e8b065 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,11 @@ History ------- +0.10.4 (2018-11-18) +------------------- +* fix conflict with click checks that prevented the ``--root`` flag working properly, #206 +* uprev dependencies + 0.10.3 (2018-09-25) ------------------- * remove ``loop`` argument from ``run_app()``, #206 diff --git a/aiohttp_devtools/runserver/config.py b/aiohttp_devtools/runserver/config.py index 6960ef9b..be360f63 100644 --- a/aiohttp_devtools/runserver/config.py +++ b/aiohttp_devtools/runserver/config.py @@ -73,12 +73,15 @@ def static_path_str(self): return self.static_path and str(self.static_path) def _find_app_path(self, app_path: str) -> Path: + # for backwards compatibility try this first path = (self.root_path / app_path).resolve() + if not path.exists(): + path = Path(app_path).resolve() if path.is_file(): logger.debug('app_path is a file, returning it directly') return path - assert path.is_dir() + assert path.is_dir(), 'app_path {} is not a directory'.format(path) files = [x for x in path.iterdir() if x.is_file()] for std_file_name in STD_FILE_NAMES: try: diff --git a/aiohttp_devtools/version.py b/aiohttp_devtools/version.py index d667c66a..0cedbc34 100644 --- a/aiohttp_devtools/version.py +++ b/aiohttp_devtools/version.py @@ -2,4 +2,4 @@ __all__ = ['VERSION'] -VERSION = StrictVersion('0.10.3') +VERSION = StrictVersion('0.10.4') diff --git a/tests/test_cli.py b/tests/test_cli.py index 2e45fda9..11561e9e 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -30,7 +30,7 @@ def test_serve_no_args(): runner = CliRunner() result = runner.invoke(cli, ['serve']) assert result.exit_code == 2 - assert 'Error: Missing argument "path"' in result.output + assert 'error: missing argument "path"' in result.output.lower() def test_runserver(mocker): @@ -131,7 +131,7 @@ def test_start_no_args(): runner = CliRunner() result = runner.invoke(cli, ['start']) assert result.exit_code == 2 - assert 'Error: Missing argument "path"' in result.output + assert 'error: missing argument "path"' in result.output.lower() def test_start_help():