Skip to content

Commit 3f5e279

Browse files
committed
Fix Windows test collection error by moving imports to module level
- Move 'from src.cli import cli' to top of file - Remove redundant imports from inside each test method - Fixes pytest collection phase error on Windows - Import now happens once during module load instead of multiple times - Resolves Windows-specific import discovery issues
1 parent 6873dab commit 3f5e279

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

tests/unit/test_cli.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
from unittest.mock import patch, MagicMock
88
import json
99
from pathlib import Path
10+
from src.cli import cli
1011

1112

1213
class TestCLI:
1314
"""Test suite for CLI commands."""
1415

1516
def test_cli_can_be_invoked(self):
1617
"""Test that CLI can be invoked without errors."""
17-
from src.cli import cli
18-
1918
runner = CliRunner()
2019
result = runner.invoke(cli, ['--help'])
2120

@@ -24,8 +23,6 @@ def test_cli_can_be_invoked(self):
2423

2524
def test_start_command_begins_tracking(self):
2625
"""Test that 'tempo start' begins tracking."""
27-
from src.cli import cli
28-
2926
runner = CliRunner()
3027

3128
with patch('src.cli.start_tracking') as mock_start:
@@ -38,8 +35,6 @@ def test_start_command_begins_tracking(self):
3835

3936
def test_stop_command_stops_tracking(self):
4037
"""Test that 'tempo stop' stops tracking."""
41-
from src.cli import cli
42-
4338
runner = CliRunner()
4439

4540
with patch('src.cli.is_tracking_running') as mock_running, \
@@ -54,8 +49,6 @@ def test_stop_command_stops_tracking(self):
5449

5550
def test_status_command_shows_tracking_status(self):
5651
"""Test that 'tempo status' shows current status."""
57-
from src.cli import cli
58-
5952
runner = CliRunner()
6053

6154
with patch('src.cli.get_tracker_status') as mock_status:
@@ -73,8 +66,6 @@ def test_status_command_shows_tracking_status(self):
7366

7467
def test_today_command_shows_daily_summary(self):
7568
"""Test that 'tempo today' shows today's activity."""
76-
from src.cli import cli
77-
7869
runner = CliRunner()
7970

8071
with patch('src.cli.get_today_summary') as mock_today:
@@ -96,8 +87,6 @@ def test_today_command_shows_daily_summary(self):
9687
@patch('src.cli.is_tracking_running')
9788
def test_start_prevents_double_start(self, mock_is_running):
9889
"""Test that start command prevents double starting."""
99-
from src.cli import cli
100-
10190
runner = CliRunner()
10291
mock_is_running.return_value = True
10392

@@ -109,8 +98,6 @@ def test_start_prevents_double_start(self, mock_is_running):
10998
@patch('src.cli.is_tracking_running')
11099
def test_stop_when_not_running(self, mock_is_running):
111100
"""Test that stop command handles when not running."""
112-
from src.cli import cli
113-
114101
runner = CliRunner()
115102
mock_is_running.return_value = False
116103

0 commit comments

Comments
 (0)