From 7a4d633ba6ec37b29eb5adfaaad3f32452318d35 Mon Sep 17 00:00:00 2001 From: gecong1973 Date: Sat, 8 Oct 2016 09:30:32 +0800 Subject: Change assertTrue(isinstance()) by optimal assert Some of tests use different method of assertTrue(isinstance(A, B)) or assertEqual(type(A), B). The correct way is to use assertIsInstance(A, B) provided by testtools Change-Id: Iad2ee275837c28b40c1062386db5a29969ee98dc --- oslo_concurrency/tests/unit/test_lockutils.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/oslo_concurrency/tests/unit/test_lockutils.py b/oslo_concurrency/tests/unit/test_lockutils.py index 667028e..683d89f 100644 --- a/oslo_concurrency/tests/unit/test_lockutils.py +++ b/oslo_concurrency/tests/unit/test_lockutils.py @@ -263,9 +263,9 @@ class LockTestCase(test_base.BaseTestCase): # a semaphore will be yielded with lockutils.lock("test") as sem: if six.PY2: - self.assertTrue(isinstance(sem, threading._Semaphore)) + self.assertIsInstance(sem, threading._Semaphore) else: - self.assertTrue(isinstance(sem, threading.Semaphore)) + self.assertIsInstance(sem, threading.Semaphore) # NOTE(flaper87): Lock is external so an InterProcessLock # will be yielded. @@ -274,8 +274,8 @@ class LockTestCase(test_base.BaseTestCase): with lockutils.lock("test1", external=True) as lock1: - self.assertTrue(isinstance(lock1, - lockutils.InterProcessLock)) + self.assertIsInstance(lock1, + lockutils.InterProcessLock) finally: if os.path.exists(lock_dir): shutil.rmtree(lock_dir, ignore_errors=True) @@ -289,9 +289,9 @@ class LockTestCase(test_base.BaseTestCase): try: with lockutils.lock("test") as sem: if six.PY2: - self.assertTrue(isinstance(sem, threading._Semaphore)) + self.assertIsInstance(sem, threading._Semaphore) else: - self.assertTrue(isinstance(sem, threading.Semaphore)) + self.assertIsInstance(sem, threading.Semaphore) with lockutils.lock("test2", external=True) as lock: self.assertTrue(lock.exists()) -- cgit v1.2.1