Skip to content

Commit

Permalink
Use Python 3.6 & 3.7 compatible means of acceessing mock call args/kw…
Browse files Browse the repository at this point in the history
…args in test
  • Loading branch information
darrenburns committed Mar 2, 2022
1 parent 862416a commit 7525377
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/test_win32_console.py
Expand Up @@ -83,9 +83,14 @@ def test_write_styled(_, SetConsoleTextAttribute, win32_handle):

assert f.getvalue() == text
# Ensure we set the text attributes and then reset them after writing styled text
assert call_args[0].args == (win32_handle,)
assert call_args[0].kwargs["attributes"].value == 64
assert call_args[1] == call(win32_handle, attributes=DEFAULT_STYLE_ATTRIBUTE)

first_args, first_kwargs = call_args[0]
second_args, second_kwargs = call_args[1]

assert first_args == (win32_handle,)
assert first_kwargs["attributes"].value == 64
assert second_args == (win32_handle,)
assert second_kwargs["attributes"] == DEFAULT_STYLE_ATTRIBUTE

@patch.object(_win32_console, "FillConsoleOutputCharacter", return_value=None)
@patch.object(_win32_console, "FillConsoleOutputAttribute", return_value=None)
Expand Down Expand Up @@ -294,8 +299,10 @@ def test_hide_cursor(_, SetConsoleCursorInfo, win32_handle):
call_args = SetConsoleCursorInfo.call_args_list

assert len(call_args) == 1
assert call_args[0].kwargs["cursor_info"].bVisible == 0
assert call_args[0].kwargs["cursor_info"].dwSize == 100

args, kwargs = call_args[0]
assert kwargs["cursor_info"].bVisible == 0
assert kwargs["cursor_info"].dwSize == 100

@patch.object(_win32_console, "SetConsoleCursorInfo", return_value=None)
@patch.object(
Expand All @@ -308,8 +315,10 @@ def test_show_cursor(_, SetConsoleCursorInfo, win32_handle):
call_args = SetConsoleCursorInfo.call_args_list

assert len(call_args) == 1
assert call_args[0].kwargs["cursor_info"].bVisible == 1
assert call_args[0].kwargs["cursor_info"].dwSize == 100

args, kwargs = call_args[0]
assert kwargs["cursor_info"].bVisible == 1
assert kwargs["cursor_info"].dwSize == 100

@patch.object(_win32_console, "SetConsoleTitle", return_value=None)
def test_set_title(SetConsoleTitle):
Expand Down

0 comments on commit 7525377

Please sign in to comment.