Skip to content

Commit 095bc1f

Browse files
mock pynput to make linux happy
1 parent 427e5e0 commit 095bc1f

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

tests/test_visualizations.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
visualize_horizontal_right_to_left)
1919

2020

21+
@patch('audio_visualizer.vertical_visualizer.os.get_terminal_size')
22+
# Mock os.system to prevent clearing the screen
23+
@patch('audio_visualizer.vertical_visualizer.os.system')
24+
# Mock time.sleep to speed up the test
25+
@patch('audio_visualizer.vertical_visualizer.time.sleep')
26+
# Mock entire pynput module
27+
@patch('audio_visualizer.visualizer.keyboard', MagicMock())
2128
class TestVisualizes(unittest.TestCase):
2229
def setUp(self):
2330
# Create a mock stop event
@@ -26,11 +33,7 @@ def setUp(self):
2633
"""
2734
Test cases for visualization functions.
2835
"""
29-
@patch('audio_visualizer.vertical_visualizer.os.get_terminal_size')
30-
# Mock os.system to prevent clearing the screen
31-
@patch('audio_visualizer.vertical_visualizer.os.system')
32-
# Mock time.sleep to speed up the test
33-
@patch('audio_visualizer.vertical_visualizer.time.sleep')
36+
3437
def test_visualize_vertical(self, mock_sleep,
3538
mock_os_system, mock_get_terminal_size):
3639
"""
@@ -78,11 +81,6 @@ def test_visualize_vertical(self, mock_sleep,
7881
self.assertIn('█', output)
7982
self.assertGreater(len(output), 0) # Check that there is some output
8083

81-
@patch('audio_visualizer.horizontal_left_to_right_visualizer.os.get_terminal_size') # noqa: E501
82-
# Mock os.system to prevent clearing the screen
83-
@patch('audio_visualizer.horizontal_left_to_right_visualizer.os.system')
84-
# Mock time.sleep to speed up the test
85-
@patch('audio_visualizer.horizontal_left_to_right_visualizer.time.sleep')
8684
def test_visualize_horizontal_left_to_right(self, mock_sleep,
8785
mock_os_system,
8886
mock_get_terminal_size):
@@ -131,11 +129,6 @@ def test_visualize_horizontal_left_to_right(self, mock_sleep,
131129
self.assertIn('█', output)
132130
self.assertGreater(len(output), 0) # Check that there is some output
133131

134-
@patch('audio_visualizer.horizontal_right_to_left_visualizer.os.get_terminal_size') # noqa: E501
135-
# Mock os.system to prevent clearing the screen
136-
@patch('audio_visualizer.horizontal_right_to_left_visualizer.os.system')
137-
# Mock time.sleep to speed up the test
138-
@patch('audio_visualizer.horizontal_right_to_left_visualizer.time.sleep')
139132
def test_visualize_right_to_left_horizontal(self, mock_sleep,
140133
mock_os_system,
141134
mock_get_terminal_size):

0 commit comments

Comments
 (0)