def test_assertLess(): # CHECK: the original assertLess method is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assertLess") as mock_method: ttc.TorchTestCase().assertLess(0, 1) mock_method.assert_called_once() # CHECK: assert_tensor_greater is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assert_tensor_less") as mock_method: ttc.TorchTestCase().assertLess(0, torch.ones(3)) mock_method.assert_called_once()
def test_assertGreaterEqual(): # CHECK: the original assertGreaterEqual method is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assertGreaterEqual") as mock_method: ttc.TorchTestCase().assertGreaterEqual(1, 0) mock_method.assert_called_once() # CHECK: assert_tensor_greater_equal is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assert_tensor_greater_equal") as mock_method: ttc.TorchTestCase().assertGreaterEqual(1, torch.zeros(3)) mock_method.assert_called_once()
def test_assertEqual(): # CHECK: assert_packed_sequence_equal is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assert_packed_sequence_equal") as mock_method: ttc.TorchTestCase().assertEqual( rnn.pack_padded_sequence(torch.FloatTensor([[1, 1], [1, 0]]), [2, 1]), rnn.pack_padded_sequence(torch.FloatTensor([[1, 1], [1, 0]]), [2, 1])) mock_method.assert_called_once() # CHECK: assert_parameter_equal is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assert_parameter_equal") as mock_method: ttc.TorchTestCase().assertEqual(nn.Parameter(torch.zeros(3)), nn.Parameter(torch.zeros(3))) mock_method.assert_called_once() # CHECK: assert_tensor_equal is invoked appropriately with mock.patch.object(ttc.TorchTestCase, "assert_tensor_equal") as mock_method: ttc.TorchTestCase().assertEqual(torch.zeros(3), torch.zeros(3)) mock_method.assert_called_once()
def setUp(self): self.test_case = ttc.TorchTestCase()