Skip to content
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-24780: unittest assertEqual difference output foiled by newlines #11548

Closed
wants to merge 3 commits into from

Conversation

nanjekyejoannah
Copy link
Contributor

@nanjekyejoannah nanjekyejoannah commented Jan 14, 2019

I have created a fix for this issue and relevant tests.

https://bugs.python.org/issue24780

@@ -1238,6 +1238,11 @@ def assertCountEqual(self, first, second, msg=None):
msg = self._formatMessage(msg, standardMsg)
self.fail(msg)

def addTrailingNewLine(self, line):
if line != '' and (line[-1] != '\n' or line[-1] != ' '):
line = line + '\n'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. line is a list here and this causes test failures due to TypeError. lines seems to be a better name since it makes me think it's a single line but it's actually a list of lines.

class AssertEqualTest(unittest.TestCase):

def test_trailing_new_line_at_end(self):
self.assertEqual("abc\n", "abc\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better test would be to test the output diff like https://github.com/python/cpython/blob/e709c1be97a04156c628f534116a236b9581aa2f/Lib/unittest/test/test_case.py#L1122 and it should be testing the failure cases and asserting the Exception output string.

@nanjekyejoannah
Copy link
Contributor Author

@tirkarthi I made the necessary updates to this PR.

@tirkarthi
Copy link
Member

Thanks @nanjekyejoannah, tests should be fixed as noted in https://github.com/python/cpython/pull/11548/files#r247392463 . The tests are about the strings being equal and are not related to the issue. The actual tests should be about the diff output for the tests.

@nanjekyejoannah
Copy link
Contributor Author

closed this. Someone can open another PR.

@mblahay
Copy link
Contributor

mblahay commented Apr 26, 2023

@nanjekyejoannah Why did you close the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants