44
55import shutil
66
7- from pathlib import Path
8- from typing import Any
7+ from typing import TYPE_CHECKING
98from unittest .mock import patch
109
1110import pytest
2928from ansible_navigator .utils .functions import to_list
3029
3130
31+ if TYPE_CHECKING :
32+ from pathlib import Path
33+
34+
3235def test_check_for_ansible_found (monkeypatch : pytest .MonkeyPatch ) -> None :
3336 """Test check_for_ansible when ansible-playbook is found."""
3437 monkeypatch .setattr (shutil , "which" , lambda _ : "/usr/bin/ansible-playbook" )
@@ -71,7 +74,9 @@ def test_clear_screen_vscode(
7174 """Test clear_screen prints blank lines in vscode terminal."""
7275 monkeypatch .setenv ("TERM_PROGRAM" , "vscode" )
7376 fake_size = type ("TermSize" , (), {"lines" : 5 , "columns" : 80 })()
74- with patch ("ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size ):
77+ with patch (
78+ "ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size
79+ ):
7580 clear_screen ()
7681 captured = capsys .readouterr ()
7782 assert captured .out .count ("\n " ) == 5
@@ -91,22 +96,28 @@ def test_clear_screen_normal(
9196def test_console_width_small () -> None :
9297 """Test console_width with small terminal."""
9398 fake_size = type ("TermSize" , (), {"columns" : 60 })()
94- with patch ("ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size ):
99+ with patch (
100+ "ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size
101+ ):
95102 assert console_width () == 60
96103
97104
98105def test_console_width_medium () -> None :
99106 """Test console_width with medium terminal."""
100107 fake_size = type ("TermSize" , (), {"columns" : 120 })()
101- with patch ("ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size ):
108+ with patch (
109+ "ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size
110+ ):
102111 result = console_width ()
103112 assert 80 <= result <= 120
104113
105114
106115def test_console_width_large () -> None :
107116 """Test console_width with large terminal."""
108117 fake_size = type ("TermSize" , (), {"columns" : 200 })()
109- with patch ("ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size ):
118+ with patch (
119+ "ansible_navigator.utils.functions.shutil.get_terminal_size" , return_value = fake_size
120+ ):
110121 assert console_width () == 132
111122
112123
@@ -261,7 +272,7 @@ def test_templar_simple() -> None:
261272
262273def test_templar_error () -> None :
263274 """Test templar with undefined variable."""
264- errors , result = templar ("{{ undefined_var }}" , {})
275+ errors , _result = templar ("{{ undefined_var }}" , {})
265276 assert len (errors ) > 0
266277
267278
0 commit comments