-
Notifications
You must be signed in to change notification settings - Fork 24k
Re-enable TestNamedTensor.test_big_tensor_repr #29407
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
Conversation
Fixes #27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests
Fixes #27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests ghstack-source-id: ae5d443 Pull Request resolved: #29407
test/test_namedtensor.py
Outdated
expected = "{}, names={})".format(repr(unnamed_tensor)[:-1], named_tensor.names) | ||
self.assertEqual(repr(named_tensor), expected) | ||
names_tag = 'names={}'.format(named_tensor.names) | ||
self.assertTrue(names_tag in repr(named_tensor)) |
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.
nit: we could use assertRegexpMatches so that any error message would print both of the non-matching strings
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.
EDIT: That's a good idea, let me try that.
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.
It turns out there is something called assertIn
that solves this problem
Fixes #27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests
Fixes #27753. The bug was that random tensors print subtly differently. This causes the "names=" tag to appear in slightly different places; sometimes it is on the same line as the data, sometimes it is on different lines. For this test, we wanted to know the following: - printing a big named tensor's repr doesn't crash - a big named tensor's repr shows the names This PR changes the test to check those two things. Test Plan: - run existing tests ghstack-source-id: 88ca7b3 Pull Request resolved: #29407
Stack from ghstack:
Fixes #27753.
The bug was that random tensors print subtly differently. This causes
the "names=" tag to appear in slightly different places; sometimes it is
on the same line as the data, sometimes it is on different lines.
For this test, we wanted to know the following:
This PR changes the test to check those two things.
Test Plan:
Differential Revision: D18428657