From 12eadc6a00a81e68989b0c4bb5b5ab464024b007 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Mon, 18 Feb 2019 00:37:00 +0000 Subject: [PATCH] Add test case for __rdiv__ in python 2 Signed-off-by: Yong Tang --- tensorflow/python/framework/tensor_shape_div_test.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tensorflow/python/framework/tensor_shape_div_test.py b/tensorflow/python/framework/tensor_shape_div_test.py index 8e63d7f5470..a4422c9b18a 100644 --- a/tensorflow/python/framework/tensor_shape_div_test.py +++ b/tensorflow/python/framework/tensor_shape_div_test.py @@ -35,6 +35,15 @@ class DimensionDivTest(test_util.TensorFlowTestCase): for y in values: self.assertEqual((x / y).value, (x // y).value) + def testRDivFail(self): + # Note: This test is related to GitHub issue 25790. + """Without from __future__ import division, __rdiv__ is used.""" + if six.PY2: # Old division exists only in Python 2 + two = tensor_shape.Dimension(2) + message = (r"unsupported operand type\(s\) for \/: " + r"'int' and 'Dimension', please use \/\/ instead") + with self.assertRaisesRegexp(TypeError, message): + _ = 6 / two if __name__ == "__main__": googletest.main()