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
This commit is contained in:
parent
14f103960e
commit
7a4d633ba6
@ -263,9 +263,9 @@ class LockTestCase(test_base.BaseTestCase):
|
|||||||
# a semaphore will be yielded
|
# a semaphore will be yielded
|
||||||
with lockutils.lock("test") as sem:
|
with lockutils.lock("test") as sem:
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertTrue(isinstance(sem, threading._Semaphore))
|
self.assertIsInstance(sem, threading._Semaphore)
|
||||||
else:
|
else:
|
||||||
self.assertTrue(isinstance(sem, threading.Semaphore))
|
self.assertIsInstance(sem, threading.Semaphore)
|
||||||
|
|
||||||
# NOTE(flaper87): Lock is external so an InterProcessLock
|
# NOTE(flaper87): Lock is external so an InterProcessLock
|
||||||
# will be yielded.
|
# will be yielded.
|
||||||
@ -274,8 +274,8 @@ class LockTestCase(test_base.BaseTestCase):
|
|||||||
|
|
||||||
with lockutils.lock("test1",
|
with lockutils.lock("test1",
|
||||||
external=True) as lock1:
|
external=True) as lock1:
|
||||||
self.assertTrue(isinstance(lock1,
|
self.assertIsInstance(lock1,
|
||||||
lockutils.InterProcessLock))
|
lockutils.InterProcessLock)
|
||||||
finally:
|
finally:
|
||||||
if os.path.exists(lock_dir):
|
if os.path.exists(lock_dir):
|
||||||
shutil.rmtree(lock_dir, ignore_errors=True)
|
shutil.rmtree(lock_dir, ignore_errors=True)
|
||||||
@ -289,9 +289,9 @@ class LockTestCase(test_base.BaseTestCase):
|
|||||||
try:
|
try:
|
||||||
with lockutils.lock("test") as sem:
|
with lockutils.lock("test") as sem:
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
self.assertTrue(isinstance(sem, threading._Semaphore))
|
self.assertIsInstance(sem, threading._Semaphore)
|
||||||
else:
|
else:
|
||||||
self.assertTrue(isinstance(sem, threading.Semaphore))
|
self.assertIsInstance(sem, threading.Semaphore)
|
||||||
|
|
||||||
with lockutils.lock("test2", external=True) as lock:
|
with lockutils.lock("test2", external=True) as lock:
|
||||||
self.assertTrue(lock.exists())
|
self.assertTrue(lock.exists())
|
||||||
|
Loading…
Reference in New Issue
Block a user