New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #27600 -- Improved the way the 'shell' command reads python code from stdin. #7681
Changes from 1 commit
fb2dd9a
fd30f66
b69a946
66e9814
2128a76
c3c851b
1d18ef4
8f47b1e
2136c3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import sys | ||
|
||
from django import __version__ | ||
from django.core.management import call_command | ||
from django.test import SimpleTestCase, mock | ||
|
@@ -18,6 +20,7 @@ def test_command_option(self): | |
self.assertEqual(len(logger), 1) | ||
self.assertEqual(logger[0], __version__) | ||
|
||
@unittest.skipIf(sys.platform == 'win32', "Python on Windows doesn't have working select().") | ||
@mock.patch('django.core.management.commands.shell.select') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these aren't necessary, you can pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how we could possibly pass an instance of OutputWrapper to For stdin, I did the same hack as in createsuperuser so it's more consistent. But if you want my own opinion, I would discourage adding production code that's supposed to be run only in the test environment, I thought this was commonly known as a bad practice but am not sure anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aha I found what you should be using for both: You could also open a second PR removing the hack from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohhh right, thanks a heap Adam, it works great 🎸 |
||
def test_stdin_read(self, select): | ||
with captured_stdin() as stdin, captured_stdout() as stdout: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not exactly true, its select() works, but not on file objects like stdin