Fixed #35308 -- Caught and logged OSError when launching formatters.#18597
Fixed #35308 -- Caught and logged OSError when launching formatters.#18597nessita merged 1 commit intodjango:mainfrom
Conversation
nessita
left a comment
There was a problem hiding this comment.
Thank you @jacobtylerwalls! Great start 🌟
I added a few comments to iterate a bit on the logger and tests.
nessita
left a comment
There was a problem hiding this comment.
Thank you @jacobtylerwalls, I loved the proposal to use stderr. Added some further comments.
nessita
left a comment
There was a problem hiding this comment.
Almost there! Thank you!
|
@jacobtylerwalls Thank you for your work and patience on this one 🌟 I have replied to the outstanding comment: I wanted to push a solution myself, after attempting a rebase and squash, which resulted in many conflicts. Do you think you'd have some time to squash all commits into one and see if you have some ideas for the comment above? |
66dd051 to
08d9c77
Compare
|
@jacobtylerwalls Thank you for the latest work, the PR looks in great shape. I was thinking whether considering some unification for all the duplicated (new) tests make sense. Have you given this a thought? I can't decide whether the extra helper would make sense or be worth it. I toyed with this idea and came up with this option, but would like to know your thoughts: from io import StringIO
from unittest import mock
class AssertFormatterFailedToLaunch:
def __init__(self, test):
self.out = StringIO()
self.err = StringIO()
self.test = test
def __enter__(self):
self.mocker = mock.patch("django.core.management.utils.shutil.which", return_value="nonexistent")
self.mocker.start()
return self
def __exit__(self, exc_type, exc_value, traceback):
self.mocker.stop()
self.test.assertIn("Formatters failed to launch", self.err.getvalue())Then each new test would be: from user_commands.utils import AssertFormatterFailedToLaunch
def test_failure_to_format(self):
with AssertFormatterFailedToLaunch(self) as f:
call_command(
"startapp", "mynewapp", directory=self.test_dir, stdout=f.out, stderr=f.err
) |
|
That's interesting, and thanks for raising it. I did have a feeling this was too repetitive. Four of the tests are already in a I do need to be aware of the temporary migration module handling, so folding that in seemed nice, and then leaving one single test for |
I loved this proposal. Since you were on board, I doubled down on this mixing the two approaches. I like the result, so I'm pushing these changes, and if you don't object, I'll be merging this when CI is green. Thank you for indulging me! |
2419559 to
b0857f1
Compare
jacobtylerwalls
left a comment
There was a problem hiding this comment.
I think this works well! I left an idea about removing a parameter, but I'm also perfectly happy for you to merge it as is. Thanks for iterating with me.
b0857f1 to
af0141e
Compare
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
af0141e to
1136341
Compare
nessita
left a comment
There was a problem hiding this comment.
Thank you @jacobtylerwalls, this looks great! 🌟
I pushed the tiniest cleanup and now, for sure, will merge when CI is green 💯
It was updated in django/django#18597
It was updated in django/django#18597
Trac ticket number
ticket-35308
Branch description
Catch and log out OSError when black cannot be launched.
Checklist
mainbranch.