diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-03-06 15:11:28 -0800 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-03-11 08:09:23 +0000 |
commit | 9a6dafd569db0d0b5dc9d7b5b34b17e3f411a9ee (patch) | |
tree | 3459a0c6df3fd09548daa9c315145dd2aaf03775 | |
parent | f70cead5eb928954908de48300cc7a9c88430c0f (diff) |
Tests: use self.assertNotIn().
Many tests use self.assertEqual(error.find("failed"), -1)
Use self.assertNotIn("failed", error) to provide more meaningful errors such as
AssertionError: 'Failed' not found in '' instead of 0 != -1.
Change-Id: I670acdc977b788b2cedf94cfeafc12097781463f
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
-rw-r--r-- | test/test_bier.py | 2 | ||||
-rw-r--r-- | test/test_bihash.py | 4 | ||||
-rw-r--r-- | test/test_bond.py | 10 | ||||
-rw-r--r-- | test/test_fib.py | 2 | ||||
-rw-r--r-- | test/test_ip_mcast.py | 2 | ||||
-rw-r--r-- | test/test_nat.py | 4 | ||||
-rw-r--r-- | test/test_p2p_ethernet.py | 14 | ||||
-rw-r--r-- | test/test_sctp.py | 4 | ||||
-rw-r--r-- | test/test_session.py | 6 | ||||
-rw-r--r-- | test/test_string.py | 2 | ||||
-rw-r--r-- | test/test_tcp.py | 6 | ||||
-rw-r--r-- | test/test_udp.py | 4 | ||||
-rw-r--r-- | test/test_vhost.py | 10 |
13 files changed, 35 insertions, 35 deletions
diff --git a/test/test_bier.py b/test/test_bier.py index 5a2c51c1708..9a9db3b0b6e 100644 --- a/test/test_bier.py +++ b/test/test_bier.py @@ -29,7 +29,7 @@ class TestBFIB(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("Failed"), -1) + self.assertNotIn("Failed", error) class TestBier(VppTestCase): diff --git a/test/test_bihash.py b/test/test_bihash.py index ff2a898dae3..6ccf6c25123 100644 --- a/test/test_bihash.py +++ b/test/test_bihash.py @@ -25,7 +25,7 @@ class TestBihash(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn('failed', error) def test_bihash_thread(self): """ Bihash Thread Test """ @@ -34,7 +34,7 @@ class TestBihash(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn('failed', error) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) diff --git a/test/test_bond.py b/test/test_bond.py index c1dcb92cbb5..533038e658a 100644 --- a/test/test_bond.py +++ b/test/test_bond.py @@ -228,8 +228,8 @@ class TestBondInterface(VppTestCase): # verify both interfaces in the show ifs = self.vapi.cli("show interface") - self.assertNotEqual(ifs.find('BondEthernet0'), -1) - self.assertNotEqual(ifs.find('BondEthernet1'), -1) + self.assertIn('BondEthernet0', ifs) + self.assertIn('BondEthernet1', ifs) # verify they are in the dump also if_dump = self.vapi.sw_interface_bond_dump() @@ -244,10 +244,10 @@ class TestBondInterface(VppTestCase): ifs = self.vapi.cli("show interface") # verify BondEthernet0 still in the show - self.assertNotEqual(ifs.find('BondEthernet0'), -1) + self.assertIn('BondEthernet0', ifs) # verify BondEthernet1 not in the show - self.assertEqual(ifs.find('BondEthernet1'), -1) + self.assertNotIn('BondEthernet1', ifs) # verify BondEthernet1 is not in the dump if_dump = self.vapi.sw_interface_bond_dump() @@ -264,7 +264,7 @@ class TestBondInterface(VppTestCase): # verify BondEthernet0 not in the show ifs = self.vapi.cli("show interface") - self.assertEqual(ifs.find('BondEthernet0'), -1) + self.assertNotIn('BondEthernet0', ifs) # verify BondEthernet0 is not in the dump if_dump = self.vapi.sw_interface_bond_dump() diff --git a/test/test_fib.py b/test/test_fib.py index 6b597465796..2f4d7265cf4 100644 --- a/test/test_fib.py +++ b/test/test_fib.py @@ -14,7 +14,7 @@ class TestFIB(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("Failed"), -1) + self.assertNotIn("Failed", error) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) diff --git a/test/test_ip_mcast.py b/test/test_ip_mcast.py index cca4f802089..41c6f3bdcaa 100644 --- a/test/test_ip_mcast.py +++ b/test/test_ip_mcast.py @@ -34,7 +34,7 @@ class TestMFIB(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("Failed"), -1) + self.assertNotIn("Failed", error) class TestIPMcast(VppTestCase): diff --git a/test/test_nat.py b/test/test_nat.py index e368fe032cc..0ef30267088 100644 --- a/test/test_nat.py +++ b/test/test_nat.py @@ -7285,9 +7285,9 @@ class TestNAT64(MethodHolder): self.assertTrue(pg1_found) features = self.vapi.cli("show interface features pg0") - self.assertNotEqual(features.find('nat64-in2out'), -1) + self.assertIn('nat64-in2out', features) features = self.vapi.cli("show interface features pg1") - self.assertNotEqual(features.find('nat64-out2in'), -1) + self.assertIn('nat64-out2in', features) self.vapi.nat64_add_del_interface(self.pg0.sw_if_index, is_add=0) self.vapi.nat64_add_del_interface(self.pg1.sw_if_index, is_add=0) diff --git a/test/test_p2p_ethernet.py b/test/test_p2p_ethernet.py index b0d546e4d1f..5200e482b04 100644 --- a/test/test_p2p_ethernet.py +++ b/test/test_p2p_ethernet.py @@ -48,22 +48,22 @@ class P2PEthernetAPI(VppTestCase): self.create_p2p_ethernet(self.pg0, 2, "de:ad:00:00:00:02") intfs = self.vapi.cli("show interface") - self.assertNotEqual(intfs.find('pg0.1'), -1) - self.assertNotEqual(intfs.find('pg0.2'), -1) - self.assertEqual(intfs.find('pg0.5'), -1) + self.assertIn('pg0.1', intfs) + self.assertIn('pg0.2', intfs) + self.assertNotIn('pg0.5', intfs) # create pg2.5 subif self.create_p2p_ethernet(self.pg0, 5, "de:ad:00:00:00:ff") intfs = self.vapi.cli("show interface") - self.assertNotEqual(intfs.find('pg0.5'), -1) + self.assertIn('pg0.5', intfs) # delete pg2.5 subif self.delete_p2p_ethernet(self.pg0, "de:ad:00:00:00:ff") intfs = self.vapi.cli("show interface") - self.assertNotEqual(intfs.find('pg0.1'), -1) - self.assertNotEqual(intfs.find('pg0.2'), -1) - self.assertEqual(intfs.find('pg0.5'), -1) + self.assertIn('pg0.1', intfs) + self.assertIn('pg0.2', intfs) + self.assertNotIn('pg0.5', intfs) self.logger.info("FFP_TEST_FINISH_0000") diff --git a/test/test_sctp.py b/test/test_sctp.py index d7efc8c9353..70201eba360 100644 --- a/test/test_sctp.py +++ b/test/test_sctp.py @@ -66,7 +66,7 @@ class TestSCTP(VppTestCase): "no-echo uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) error = self.vapi.cli("test echo client mbytes 10 no-return " + " appns 1" + @@ -76,7 +76,7 @@ class TestSCTP(VppTestCase): " uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) # Delete inter-table routes ip_t01.remove_vpp_config() diff --git a/test/test_session.py b/test/test_session.py index 5f4f3f5cfba..afea5f6a90d 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -68,14 +68,14 @@ class TestSession(VppTestCase): "private-segment-size 1m uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) error = self.vapi.cli("test echo client nclients 100 appns 1 " + "no-output fifo-size 64 syn-timeout 2 " + "private-segment-size 1m uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) if self.vpp_dead: self.assert_equal(0) @@ -98,7 +98,7 @@ class TestSessionUnitTests(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) def tearDown(self): super(TestSessionUnitTests, self).tearDown() diff --git a/test/test_string.py b/test/test_string.py index b44489e3038..cfdec1fdbac 100644 --- a/test/test_string.py +++ b/test/test_string.py @@ -35,7 +35,7 @@ class TestString(VppTestCase): error = self.vapi.cli("test string " + name) if error.find("failed") != -1: self.logger.critical("FAILURE in the " + name + " test") - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) diff --git a/test/test_tcp.py b/test/test_tcp.py index 5f2bce5ae63..b7ce596bdd9 100644 --- a/test/test_tcp.py +++ b/test/test_tcp.py @@ -66,14 +66,14 @@ class TestTCP(VppTestCase): uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) error = self.vapi.cli("test echo client mbytes 10 appns 1 " + "fifo-size 4 no-output test-bytes " + "syn-timeout 2 uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) # Delete inter-table routes ip_t01.remove_vpp_config() @@ -97,7 +97,7 @@ class TestTCPUnitTests(VppTestCase): if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) if __name__ == '__main__': unittest.main(testRunner=VppTestRunner) diff --git a/test/test_udp.py b/test/test_udp.py index a52ba27f64e..d0ad23fb230 100644 --- a/test/test_udp.py +++ b/test/test_udp.py @@ -293,14 +293,14 @@ class TestUDP(VppTestCase): "uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) error = self.vapi.cli("test echo client mbytes 10 appns 1 " + "fifo-size 4 no-output test-bytes " + "syn-timeout 2 no-return uri " + uri) if error: self.logger.critical(error) - self.assertEqual(error.find("failed"), -1) + self.assertNotIn("failed", error) # Delete inter-table routes ip_t01.remove_vpp_config() diff --git a/test/test_vhost.py b/test/test_vhost.py index 469fadaf2cd..9a938214060 100644 --- a/test/test_vhost.py +++ b/test/test_vhost.py @@ -35,8 +35,8 @@ class TesVhostInterface(VppTestCase): # verify both interfaces in the show ifs = self.vapi.cli("show interface") - self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1) - self.assertNotEqual(ifs.find('VirtualEthernet0/0/1'), -1) + self.assertIn('VirtualEthernet0/0/0', ifs) + self.assertIn('VirtualEthernet0/0/1', ifs) # verify they are in the dump also if_dump = self.vapi.sw_interface_vhost_user_dump() @@ -51,10 +51,10 @@ class TesVhostInterface(VppTestCase): ifs = self.vapi.cli("show interface") # verify VirtualEthernet0/0/0 still in the show - self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1) + self.assertIn('VirtualEthernet0/0/0', ifs) # verify VirtualEthernet0/0/1 not in the show - self.assertEqual(ifs.find('VirtualEthernet0/0/1'), -1) + self.assertNotIn('VirtualEthernet0/0/1', ifs) # verify VirtualEthernet0/0/1 is not in the dump if_dump = self.vapi.sw_interface_vhost_user_dump() @@ -71,7 +71,7 @@ class TesVhostInterface(VppTestCase): # verify VirtualEthernet0/0/0 not in the show ifs = self.vapi.cli("show interface") - self.assertEqual(ifs.find('VirtualEthernet0/0/0'), -1) + self.assertNotIn('VirtualEthernet0/0/0', ifs) # verify VirtualEthernet0/0/0 is not in the dump if_dump = self.vapi.sw_interface_vhost_user_dump() |