Skip to content

tests: five POSIX-only fixtures (mkfifo, AF_UNIX, rmdir of the CWD) fail instead of skipping on Windows #2919

Open

Description

@sashankh

Summary

Five tests construct fixtures out of POSIX-only OS behaviour with no platform guard, so on
Windows they report as failures rather than skips:

FAILED tests/test_non_regular_files.py::test_fifo_is_rejected
    AttributeError: module 'os' has no attribute 'mkfifo'
FAILED tests/test_non_regular_files.py::test_unix_socket_is_rejected
    AttributeError: module 'socket' has no attribute 'AF_UNIX'
FAILED tests/test_non_regular_files.py::test_symlink_pointing_at_a_fifo_is_rejected
    AttributeError: module 'os' has no attribute 'mkfifo'
FAILED tests/test_watch.py::test_rebuild_code_deleted_cwd_without_repo_root_returns_false
    PermissionError: [WinError 32] The process cannot access the file because it is
    being used by another process: '...\\gone'
FAILED tests/test_watch.py::test_rebuild_code_deleted_cwd_uses_graphify_repo_root
    PermissionError: [WinError 32] ... '...\\gone'

In every case the exception is raised while building the fixture, before the code under
test is reached — os.mkfifo(...), socket.socket(socket.AF_UNIX, ...), and

os.chdir(gone)
gone.rmdir()          # POSIX unlinks a live CWD; Windows holds an open handle

This is the situation #2642 already described for symlinks:

A plain non-elevated Windows shell raises OSError: [WinError 1314], which pytest reports
as a FAILURE — 15 of them, drowning out real defects — when what it means is
"unsupported here".

tests/test_watch.py already skips ten tests with fcntl-only (POSIX), so the practice is
established; these five were simply missed.

Why it matters

They are not flaky or cosmetic — they are five permanent red entries in every Windows
contributor's run, sitting next to genuinely interesting Windows failures. Two of the three
test_non_regular_files.py cases can never pass on Windows by construction, so leaving them
red carries no information.

Also unguarded (currently passing by luck)

test_symlink_to_a_regular_file_is_accepted and test_broken_symlink_is_rejected_without_raising
call symlink_to() without the requires_symlinks fixture #2642 added. They pass on a
Windows box with Developer Mode enabled and fail with WinError 1314 on one without — the
exact case that fixture exists for.

Repro

Windows, any Python 3.10+:

python -m pytest tests/test_non_regular_files.py tests/test_watch.py -q

Actual: 5 failed. Expected: skipped with a platform reason.

Suggested fix

Extend the _can_symlink / requires_symlinks pair in tests/conftest.py with siblings for
the three capabilities involved — FIFOs, AF_UNIX binds, and removing a directory that is the
process CWD — and take them as fixture parameters on the affected tests.

Probing rather than testing sys.platform matters for the same reason it did in #2642:
Windows 10+ does support AF_UNIX and CPython exposes it on some builds, and a POSIX host can
still lack FIFOs when the temp dir is on a filesystem that has none. Hosts that can do these
things should keep the coverage.

Environment: Windows 11, Python 3.12.10, v8 @ b2cd362 (0.9.48).

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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions