From 3e6650f99ea1bdf2c64df5ac8554db2feb3f8ee4 Mon Sep 17 00:00:00 2001 From: Takashi Natsume Date: Sun, 4 Sep 2022 20:00:58 +0900 Subject: [PATCH] Fix misuse of assertTrue Replace assertTrue with assertEqual. Fix calling os.path.exists. Change-Id: I745df5af4f6a1fadb73c54b8ee31abfbda335fc4 Closes-Bug: 1988668 Signed-off-by: Takashi Natsume --- test/unit/common/test_db.py | 3 ++- test/unit/common/test_manager.py | 6 +++--- test/unit/common/test_storage_policy.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/unit/common/test_db.py b/test/unit/common/test_db.py index b7b4aa114b..8a3e11a804 100644 --- a/test/unit/common/test_db.py +++ b/test/unit/common/test_db.py @@ -421,7 +421,8 @@ class TestExampleBroker(unittest.TestCase): self.assertEqual(info['created_at'], created_at) self.assertEqual(info['put_timestamp'], recreate_timestamp) self.assertEqual(info['delete_timestamp'], delete_timestamp) - self.assertTrue(info['status_changed_at'], status_changed_at) + self.assertEqual(Timestamp(status_changed_at).normal, + info['status_changed_at']) def test_merge_timestamps_recreate_with_objects(self): put_timestamp = next(self.ts).internal diff --git a/test/unit/common/test_manager.py b/test/unit/common/test_manager.py index 0cccee94f2..f1784fc7fc 100644 --- a/test/unit/common/test_manager.py +++ b/test/unit/common/test_manager.py @@ -1023,7 +1023,7 @@ class TestServer(unittest.TestCase): running_pids = server.get_running_pids() for f in ('thing-sayer.pid', 'other-doer.pid', 'other-sayer.pid'): # other server pid files persist - self.assertTrue(os.path.exists, os.path.join(t, f)) + self.assertTrue(os.path.exists(os.path.join(t, f))) # verify that servers are in fact not running for server_name in ('thing-sayer', 'other-doer', 'other-sayer'): server = manager.Server(server_name, run_dir=t) @@ -1644,9 +1644,9 @@ class TestServer(unittest.TestCase): pids = server.stop(number=3) self.assertEqual(len(pids), 1) expected = { - 3: conf3, + 3: self.join_run_dir('account-reaper/3.pid'), } - self.assertTrue(pids, expected) + self.assertEqual(expected, pids) self.assertEqual(manager.os.pid_sigs[3], [signal.SIGTERM]) self.assertFalse(os.path.exists(conf4)) self.assertFalse(os.path.exists(conf3)) diff --git a/test/unit/common/test_storage_policy.py b/test/unit/common/test_storage_policy.py index 2fa28d5bd5..36a12850ee 100644 --- a/test/unit/common/test_storage_policy.py +++ b/test/unit/common/test_storage_policy.py @@ -756,7 +756,7 @@ class TestStoragePolicies(unittest.TestCase): policies = parse_storage_policies(orig_conf) self.assertEqual(policies.default, policies[1]) - self.assertTrue(policies[0].name, 'Policy-0') + self.assertEqual('zero', policies[0].name) bad_conf = self._conf(""" [storage-policy:0]