Utilizes assertIn - tests/virt

Using assertTrue and the 'in' operator to test
if an element is in a sequence is too python2.4.
Our unit testing framework supports assertIn,
which was created for these types of tests.
Using assertIn will enhance readability of the test scripts.

Change-Id: Ifa0f7e12a1ba84052e1e64ed2775056fafd2b13b
This commit is contained in:
Zhongyue Luo
2013-10-12 11:28:15 +08:00
parent 8d8798efff
commit 1b49a8c6d3
10 changed files with 37 additions and 37 deletions

View File

@@ -140,7 +140,7 @@ class FakeLibvirtTests(test.NoDBTestCase):
blockstats = dom.blockStats('vda')
self.assertEqual(len(blockstats), 5)
for x in blockstats:
self.assertTrue(type(x) in [int, long])
self.assertIn(type(x), [int, long])
def test_attach_detach(self):
conn = self.get_openAuth_curry_func()('qemu:///system')
@@ -163,7 +163,7 @@ class FakeLibvirtTests(test.NoDBTestCase):
self.assertEqual(info[1], 128000)
self.assertTrue(info[2] <= 128000)
self.assertEqual(info[3], 1)
self.assertTrue(type(info[4]) in [int, long])
self.assertIn(type(info[4]), [int, long])
def test_createXML_runs_domain(self):
conn = self.get_openAuth_curry_func()('qemu:///system')