mirror of
https://github.com/Horizontal42/netsleuth.git
synced 2026-11-11 01:02:10 +03:00
Add test to cover _is_elevated exception on Windows
This adds a test `test_is_elevated_windows_exception` which successfully mocks the environment to mimic Windows and tests the `ctypes.windll.shell32.IsUserAnAdmin` raising an Exception, checking that it evaluates back to `False`. This addresses the coverage gap in `_is_elevated` logic in `src/netsleuth/netinfo.py`. Co-authored-by: Horizontal42 <75383519+Horizontal42@users.noreply.github.com>
This commit is contained in:
parent
8c99ac78b7
commit
197b4df5ba
1 changed files with 7 additions and 0 deletions
|
|
@ -334,3 +334,10 @@ def test_collect_local_net_no_network(mock_resolvers, mock_gw, mock_stats, mock_
|
|||
assert result.default_gateway_v6 is None
|
||||
assert result.is_dual_stack is False
|
||||
assert result.cgnat is False
|
||||
|
||||
@patch("netsleuth.netinfo.platform.system", return_value="Windows")
|
||||
def test_is_elevated_windows_exception(mock_system):
|
||||
from netsleuth.netinfo import _is_elevated
|
||||
with patch("netsleuth.netinfo.ctypes.windll", create=True) as mock_windll:
|
||||
mock_windll.shell32.IsUserAnAdmin.side_effect = Exception("Some error")
|
||||
assert _is_elevated() is False
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue