-
Notifications
You must be signed in to change notification settings - Fork 617
Closed
Labels
Description
In image/filters_test.py, there are some buggy test cases:
- There are some patterns like
addons/tensorflow_addons/image/filters_test.py
Lines 60 to 63 in 6bb0d4b
with self.assertRaisesRegexp(TypeError, 'Size of the filter must be Integers'): median_filter2d(tf_img, (3.5, 3)) median_filter2d(tf_img, (None, 3))
However, this is not safe because each context manager will catch only one exception, and then exit. That it, the following code snippet will pass the test:
def foo(x):
if x < 5:
raise ValueError("fail " + str(x))
class Test(tf.test.TestCase):
def test_context_manager(self):
with self.assertRaisesRegexp(ValueError, "fail 3"):
foo(3)
foo(2)
foo(1)
with self.assertRaises(ValueError):
foo(5)
foo(4)
foo(3)- One test case disables eager execution, but this will affect all test cases (in the same file) executed after it.
addons/tensorflow_addons/image/filters_test.py
Lines 71 to 75 in 6bb0d4b
def test_dimension(self): tf.compat.v1.disable_eager_execution() tf_img = tf.compat.v1.placeholder(tf.int32, shape=[3, 4, None]) tf_img1 = tf.compat.v1.placeholder(tf.int32, shape=[3, None, 4]) tf_img2 = tf.compat.v1.placeholder(tf.int32, shape=[None, 3, 4])
In other words,test_check_eagerwill fail in this toy test case.
class Test(tf.test.TestCase):
# Make it execute first
def test_a(self):
tf.compat.v1.disable_eager_execution()
tf.compat.v1.placeholder(tf.float32, shape=(1, 2, None))
def test_check_eager(self):
if not tf.executing_eagerly():
raise Exception("Not in eager mode")This might not be what we want. In order to utilize tf.compat.v1.placeholder, which can be used to test None shape, in tf2.0, maybe @run_deprecated_v1 is helpful enough.
facaiy, seanpmorgan and Mainak431