Skip to content

Commit

Permalink
cleanup of deprecated test methods
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 716610454
  • Loading branch information
TensorFlow Hub Authors authored and copybara-github committed Jan 17, 2025
1 parent a1bc26b commit 26c94f6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/half_plus_two/half_plus_two_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def testExportTool(self):
module_path = os.path.join(self.get_temp_dir(), "half-plus-two-module")

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

# Test the Module computes (0.5*input + 2).
with tf.Graph().as_default():
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_hub/compressed_module_resolver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def testModuleDescriptor(self):
http_resolver = compressed_module_resolver.HttpCompressedFileResolver()
path = http_resolver(self.module_handle)
desc = tf_utils.read_file_to_string(resolver._module_descriptor_file(path))
self.assertRegexpMatches(
self.assertRegex(
desc, "Module: %s\n"
"Download Time: .*\n"
"Downloader Hostname: %s .PID:%d." % (re.escape(
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_hub/feature_column_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def testLoadingDifferentFeatureColumnsFails(self):

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

Expand Down
2 changes: 1 addition & 1 deletion tensorflow_hub/keras_layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def test_keras_layer_logs_if_training_zero_variables(self):
layer([[10.]])
layer([[10.]])
self.assertLen(logs.records, 1) # Duplicate logging is avoided.
self.assertRegexpMatches(logs.records[0].msg, "zero trainable weights")
self.assertRegex(logs.records[0].msg, "zero trainable weights")
else:
# Just test that it runs at all.
layer([[10.]])
Expand Down
10 changes: 5 additions & 5 deletions tensorflow_hub/resolver_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def testCacheDir(self):
self.assertEqual(cache_dir, None)
# Use temp dir.
cache_dir = resolver.tfhub_cache_dir(use_temp=True)
self.assertEquals(cache_dir,
self.assertEqual(cache_dir,
os.path.join(tempfile.gettempdir(), "tfhub_modules"))
# Use override
cache_dir = resolver.tfhub_cache_dir(default_cache_dir="/d", use_temp=True)
Expand Down Expand Up @@ -138,10 +138,10 @@ def testDirSize(self):
self.assertEqual(0, resolver._locked_tmp_dir_size(fake_lock_filename))

def testLockFileName(self):
self.assertEquals("/a/b/c.lock", resolver._lock_filename("/a/b/c/"))
self.assertEqual("/a/b/c.lock", resolver._lock_filename("/a/b/c/"))

def testTempDownloadDir(self):
self.assertEquals("/a/b.t.tmp", resolver._temp_download_dir("/a/b/", "t"))
self.assertEqual("/a/b.t.tmp", resolver._temp_download_dir("/a/b/", "t"))

def testReadTaskUidFromLockFile(self):
module_dir = os.path.join(self.get_temp_dir(), "module")
Expand Down Expand Up @@ -250,7 +250,7 @@ def fake_download_fn_with_rogue_behavior(handle, tmp_dir):
self.assertEqual(
sorted(tf.compat.v1.gfile.ListDirectory(parent_dir)),
["module", "module.descriptor.txt"])
self.assertRegexpMatches(
self.assertRegex(
tf_utils.read_file_to_string(
resolver._module_descriptor_file(module_dir)), "Module: module\n"
"Download Time: .*\n"
Expand Down Expand Up @@ -300,7 +300,7 @@ def fake_download_fn(handle, tmp_dir):
self.assertEqual(
sorted(tf.compat.v1.gfile.ListDirectory(parent_dir)),
["module", "module.descriptor.txt"])
self.assertRegexpMatches(
self.assertRegex(
tf_utils.read_file_to_string(
resolver._module_descriptor_file(module_dir)), "Module: module\n"
"Download Time: .*\n"
Expand Down
2 changes: 1 addition & 1 deletion tensorflow_hub/tensor_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def testConvertTensors(self):

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

Expand Down

0 comments on commit 26c94f6

Please sign in to comment.