Skip to content

Commit

Permalink
Allow for exit 68 for ping on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
yarikoptic committed Feb 19, 2025
1 parent 0130400 commit 88ace86
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/test_command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ def is_pypy():
return True if platform.python_implementation().lower() == "pypy" else False


def is_macos():
"""
Checks if under Mac OS
"""
return platform.system().lower() == "darwin"


def test_standard_ping_with_encoding():
"""
Test command_runner with a standard ping and encoding parameter
Expand Down Expand Up @@ -243,9 +250,13 @@ def test_valid_exit_codes():
# WIP We could improve tests here by capturing logs
"""
valid_exit_codes = [0, 1, 2]
if is_macos():
valid_exit_codes.append(68) # ping non-existent exits with such on Mac
for method in methods:
exit_code, _ = command_runner('ping nonexistent_host', shell=True, valid_exit_codes=[0, 1, 2], method=method)
assert exit_code in [0, 1, 2], 'Exit code not in valid list with method {}'.format(method)

exit_code, _ = command_runner('ping nonexistent_host', shell=True, valid_exit_codes=valid_exit_codes, method=method)
assert exit_code in valid_exit_codes, 'Exit code not in valid list with method {}'.format(method)

exit_code, _ = command_runner('ping nonexistent_host', shell=True, valid_exit_codes=True, method=method)
assert exit_code != 0, 'Exit code should not be equal to 0'
Expand Down Expand Up @@ -768,4 +779,4 @@ def test_no_close_queues():
test_split_streams()
test_on_exit()
test_priority()
test_no_close_queues()
test_no_close_queues()

0 comments on commit 88ace86

Please sign in to comment.