From 8fc381f1011e2dfe7229618457908ecf127cbdba Mon Sep 17 00:00:00 2001 From: Blair Conrad Date: Wed, 16 Oct 2024 13:07:57 -0400 Subject: [PATCH] tests: Accommodate workdir test being run near filesystem root --- tests/test_context.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_context.py b/tests/test_context.py index 5253efe..e8389f8 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -96,4 +96,8 @@ def test_workdir_as_context_manager(monkeypatch: pytest.MonkeyPatch) -> None: records.append(failure.value.code) base = records[0] - assert records == [base, base - 1, base - 2, base - 3] + + # If the repository is checked out near the root of the filesystem, the working directory will + # eventually be the root, so cap the lowest depth at 1. + expected_depths = [max(1, base - offset) for offset in range(len(records))] + assert records == expected_depths