Skip to content

Commit

Permalink
Tests: Use monkeypatch.context to avoid side effects on pytest
Browse files Browse the repository at this point in the history
* Otherwise this mocked attribute would affect pytest negatively when
  running tests with --verbose.

See-Also: dbcli#1152 (comment)
Signed-off-by: Alfred Wingate <[email protected]>
  • Loading branch information
parona-source committed Mar 29, 2024
1 parent f234f9e commit 86a994c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ def test_reserved_space_is_integer(monkeypatch):
def stub_terminal_size():
return (5, 5)

monkeypatch.setattr(shutil, 'get_terminal_size', stub_terminal_size)
with monkeypatch.context() as m:
m.setattr(shutil, 'get_terminal_size', stub_terminal_size)
mycli = MyCli()
assert isinstance(mycli.get_reserved_space(), int)

Expand Down

0 comments on commit 86a994c

Please sign in to comment.