mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Remove a use of exec (#35624)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/35624 Python 2 has reached end-of-life and is no longer supported by PyTorch. This test case is valid syntax in Python 3. Test Plan: CI Differential Revision: D20842877 Pulled By: dreiss fbshipit-source-id: 856e72171496aa1d517f2f27a8a5066462cf4f76
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7f7fdb1013
commit
2f4da7c00c
@ -162,12 +162,9 @@ class TestNamedTensor(TestCase):
|
||||
self.assertTrue(fully_named.has_names())
|
||||
|
||||
def test_py3_ellipsis(self):
|
||||
# Need to exec or else flake8 will complain about invalid python 2.
|
||||
tensor = torch.randn(2, 3, 5, 7)
|
||||
scope = {'tensor': tensor}
|
||||
code_str = "output = tensor.refine_names('N', ..., 'C')"
|
||||
exec(code_str, globals(), scope)
|
||||
self.assertEqual(scope['output'].names, ['N', None, None, 'C'])
|
||||
output = tensor.refine_names('N', ..., 'C')
|
||||
self.assertEqual(output.names, ['N', None, None, 'C'])
|
||||
|
||||
def test_refine_names(self):
|
||||
# Unnamed tensor -> Unnamed tensor
|
||||
|
Reference in New Issue
Block a user