Skip to content

Commit 26c94f6

Browse files
TensorFlow Hub Authorscopybara-github
authored andcommitted
cleanup of deprecated test methods
PiperOrigin-RevId: 716610454
1 parent a1bc26b commit 26c94f6

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

examples/half_plus_two/half_plus_two_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def testExportTool(self):
3434
module_path = os.path.join(self.get_temp_dir(), "half-plus-two-module")
3535

3636
export_tool_path = os.path.join(test_utils.test_srcdir(), EXPORT_TOOL_PATH)
37-
self.assertEquals(0, subprocess.call([export_tool_path, module_path]))
37+
self.assertEqual(0, subprocess.call([export_tool_path, module_path]))
3838

3939
# Test the Module computes (0.5*input + 2).
4040
with tf.Graph().as_default():

tensorflow_hub/compressed_module_resolver_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def testModuleDescriptor(self):
106106
http_resolver = compressed_module_resolver.HttpCompressedFileResolver()
107107
path = http_resolver(self.module_handle)
108108
desc = tf_utils.read_file_to_string(resolver._module_descriptor_file(path))
109-
self.assertRegexpMatches(
109+
self.assertRegex(
110110
desc, "Module: %s\n"
111111
"Download Time: .*\n"
112112
"Downloader Hostname: %s .PID:%d." % (re.escape(

tensorflow_hub/feature_column_v2_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def testLoadingDifferentFeatureColumnsFails(self):
175175

176176
# Loading of checkpoints from the first model into the second model should
177177
# fail.
178-
with self.assertRaisesRegexp(AssertionError,
178+
with self.assertRaisesRegex(AssertionError,
179179
".*not bound to checkpointed values.*"):
180180
model_2.load_weights(checkpoint_path).assert_consumed()
181181

tensorflow_hub/keras_layer_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ def test_keras_layer_logs_if_training_zero_variables(self):
803803
layer([[10.]])
804804
layer([[10.]])
805805
self.assertLen(logs.records, 1) # Duplicate logging is avoided.
806-
self.assertRegexpMatches(logs.records[0].msg, "zero trainable weights")
806+
self.assertRegex(logs.records[0].msg, "zero trainable weights")
807807
else:
808808
# Just test that it runs at all.
809809
layer([[10.]])

tensorflow_hub/resolver_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def testCacheDir(self):
8989
self.assertEqual(cache_dir, None)
9090
# Use temp dir.
9191
cache_dir = resolver.tfhub_cache_dir(use_temp=True)
92-
self.assertEquals(cache_dir,
92+
self.assertEqual(cache_dir,
9393
os.path.join(tempfile.gettempdir(), "tfhub_modules"))
9494
# Use override
9595
cache_dir = resolver.tfhub_cache_dir(default_cache_dir="/d", use_temp=True)
@@ -138,10 +138,10 @@ def testDirSize(self):
138138
self.assertEqual(0, resolver._locked_tmp_dir_size(fake_lock_filename))
139139

140140
def testLockFileName(self):
141-
self.assertEquals("/a/b/c.lock", resolver._lock_filename("/a/b/c/"))
141+
self.assertEqual("/a/b/c.lock", resolver._lock_filename("/a/b/c/"))
142142

143143
def testTempDownloadDir(self):
144-
self.assertEquals("/a/b.t.tmp", resolver._temp_download_dir("/a/b/", "t"))
144+
self.assertEqual("/a/b.t.tmp", resolver._temp_download_dir("/a/b/", "t"))
145145

146146
def testReadTaskUidFromLockFile(self):
147147
module_dir = os.path.join(self.get_temp_dir(), "module")
@@ -250,7 +250,7 @@ def fake_download_fn_with_rogue_behavior(handle, tmp_dir):
250250
self.assertEqual(
251251
sorted(tf.compat.v1.gfile.ListDirectory(parent_dir)),
252252
["module", "module.descriptor.txt"])
253-
self.assertRegexpMatches(
253+
self.assertRegex(
254254
tf_utils.read_file_to_string(
255255
resolver._module_descriptor_file(module_dir)), "Module: module\n"
256256
"Download Time: .*\n"
@@ -300,7 +300,7 @@ def fake_download_fn(handle, tmp_dir):
300300
self.assertEqual(
301301
sorted(tf.compat.v1.gfile.ListDirectory(parent_dir)),
302302
["module", "module.descriptor.txt"])
303-
self.assertRegexpMatches(
303+
self.assertRegex(
304304
tf_utils.read_file_to_string(
305305
resolver._module_descriptor_file(module_dir)), "Module: module\n"
306306
"Download Time: .*\n"

tensorflow_hub/tensor_info_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def testConvertTensors(self):
182182

183183
# check sparsity
184184
in1 = tf.compat.v1.sparse_placeholder(tf.int32, [])
185-
with self.assertRaisesRegexp(TypeError,
185+
with self.assertRaisesRegex(TypeError,
186186
"Got SparseTensor. Expected Tensor."):
187187
tensor_info.convert_dict_to_compatible_tensor({"a": in1}, targets)
188188

0 commit comments

Comments
 (0)