Tests: Fix traceback.
self.assertTrue(packet.haslayer(msg_type))
File "/usr/lib/python2.7/unittest/case.py", line 422, in assertTrue
raise self.failureException(msg)
AssertionError: 0 is not true
* Scapy packet.haslayer() returns 1 or 0.
Replace with assertEqual(packet.haslayer(), 1) to fix tracebacks.
* Scapy has multiple layers called TCP/UDP
Specify the module name to prevent namespace collisions.
* Remove duplicate import.
Change-Id: I600f9f330075cd40e1da50f8b2ceb24f645f2c20
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/test/test_dhcp6.py b/test/test_dhcp6.py
index fe06f98..6c20386 100644
--- a/test/test_dhcp6.py
+++ b/test/test_dhcp6.py
@@ -61,8 +61,8 @@
self.assertEqual(len(rx_list), 1)
packet = rx_list[0]
- self.assertTrue(packet.haslayer(IPv6))
- self.assertTrue(packet[IPv6].haslayer(DHCP6_Solicit))
+ self.assertEqual(packet.haslayer(IPv6), 1)
+ self.assertEqual(packet[IPv6].haslayer(DHCP6_Solicit), 1)
client_duid = packet[DHCP6OptClientId].duid
trid = packet[DHCP6_Solicit].trid
@@ -137,8 +137,8 @@
self.assertEqual(len(rx_list), 1)
packet = rx_list[0]
- self.assertTrue(packet.haslayer(IPv6))
- self.assertTrue(packet[IPv6].haslayer(DHCP6_Solicit))
+ self.assertEqual(packet.haslayer(IPv6), 1)
+ self.assertEqual(packet[IPv6].haslayer(DHCP6_Solicit), 1)
client_duid = packet[DHCP6OptClientId].duid
trid = packet[DHCP6_Solicit].trid
@@ -256,7 +256,7 @@
def validate_packet(self, packet, msg_type, is_resend=False):
try:
- self.assertTrue(packet.haslayer(msg_type))
+ self.assertEqual(packet.haslayer(msg_type), 1)
client_duid = packet[DHCP6OptClientId].duid
if self.client_duid is None:
self.client_duid = client_duid
@@ -508,7 +508,7 @@
def validate_packet(self, packet, msg_type, is_resend=False):
try:
- self.assertTrue(packet.haslayer(msg_type))
+ self.assertEqual(packet.haslayer(msg_type), 1)
client_duid = packet[DHCP6OptClientId].duid
if self.client_duid is None:
self.client_duid = client_duid