Skip to content

Commit

Permalink
Increase-test-coverage for keras_tensor
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal-Alsrheed committed Sep 22, 2023
1 parent 934b97a commit db1ebc5
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions keras_core/backend/common/keras_tensor_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,24 +362,26 @@ def test_rtruediv_method(self, mock_symbolic_call):
mock_symbolic_call.assert_called_once_with(y, x)
self.assertEqual(result, mock_tensor)

# TODO: FAILED Expected 'symbolic_call' to be called once but wasn't
# @patch("keras_core.ops.Divide.symbolic_call")
# def test_div_method(self, mock_symbolic_call):
# mock_tensor = Mock()
# mock_symbolic_call.return_value = mock_tensor
# x = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# y = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# result = x / y
# mock_symbolic_call.assert_called_once_with(x, y)
# self.assertEqual(result, mock_tensor)

# TODO: FAILED Expected 'symbolic_call' to be called once but wasn't
# @patch("keras_core.ops.Divide.symbolic_call")
# def test_rdiv_method(self, mock_symbolic_call):
# mock_tensor = Mock()
# mock_symbolic_call.return_value = mock_tensor
# x = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# y = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# result = y / x
# mock_symbolic_call.assert_called_once_with(y, x)
# self.assertEqual(result, mock_tensor)
@patch("keras_core.ops.Divide.symbolic_call")
def test_div_method(self, mock_symbolic_call):
"""Test __div__ method"""
mock_tensor = Mock()
mock_symbolic_call.return_value = mock_tensor
x = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
y = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# to ensure compatibility across Python versions
result = x.__div__(y)
mock_symbolic_call.assert_called_once_with(x, y)
self.assertEqual(result, mock_tensor)

@patch("keras_core.ops.Divide.symbolic_call")
def test_rdiv_method(self, mock_symbolic_call):
"""Test __rdiv__ method"""
mock_tensor = Mock()
mock_symbolic_call.return_value = mock_tensor
x = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
y = keras_tensor.KerasTensor(shape=(3, 4), dtype="float32")
# to ensure compatibility across Python versions
result = x.__rdiv__(y)
mock_symbolic_call.assert_called_once_with(y, x)
self.assertEqual(result, mock_tensor)

0 comments on commit db1ebc5

Please sign in to comment.