Skip to content

Commit 24a6db0

Browse files
[TESTING] Slight improvement to testing related to #188
Changes in file tests/test_hear_data_processing.py: - improved verification for test_handle_with_invalid_utf8_data(self)
1 parent 1bc42c5 commit 24a6db0

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/test_hear_data_processing.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,20 @@ def test_handle_with_invalid_utf8_data(self):
191191
_fixture_port_num = self._always_generate_random_port_WHEN_called()
192192
self.assertIsNotNone(_fixture_port_num)
193193
self.assertIsInstance(_fixture_port_num, int)
194+
_fixture_client_addr = ("224.0.0.1", _fixture_port_num)
194195
data = b'\xff\xfe\xfd\xfc' # Invalid UTF-8 bytes
195196
sock = multicast.genSocket()
196197
handler = multicast.hear.HearUDPHandler(
197198
request=(data, sock),
198-
client_address=("224.0.0.1", _fixture_port_num),
199+
client_address=_fixture_client_addr,
199200
server=None
200201
)
201202
try:
202203
# Should silently ignore invalid UTF-8 data
203-
handler.handle()
204-
# If no exception is raised, the test passes
204+
handler.handle() # If no exception is raised, the test passes
205+
# Verify handler state after processing invalid data
206+
self.assertIsNone(handler.server) # Server should remain None
207+
self.assertEqual(handler.client_address, _fixture_client_addr)
205208
except Exception as e:
206209
self.fail(f"Handler raised an unexpected exception: {e}")
207210
finally:

0 commit comments

Comments
 (0)