From f797c21ed192cce5743abdc5c86a183f4bf89165 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Thu, 31 Oct 2024 10:01:58 -0500 Subject: [PATCH] test: fix test --- src/ape/pytest/runners.py | 25 ++++++++++++++++--------- tests/functional/test_project.py | 3 ++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ape/pytest/runners.py b/src/ape/pytest/runners.py index e41f724027..6ddac468d8 100644 --- a/src/ape/pytest/runners.py +++ b/src/ape/pytest/runners.py @@ -72,15 +72,22 @@ def pytest_exception_interact(self, report, call): # Else, it gets way too noisy. show_locals = not self.config_wrapper.show_internal - report.longrepr = call.excinfo.getrepr( - funcargs=True, - abspath=Path.cwd(), - showlocals=show_locals, - style="short", - tbfilter=False, - truncate_locals=True, - chain=False, - ) + try: + here = Path.cwd() + + except FileNotFoundError: + pass # In a temp-folder, most likely. + + else: + report.longrepr = call.excinfo.getrepr( + funcargs=True, + abspath=here, + showlocals=show_locals, + style="short", + tbfilter=False, + truncate_locals=True, + chain=False, + ) if self.config_wrapper.interactive and report.failed: traceback = call.excinfo.traceback[-1] diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index 256fdb841e..29f9dfb03e 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -680,9 +680,10 @@ def test_init_invalid_config(self): os.chdir(temp_dir) expected = r"[.\n]*Input should be a valid string\n-->1: name:\n 2: {asdf}[.\n]*" + weird_project = Project(temp_dir) try: with pytest.raises(ConfigError, match=expected): - _ = Project(temp_dir) + _ = weird_project.path finally: os.chdir(here)