Skip to content

Commit 819f048

Browse files
[STYLE] Expanded locale testing stability (- WIP PR #448 -)
Changes in file .github/workflows/CI-BUILD.yml: * added fr_CA.UTF-8 to build testing * small style changes Changes in file tests/test_hear_cleanup.py: * new test for negitive case Changes in file tox.ini: * More style changes
1 parent 170eddb commit 819f048

File tree

3 files changed

+57
-9
lines changed

3 files changed

+57
-9
lines changed

.github/workflows/CI-BUILD.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ env:
2323
# Define Python versions at the top level -- Expected format: X.Y (e.g., 3.13)
2424
PYTHON_DEFAULT: "${{ vars.PYTHON_DEFAULT }}"
2525
PYTHON_OLD_MIN: "${{ vars.PYTHON_OLD_MIN }}" # For Oldest Python versions
26+
PYTHON_OLD_EXTRA: "${{ vars.PYTHON_OLD_EXTRA }}" # For Oldest Python versions (Extra coverage)
2627
PYTHON_EXPERIMENTAL: "${{ vars.PYTHON_EXPERIMENTAL }}" # For future Python versions
2728

2829
jobs:
@@ -149,14 +150,17 @@ jobs:
149150
fail-fast: false
150151
matrix:
151152
python-version: ["${{ vars.PYTHON_OLD_MIN }}", "${{ vars.PYTHON_DEFAULT }}", "${{ vars.PYTHON_EXPERIMENTAL }}"]
152-
lang-var: ["de.utf-8", "jp.utf-8"]
153+
lang-var: ["de_DE.UTF-8", "ja_JP.UTF-8", "fr_CA.UTF-8"]
153154
experimental: [true]
154155
include:
155156
- python-version: "${{ vars.PYTHON_DEFAULT }}"
156-
lang-var: "de.utf-8"
157+
lang-var: "de_DE.UTF-8"
157158
experimental: false
158159
- python-version: "${{ vars.PYTHON_DEFAULT }}"
159-
lang-var: "jp.utf-8"
160+
lang-var: "ja_JP.UTF-8"
161+
experimental: false
162+
- python-version: "${{ vars.PYTHON_DEFAULT }}"
163+
lang-var: "fr_CA.UTF-8"
160164
experimental: false
161165
- python-version: "${{ vars.PYTHON_OLD_MIN }}"
162166
lang-var: "en_US.utf-8"

tests/test_hear_cleanup.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,50 @@ def get_default_ip() -> str:
207207
s.close()
208208
return ip
209209

210+
def test_should_not_invoke_kill_func_when_handle_error_not_called(self) -> None:
211+
"""Test that handle_error only conditionally calls kill_func on stop keyword.
212+
213+
Verifies that the server properly handles mocked requests without
214+
the STOP command and never calls the kill_func to free up server resources early.
215+
216+
Args:
217+
None (self is implicit)
218+
219+
Returns:
220+
None
221+
222+
Raises:
223+
AssertionError: If the test conditions are not met.
224+
"""
225+
theResult = False
226+
fail_fixture = "Mock(MSG) --> Handler-HEAR --> early shutdown"
227+
_fixture_port_num = self._the_test_port
228+
try:
229+
self.assertIsNotNone(_fixture_port_num)
230+
self.assertIsInstance(_fixture_port_num, int)
231+
# Create an instance of McastServer
232+
server_address = (self.TEST_MULTICAST_GROUP, _fixture_port_num)
233+
self.server = multicast.hear.McastServer(server_address, None, False)
234+
self.server.shutdown = MagicMock() # Mock the shutdown method
235+
client_address = (self.get_default_ip(), _fixture_port_num)
236+
# Mock a request not containing "STOP"
237+
request = ("Any other message with O, P, S, T", multicast.genSocket())
238+
# Add assertions for initial state
239+
self.assertIsNotNone(request[1], "Socket should be created")
240+
self.assertIsInstance(request[0], str, "Request should be a string")
241+
try:
242+
self.server.handle_error(request, client_address)
243+
# Assert that the shutdown method was called
244+
self.server.shutdown.assert_not_called()
245+
theResult = True
246+
finally:
247+
# Clean up
248+
self.server.server_close()
249+
except Exception as _cause:
250+
context.debugtestError(_cause)
251+
self.fail(fail_fixture)
252+
self.assertTrue(theResult, fail_fixture)
253+
210254
def test_should_invoke_kill_func_when_handle_error_called(self) -> None:
211255
"""Test that kill_func calls shutdown on the server instance.
212256

tox.ini

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ alwayscopy = True
5353
passenv =
5454
{[base]passenv}
5555
setenv =
56-
LC_CTYPE=C.utf8
57-
LC_ALL=en_US.utf8
56+
LC_CTYPE=C.UTF-8
57+
LC_ALL=en_US.UTF-8
5858
PYTHON={envpython}
5959
PYTHONCOERCECLOCALE=UTF-8
6060
PYTHONUTF8=1
@@ -106,10 +106,10 @@ skipsdist = False
106106
recreate = True
107107
alwayscopy = True
108108
passenv =
109-
LC_CTYPE=C.utf8
110-
LC_ALL=en_US.utf8
111109
{[base]passenv}
112110
setenv =
111+
LC_CTYPE=C.UTF-8
112+
LC_ALL=en_US.UTF-8
113113
PYTHON={envpython}
114114
PYTHONCOERCECLOCALE=UTF-8
115115
PYTHONUTF8=1
@@ -134,10 +134,10 @@ skipsdist = False
134134
recreate = True
135135
alwayscopy = True
136136
passenv =
137-
LC_CTYPE=C.utf8
138-
LC_ALL=en_US.utf8
139137
{[base]passenv}
140138
setenv =
139+
LC_CTYPE=C.UTF-8
140+
LC_ALL=en_US.UTF-8
141141
PYTHON={envpython}
142142
PYTHONCOERCECLOCALE=UTF-8
143143
PYTHONUTF8=1

0 commit comments

Comments
 (0)