Opened 3 months ago
Last modified 2 months ago
#36479 closed Cleanup/optimization
Failing test for black formatter missing install simulation — at Initial Version
Reported by: | Roelzkie | Owned by: | Roelzkie |
---|---|---|---|
Component: | Core (Management commands) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Roelzkie, Mike Edmunds | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The test on test.user_commands.tests.UtilsTests.test_run_formatters_handles_oserror_for_black_path
attempts to assert a `FileNotFoundError` when simulating a missing black formatter installation.
./runtests.py user_commands.tests.UtilsTests.test_run_formatters_handles_oserror_for_black_path
However, it fails on the Darwin
platform, at least on MacOS v14.7.2 (Sonoma) M1 machine. I tested on a Linux platform, and the test passed.
The root issue is due to the subprocess.run
command, which yields different OSError
results on different OSes when the test reaches the `subprocess.run(["nonexistent", "--fast", "--")`]
For Darwin (at least on MacOS v14.7.2 - M1), it yields a NotADirectoryError
/ OSError(20, "Not a directory")
which fails the test.
For Linux, it yields a FileNotFoundError
/ OSError(2, "File not found")
which passes the test.
Ideally this test should be able to handle it regardless of the machine platform.
See failed test full stacktrace: https://dpaste.org/pY48h