diff --git a/htmd/site.py b/htmd/site.py index 900bd45..e3d61ad 100644 --- a/htmd/site.py +++ b/htmd/site.py @@ -21,22 +21,15 @@ def get_project_dir() -> Path: current_directory = Path.cwd() - while True: - file_path = current_directory / 'config.toml' - - if file_path.is_file(): - return current_directory - - # Move to the parent directory + while not (current_directory / 'config.toml').is_file(): parent_directory = current_directory.parent - # If the current and parent directories are the same, break the loop if current_directory == parent_directory: - break + return Path.cwd() current_directory = parent_directory - return Path.cwd() + return current_directory project_dir = get_project_dir() diff --git a/tests/test_preview.py b/tests/test_preview.py index 48db40f..bd926fc 100644 --- a/tests/test_preview.py +++ b/tests/test_preview.py @@ -148,7 +148,10 @@ def test_preview_reload_css(run_start: CliRunner) -> None: # noqa: ARG001 while after == before: try: response = requests.get(url, timeout=0.1) - except requests.exceptions.ReadTimeout: + except ( + requests.exceptions.ReadTimeout, + requests.exceptions.ConnectionError, + ): # happens during restart read_timeout = True else: @@ -182,7 +185,10 @@ def test_preview_reload_js(run_start: CliRunner) -> None: # noqa: ARG001 while after == before: try: response = requests.get(url, timeout=0.1) - except requests.exceptions.ReadTimeout: + except ( + requests.exceptions.ReadTimeout, + requests.exceptions.ConnectionError, + ): # happens during restart read_timeout = True else: