Skip to content

abs_lambda_path returns native separators on Windows, failing its own unit test #8449

Description

@MohammedAlkindi

On Windows, tests/unit/test_shared_functions.py::test_abs_lambda_path_empty_envvar fails on an unmodified develop checkout (3bd47e2):

assert abs_lambda_path() == default_lambda_path
AssertionError: assert '\var\task' == '/var/task'

abs_lambda_path() builds its result with pathlib.Path, which is WindowsPath off-Linux and rewrites the separators. LAMBDA_TASK_ROOT is always POSIX-shaped because the runtime is Linux, so the value the docstring says is returned unchanged comes back as \var\task.

Deployed functions are unaffected. What it does affect is contributors running the suite on Windows, and the Redis-certs example in docs/utilities/idempotency.md, which interpolates f"{abs_lambda_path()}/certs/..." and so yields mixed separators. Your workflows are ubuntu-latest only, so CI cannot see either.

Possible solution: use PurePosixPath when LAMBDA_TASK_ROOT is set, keeping Path.cwd() for the unset case. test_abs_lambda_path_w_filename_envvar also needs its oracle corrected, since it currently builds the expected value with the same Path call. I have both working locally and can open a PR if useful.

To reproduce: check out develop on Windows and run pytest tests/unit/test_shared_functions.py -k abs_lambda_path.

AI-assisted; I reproduced this and ran the suite myself.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions