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: #1152 (comment)
Signed-off-by: Alfred Wingate <[email protected]>
  • Loading branch information
parona-source committed Mar 29, 2024
1 parent f234f9e commit 692d37e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,10 @@ def test_reserved_space_is_integer(monkeypatch):
def stub_terminal_size():
return (5, 5)

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


def test_list_dsn():
Expand Down

0 comments on commit 692d37e

Please sign in to comment.