@@ -83,12 +83,16 @@ def raise_not_found(*args, **kwargs):
8383
8484
8585def test_create_test_group_file_success (tmp_path , monkeypatch ):
86- template = tmp_path / "template.py"
87- template .write_text ("# template\n class {test_group_name}: pass\n " )
8886 target_dir = tmp_path / "hil_tests"
8987 target_dir .mkdir ()
9088
91- monkeypatch .setattr (cli , "get_template_path" , lambda : template )
89+ # mock template content
90+ monkeypatch .setattr (
91+ cli ,
92+ "get_template_content" ,
93+ lambda : "# template\n class {test_group_name}: pass\n " ,
94+ )
95+
9296 logger = DummyLogger ()
9397
9498 created = cli .create_test_group_file ("alpha" , target_dir , logger )
@@ -100,15 +104,20 @@ def test_create_test_group_file_success(tmp_path, monkeypatch):
100104 assert any ("Created test group template" in msg for msg in logger .messages )
101105
102106
107+
103108def test_create_test_group_file_existing (tmp_path , monkeypatch ):
104- template = tmp_path / "template.py"
105- template .write_text ("# template\n class {test_group_name}: pass\n " )
109+ monkeypatch .setattr (
110+ cli ,
111+ "get_template_content" ,
112+ lambda : "# template\n class {test_group_name}: pass\n " ,
113+ )
114+
106115 target_dir = tmp_path / "hil_tests"
107116 target_dir .mkdir ()
117+
108118 existing = target_dir / "test_alpha.py"
109119 existing .write_text ("# existing" )
110120
111- monkeypatch .setattr (cli , "get_template_path" , lambda : template )
112121 logger = DummyLogger ()
113122
114123 created = cli .create_test_group_file ("alpha" , target_dir , logger )
@@ -117,12 +126,16 @@ def test_create_test_group_file_existing(tmp_path, monkeypatch):
117126 assert any ("already exists" in msg for msg in logger .messages )
118127
119128
129+
120130def test_create_test_group_file_missing_dir (tmp_path , monkeypatch ):
121- template = tmp_path / "template.py"
122- template .write_text ("# template\n class {test_group_name}: pass\n " )
131+ monkeypatch .setattr (
132+ cli ,
133+ "get_template_content" ,
134+ lambda : "# template\n class {test_group_name}: pass\n " ,
135+ )
136+
123137 target_dir = tmp_path / "missing"
124138
125- monkeypatch .setattr (cli , "get_template_path" , lambda : template )
126139 logger = DummyLogger ()
127140
128141 created = cli .create_test_group_file ("alpha" , target_dir , logger )
@@ -131,6 +144,7 @@ def test_create_test_group_file_missing_dir(tmp_path, monkeypatch):
131144 assert any ("does not exist" in msg for msg in logger .messages )
132145
133146
147+
134148# ---------------------------------------------------------------------
135149# log_discovered_devices
136150# ---------------------------------------------------------------------
0 commit comments