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
bpo-30109: Fix reindent.py #1207
Conversation
Skip the file if it has bad encoding. https://bugs.python.org/issue30109
Lib/test/test_tools/test_reindent.py
Outdated
@@ -23,6 +23,13 @@ def test_help(self): | |||
self.assertEqual(out, b'') | |||
self.assertGreater(err, b'') | |||
|
|||
def test_reindent_file_with_bad_encoding(self): | |||
bad_coding_path = os.path.join( | |||
os.path.dirname(os.path.realpath(__file__)), '../bad_coding.py') |
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.
os.path.join(..., os.pardir, 'bad_coding.py')
It is common also to use support.findfile()
.
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.
Thanks :) I changed to findfile()
.
Lib/test/test_tools/test_reindent.py
Outdated
os.path.dirname(os.path.realpath(__file__)), '../bad_coding.py') | ||
rc, out, err = assert_python_ok(self.script, '-r', bad_coding_path) | ||
self.assertEqual(out, b'') | ||
self.assertGreater(err, b'') |
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.
I think assertNotEqual()
is more appropriate here. It produces more detailed report for strings and perhaps will produce more detailed report for bytes in future.
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.
Changed to assertNotEqual
:)
Use support.findfile Use assertNotEqual
Thanks @serhiy-storchaka :) |
Skip the file if it has bad encoding. (cherry picked from commit 58f3c9d)
Skip the file if it has bad encoding. (cherry picked from commit 58f3c9d)
Thanks @Mariatta for the PR |
Sorry, @Mariatta, I could not cleanly backport this to |
Backport to 2.7 has been done in #5637. |
GH-5637 is a backport of this pull request to the 2.7 branch. |
Skip the file if it has bad encoding.
https://bugs.python.org/issue30109