Changes between Version 1 and Version 4 of Ticket #36479


Ignore:
Timestamp:
Jun 26, 2025, 4:53:13 AM (2 months ago)
Author:
Roelzkie
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36479

    • Property Has patch set
    • Property Cc Mike Edmunds added
  • Ticket #36479 – Description

    v1 v4  
    66
    77
    8 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.
     8However, 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.
    99
    10 The root issue is due to the `subprocess.run` command, which yields different `OSError` results on different OSes when the test reaches the [https://github.com/django/django/blob/68a45d9a8078db642f0aca7ddab33af6df7ebeb3/django/core/management/utils.py#L175-L177 `subprocess.run(["nonexistent", "--fast", "--"])]`.
     10The root issue is due to the `subprocess.run` command, which yields different `OSError` results on different OS's when the test reaches the [https://github.com/django/django/blob/68a45d9a8078db642f0aca7ddab33af6df7ebeb3/django/core/management/utils.py#L175-L177 `subprocess.run(["nonexistent", "--fast", "--"])`].
    1111
    12 For Darwin (at least on MacOS v14.7.2 - M1), it yields a `NotADirectoryError` / `OSError(20, "Not a directory")` which fails the test.
    13 For Linux, it yields a `FileNotFoundError` / `OSError(2, "File not found")` which passes the test.
     12For `darwin` (at least on MacOS v14.7.2 - M1), it yields a `NotADirectoryError` / `OSError(20, "Not a directory")` which fails the test.
     13For `linux`, it yields a `FileNotFoundError` / `OSError(2, "File not found")` which passes the test.
    1414
    15 Ideally this test should be able to handle it regardless of the machine platform.
     15Ideally, this test should be able to handle it regardless of the machine platform.
    1616
    17 See failed test full stacktrace: https://dpaste.org/pY48h
     17See failed test full stacktrace: https://dpaste.org/pY48h (link will expire, see result below instead).
     18
     19{{{
     20FAIL: test_run_formatters_handles_oserror_for_black_path (user_commands.tests.UtilsTests.test_run_formatters_handles_oserror_for_black_path) [FileNotFoundError]
     21----------------------------------------------------------------------
     22Traceback (most recent call last):
     23  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/unittest/case.py", line 58, in testPartExecutor
     24    yield
     25  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/unittest/case.py", line 556, in subTest
     26    yield
     27  File "/Users/user1/projects/django/tests/user_commands/tests.py", line 584, in test_run_formatters_handles_oserror_for_black_path
     28    self.assertIn(exception.__qualname__, parsed_error)
     29    ^^^^^^^
     30  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/unittest/case.py", line 1174, in assertIn
     31    self.fail(self._formatMessage(msg, standardMsg))
     32    ^^^^^^^^^^^
     33  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/unittest/case.py", line 732, in fail
     34    raise self.failureException(msg)
     35    ^^^^^^^^^^^^^^^
     36AssertionError: 'FileNotFoundError' not found in 'Formatters failed to launch:Traceback (most recent call last):
     37  File "/Users/user1/projects/django/django/core/management/utils.py", line 175, in run_formatters
     38    subprocess.run(
     39    ~~~~~~~~~~~~~~^
     40        [black_path, "--fast", "--", *written_files],
     41        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     42        capture_output=True,
     43        ^^^^^^^^^^^^^^^^^^^^
     44    )
     45    ^
     46  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/subprocess.py", line 556, in run
     47    with Popen(*popenargs, **kwargs) as process:
     48         ~~~~~^^^^^^^^^^^^^^^^^^^^^^
     49  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/subprocess.py", line 1038, in __init__
     50    self._execute_child(args, executable, preexec_fn, close_fds,
     51    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     52                        pass_fds, cwd, env,
     53                        ^^^^^^^^^^^^^^^^^^^
     54    ...<5 lines>...
     55                        gid, gids, uid, umask,
     56                        ^^^^^^^^^^^^^^^^^^^^^^
     57                        start_new_session, process_group)
     58                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     59  File "/Users/user1/.pyenv/versions/3.13.2/lib/python3.13/subprocess.py", line 1974, in _execute_child
     60    raise child_exception_type(errno_num, err_msg, err_filename)
     61NotADirectoryError: [Errno 20] Not a directory: \'nonexistent\''
     62
     63----------------------------------------------------------------------
     64}}}
     65
    1866
    1967Update: Please see https://github.com/django/django/pull/19591
Back to Top