Creating test case for printing ort tensor (#10850)

* creating a test for printing ort tensor

* modifying comment for error case

* Using Output Grabber to assert the print output

* modifying the print ort test

* removing comments

* removing sys import
This commit is contained in:
Abhishek Jindal 2022-03-11 21:39:48 -08:00 committed by GitHub
parent ce10d7d231
commit 03181caeae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,13 +120,12 @@ class OrtEPTests(unittest.TestCase):
ort_device = torch_ort.device(1)
assert 'My EP provider created, with device id: 0, some_option: val' in out.capturedtext
#disable the print test for now as we need to merge a PR to pytorch first.
#def test_print(self):
# x = torch.ones(1, 2)
# ort_x = x.to('ort')
# with OutputGrabber() as out:
# print(ort_x)
# assert "tensor([[1., 1.]], device='ort:0')" in out.capturedtext
def test_print(self):
x = torch.ones(1, 2)
ort_x = x.to('ort')
with OutputGrabber() as out:
print(ort_x)
assert "tensor([[1., 1.]], device='ort:0')" in out.capturedtext
if __name__ == '__main__':
unittest.main()