Skip to content

Commit

Permalink
(chore) Refactor deprecated unittest aliases for Python 3.11 compatib…
Browse files Browse the repository at this point in the history
…ility. (tensorflow#5380)
  • Loading branch information
tirkarthi authored and yatbear committed Mar 27, 2023
1 parent d5219bc commit e16ff42
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion tensorboard/compat/tensorflow_stub/io/gfile_fsspec_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def testJoin(self):

def testComplexChaining(self):
path = "simplecache::zip://*::file://banana/bar"
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
errors.InvalidArgumentError,
"fsspec URL must only have paths in the last chained filesystem",
):
Expand Down
2 changes: 1 addition & 1 deletion tensorboard/data/experimental/experiment_from_dev_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def stream_experiment_data(request, **kwargs):
lambda api_endpoint: mock_api_client,
):
experiment = experiment_from_dev.ExperimentFromDev("789")
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError,
r"contains missing value\(s\).*different sets of "
r"steps.*pivot=False",
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/lazy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_repr_before_load(self):
def foo():
self.fail("Should not need to resolve this module.")

self.assertEquals(
self.assertEqual(
repr(foo), "<module 'foo' via LazyModule (not yet loaded)>"
)

Expand All @@ -76,7 +76,7 @@ def foo():
return collections

foo.namedtuple
self.assertEquals(
self.assertEqual(
repr(foo), "<%r via LazyModule (loaded)>" % collections
)

Expand Down
2 changes: 1 addition & 1 deletion tensorboard/plugins/debugger_v2/debugger_v2_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ def testServeStackFramesWithMissingStackFrameIdParamErrors(self):
self.assertEqual(
"application/json", response.headers.get("content-type")
)
self.assertRegexpMatches(
self.assertRegex(
json.loads(response.get_data())["error"],
"Not found: Cannot find stack frame with ID"
".*nonsense-stack-frame-id.*",
Expand Down
18 changes: 9 additions & 9 deletions tensorboard/plugins/hparams/list_session_groups_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def test_no_allowed_statuses(self):
aggregation_type: AGGREGATION_AVG
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups), 0)
self.assertEqual(len(response.session_groups), 0)

def test_some_allowed_statuses(self):
request = """
Expand All @@ -593,7 +593,7 @@ def test_some_allowed_statuses(self):
aggregation_type: AGGREGATION_AVG
"""
response = self._run_handler(request)
self.assertEquals(
self.assertEqual(
_reduce_to_names(response.session_groups),
[
("group_1", ["session_1"]),
Expand All @@ -610,7 +610,7 @@ def test_some_allowed_statuses_empty_groups(self):
aggregation_type: AGGREGATION_AVG
"""
response = self._run_handler(request)
self.assertEquals(
self.assertEqual(
_reduce_to_names(response.session_groups),
[("group_2", ["session_3"])],
)
Expand All @@ -629,7 +629,7 @@ def test_aggregation_median_current_temp(self):
aggregation_metric: { tag: "current_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down Expand Up @@ -663,7 +663,7 @@ def test_aggregation_median_delta_temp(self):
aggregation_metric: { tag: "delta_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down Expand Up @@ -697,7 +697,7 @@ def test_aggregation_max_current_temp(self):
aggregation_metric: { tag: "current_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down Expand Up @@ -731,7 +731,7 @@ def test_aggregation_max_delta_temp(self):
aggregation_metric: { tag: "delta_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down Expand Up @@ -765,7 +765,7 @@ def test_aggregation_min_current_temp(self):
aggregation_metric: { tag: "current_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down Expand Up @@ -799,7 +799,7 @@ def test_aggregation_min_delta_temp(self):
aggregation_metric: { tag: "delta_temp" }
"""
response = self._run_handler(request)
self.assertEquals(len(response.session_groups[1].metric_values), 2)
self.assertEqual(len(response.session_groups[1].metric_values), 2)
self.assertProtoEquals(
"""
name { tag: "current_temp" }
Expand Down
2 changes: 1 addition & 1 deletion tensorboard/plugins/mesh/demo_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_parse_vertex(self):

def test_prase_vertex_expects_colors(self):
"""Tests that method will throw error if color is not poresent."""
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError, "PLY file must contain vertices with colors"
):
demo_utils._parse_vertex("1 2 3")
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/uploader/exporter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ def stream_experiment_data(request, **kwargs):
# experiment_id.
with self.assertRaises(exporter_lib.GrpcTimeoutException) as cm:
next(generator)
self.assertEquals(cm.exception.experiment_id, experiment_id)
self.assertEqual(cm.exception.experiment_id, experiment_id)

def test_stream_experiment_data_passes_through_unexpected_exception(self):
# Setup: Client where:
Expand Down Expand Up @@ -758,7 +758,7 @@ def stream_experiment_data(request, **kwargs):
# Expect: The internal error is passed through.
with self.assertRaises(grpc.RpcError) as cm:
next(generator)
self.assertEquals(cm.exception.details(), "details string")
self.assertEqual(cm.exception.details(), "details string")

def test_handles_outdir_with_no_slash(self):
oldcwd = os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion tensorboard/uploader/uploader_subcommand_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def testListIntentSetsExperimentMask(self):
actual_mask = exporter_lib.list_experiments.call_args[1][
"fieldmask"
]
self.assertEquals(actual_mask, expected_mask)
self.assertEqual(actual_mask, expected_mask)


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions tensorboard/uploader/uploader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ def test_histogram_event_with_empty_tensor_content_errors_out(self):

mock_client = _create_mock_client()
sender = _create_tensor_request_sender("123", mock_client)
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError,
re.compile(
r"failed to upload a tensor.*malformation.*tag.*\'one\'.*step.*42",
Expand All @@ -1493,7 +1493,7 @@ def test_histogram_event_with_incorrect_tensor_shape_errors_out(self):

mock_client = _create_mock_client()
sender = _create_tensor_request_sender("123", mock_client)
with self.assertRaisesRegexp(
with self.assertRaisesRegex(
ValueError,
re.compile(
r"failed to upload a tensor.*malformation.*tag.*\'two\'.*step.*1337."
Expand Down

0 comments on commit e16ff42

Please sign in to comment.