@@ -29,23 +29,17 @@ class TestLiveCollectorInteractiveControls(unittest.TestCase):
2929
3030 def setUp (self ):
3131 """Set up collector with mock display."""
32- from profiling .sampling .live_collector import constants
33-
34- # Save and reset the display update interval
35- self ._saved_interval = constants .DISPLAY_UPDATE_INTERVAL
36- constants .DISPLAY_UPDATE_INTERVAL = 0.1
37-
3832 self .display = MockDisplay (height = 40 , width = 160 )
3933 self .collector = LiveStatsCollector (
4034 1000 , pid = 12345 , display = self .display
4135 )
4236 self .collector .start_time = time .perf_counter ()
37+ # Set a consistent display update interval for tests
38+ self .collector ._display_update_interval = 0.1
4339
4440 def tearDown (self ):
45- """Restore the display update interval."""
46- from profiling .sampling .live_collector import constants
47-
48- constants .DISPLAY_UPDATE_INTERVAL = self ._saved_interval
41+ """Clean up after test."""
42+ pass
4943
5044 def test_pause_functionality (self ):
5145 """Test pause/resume functionality."""
@@ -116,53 +110,45 @@ def test_reset_stats(self):
116110
117111 def test_increase_refresh_rate (self ):
118112 """Test increasing refresh rate (faster updates)."""
119- from profiling .sampling .live_collector import constants
120-
121- initial_interval = constants .DISPLAY_UPDATE_INTERVAL
113+ initial_interval = self .collector ._display_update_interval
122114
123115 # Simulate '+' key press (faster = smaller interval)
124116 self .display .simulate_input (ord ("+" ))
125117 self .collector ._handle_input ()
126118
127- self .assertLess (constants . DISPLAY_UPDATE_INTERVAL , initial_interval )
119+ self .assertLess (self . collector . _display_update_interval , initial_interval )
128120
129121 def test_decrease_refresh_rate (self ):
130122 """Test decreasing refresh rate (slower updates)."""
131- from profiling .sampling .live_collector import constants
132-
133- initial_interval = constants .DISPLAY_UPDATE_INTERVAL
123+ initial_interval = self .collector ._display_update_interval
134124
135125 # Simulate '-' key press (slower = larger interval)
136126 self .display .simulate_input (ord ("-" ))
137127 self .collector ._handle_input ()
138128
139- self .assertGreater (constants . DISPLAY_UPDATE_INTERVAL , initial_interval )
129+ self .assertGreater (self . collector . _display_update_interval , initial_interval )
140130
141131 def test_refresh_rate_minimum (self ):
142132 """Test that refresh rate has a minimum (max speed)."""
143- from profiling .sampling .live_collector import constants
144-
145- constants .DISPLAY_UPDATE_INTERVAL = 0.05 # Set to minimum
133+ self .collector ._display_update_interval = 0.05 # Set to minimum
146134
147135 # Try to go faster
148136 self .display .simulate_input (ord ("+" ))
149137 self .collector ._handle_input ()
150138
151139 # Should stay at minimum
152- self .assertEqual (constants . DISPLAY_UPDATE_INTERVAL , 0.05 )
140+ self .assertEqual (self . collector . _display_update_interval , 0.05 )
153141
154142 def test_refresh_rate_maximum (self ):
155143 """Test that refresh rate has a maximum (min speed)."""
156- from profiling .sampling .live_collector import constants
157-
158- constants .DISPLAY_UPDATE_INTERVAL = 1.0 # Set to maximum
144+ self .collector ._display_update_interval = 1.0 # Set to maximum
159145
160146 # Try to go slower
161147 self .display .simulate_input (ord ("-" ))
162148 self .collector ._handle_input ()
163149
164150 # Should stay at maximum
165- self .assertEqual (constants . DISPLAY_UPDATE_INTERVAL , 1.0 )
151+ self .assertEqual (self . collector . _display_update_interval , 1.0 )
166152
167153 def test_help_toggle (self ):
168154 """Test help screen toggle."""
@@ -290,27 +276,23 @@ def test_filter_clear_uppercase(self):
290276
291277 def test_increase_refresh_rate_with_equals (self ):
292278 """Test increasing refresh rate with '=' key."""
293- from profiling .sampling .live_collector import constants
294-
295- initial_interval = constants .DISPLAY_UPDATE_INTERVAL
279+ initial_interval = self .collector ._display_update_interval
296280
297281 # Simulate '=' key press (alternative to '+')
298282 self .display .simulate_input (ord ("=" ))
299283 self .collector ._handle_input ()
300284
301- self .assertLess (constants . DISPLAY_UPDATE_INTERVAL , initial_interval )
285+ self .assertLess (self . collector . _display_update_interval , initial_interval )
302286
303287 def test_decrease_refresh_rate_with_underscore (self ):
304288 """Test decreasing refresh rate with '_' key."""
305- from profiling .sampling .live_collector import constants
306-
307- initial_interval = constants .DISPLAY_UPDATE_INTERVAL
289+ initial_interval = self .collector ._display_update_interval
308290
309291 # Simulate '_' key press (alternative to '-')
310292 self .display .simulate_input (ord ("_" ))
311293 self .collector ._handle_input ()
312294
313- self .assertGreater (constants . DISPLAY_UPDATE_INTERVAL , initial_interval )
295+ self .assertGreater (self . collector . _display_update_interval , initial_interval )
314296
315297 def test_finished_state_displays_banner (self ):
316298 """Test that finished state shows prominent banner."""
0 commit comments