Skip to content

Commit 5b1c175

Browse files
committed
Add test for L3WinSocket.close() with partial init
Introduces a test to ensure L3WinSocket.close() does not raise AttributeError when called on a partially initialized object. This improves robustness by verifying correct handling of incomplete initialization.
1 parent b95f468 commit 5b1c175

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

test/windows.uts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,27 @@ def _test():
117117

118118
retry_test(_test)
119119

120+
= Test L3WinSocket close() with partial initialization
121+
~ windows
122+
123+
from scapy.arch.windows.native import L3WinSocket
124+
import socket
125+
126+
# Create partially initialized L3WinSocket
127+
ws = object.__new__(L3WinSocket)
128+
ws.closed = False
129+
ws.promisc = True
130+
# Note: ws.ins is intentionally not set
131+
132+
# This should not raise AttributeError
133+
try:
134+
ws.close()
135+
test_passed = True
136+
except AttributeError:
137+
test_passed = False
138+
139+
assert test_passed, "L3WinSocket.close() raised AttributeError on partially initialized object"
140+
120141
= Leave native mode
121142

122143
conf.use_pcap = True

0 commit comments

Comments
 (0)