Skip to content

Commit bbcb6b9

Browse files
Moved method out of the run_all_in_graph_and_eager_mode in utils_test.py (#1357)
1 parent 0f680e2 commit bbcb6b9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tensorflow_addons/image/utils_test.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,18 @@ def test_from_4D_image_with_invalid_data(self):
7676
img_utils.from_4D_image(tf.ones(shape=(2, 2, 4, 1)), tf.constant(2))
7777
)
7878

79-
def test_from_4D_image_with_invalid_shape(self):
80-
errors = (ValueError, tf.errors.InvalidArgumentError)
81-
for rank in 2, tf.constant(2):
82-
with self.subTest(rank=rank):
83-
with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
84-
img_utils.from_4D_image(tf.ones(shape=(2, 4)), rank)
8579

86-
with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
87-
img_utils.from_4D_image(tf.ones(shape=(2, 4, 1)), rank)
80+
@pytest.mark.parametrize("rank", [2, tf.constant(2)])
81+
def test_from_4d_image_with_invalid_shape(rank):
82+
errors = (ValueError, tf.errors.InvalidArgumentError)
83+
with pytest.raises(errors, match="`image` must be 4D tensor"):
84+
img_utils.from_4D_image(tf.ones(shape=(2, 4)), rank)
85+
86+
with pytest.raises(errors, match="`image` must be 4D tensor"):
87+
img_utils.from_4D_image(tf.ones(shape=(2, 4, 1)), rank)
8888

89-
with self.assertRaisesRegexp(errors, "`image` must be 4D tensor"):
90-
img_utils.from_4D_image(tf.ones(shape=(1, 2, 4, 1, 1)), rank)
89+
with pytest.raises(errors, match="`image` must be 4D tensor"):
90+
img_utils.from_4D_image(tf.ones(shape=(1, 2, 4, 1, 1)), rank)
9191

9292

9393
if __name__ == "__main__":

0 commit comments

Comments
 (0)