#36479: Failing test for black formatter missing install simulation
-------------------------------+--------------------------------------
     Reporter:  Roelzkie       |                    Owner:  Roelzkie
         Type:  Bug            |                   Status:  assigned
    Component:  Uncategorized  |                  Version:  dev
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  1              |  Patch needs improvement:  0
Easy pickings:  1              |                    UI/UX:  0
-------------------------------+--------------------------------------
Changes (by Roelzkie):

 * needs_tests:  0 => 1


Old description:

> The test on
> `test.user_commands.tests.UtilsTests.test_run_formatters_handles_oserror_for_black_path`
> attempts to assert a
> [https://github.com/django/django/blob/main/tests/user_commands/tests.py#L569
> `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
> [https://github.com/django/django/blob/68a45d9a8078db642f0aca7ddab33af6df7ebeb3/django/core/management/utils.py#L175-L177
> `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

New description:

 The test on
 
`test.user_commands.tests.UtilsTests.test_run_formatters_handles_oserror_for_black_path`
 attempts to assert a
 [https://github.com/django/django/blob/main/tests/user_commands/tests.py#L569
 `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
 
[https://github.com/django/django/blob/68a45d9a8078db642f0aca7ddab33af6df7ebeb3/django/core/management/utils.py#L175-L177
 `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

 Update: Please see https://github.com/django/django/pull/19591

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36479#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070197a8320f79-a9a49634-cf92-401f-92d6-22d57ce4266f-000000%40eu-central-1.amazonses.com.

Reply via email to