@@ -192,14 +192,14 @@ def test_copy_examples(input, expected_paths, example_cases):
192192 pm = PacksManager (root_path = examples_dir )
193193 target_dir = example_cases / "user_target"
194194 pm .copy_examples (input , target_dir = target_dir )
195- actual = list (target_dir .rglob ("*" ))
196- expected = [target_dir / path for path in expected_paths ]
195+ actual = sorted ( list (target_dir .rglob ("*" ) ))
196+ expected = sorted ( [target_dir / path for path in expected_paths ])
197197 assert actual == expected
198198 for path in expected_paths :
199- dest = target_dir / path
200- source = examples_dir / path
201- if dest .is_file () and source .is_file ():
202- assert dest .read_text () == source .read_text ()
199+ copied_path = target_dir / path
200+ original_path = examples_dir / path
201+ if copied_path .is_file () and original_path .is_file ():
202+ assert copied_path .read_text () == original_path .read_text ()
203203
204204
205205# Test default and targeted copy_example location on case5
@@ -256,18 +256,13 @@ def test_copy_examples_location(input, expected_path, example_cases):
256256 # 4) Path to directory already exists.
257257 # Expected: Raise a warning with the message.
258258 ["ex1" ],
259- "Target directory already exists. To overwrite use --force." ,
260- Path ("docs/examples/" ),
261- ),
262- (
263- # 5) No input provided.
264- # Expected: Raise an error with the message.
265- [],
266259 (
267- "No input specified. "
268- "Provide at least one example or pack to copy."
260+ "Example directory(ies): 'ex1' already exist. "
261+ " Current versions of existing files have "
262+ "been left unchanged. To overwrite, please rerun "
263+ "and specify --force."
269264 ),
270- None ,
265+ Path ( "docs/examples/" ) ,
271266 ),
272267 ],
273268)
@@ -277,40 +272,3 @@ def test_copy_examples_bad(bad_inputs, expected, path, example_cases):
277272 target_dir = None if path is None else examples_dir / path
278273 with pytest .raises (Exception , match = re .escape (expected )):
279274 pm .copy_examples (bad_inputs , target_dir = target_dir )
280-
281-
282- # Test bad target_dir to copy_examples on case3
283- # 1) target doesn't exist
284- # 2) target is a file
285- # 3) target is nested in a file
286- @pytest .mark .parametrize (
287- "bad_target,expected" ,
288- [
289- (
290- # 1) Target doesn't exist.
291- # Expected: Raise an error that the target directory is missing.
292- Path ("nonexistent/path/target" ),
293- "Target directory does not exist" ,
294- ),
295- (
296- # 2) Target is a file.
297- # Expected: Raise an error that the target path is not a directory.
298- Path ("docs/examples/packA/ex1/script4.py" ),
299- "Target path is not a directory" ,
300- ),
301- (
302- # 3) Target is nested in a file.
303- # Expected: Raise an error that the target path is not a directory.
304- Path ("docs/examples/packA/ex1/script4.py/nested" ),
305- "Target path is not a directory" ,
306- ),
307- ],
308- )
309- def test_copy_examples_bad_target (bad_target , expected , example_cases ):
310- examples_dir = example_cases / "case3"
311- pm = PacksManager (root_path = examples_dir )
312- with pytest .raises (Exception , match = re .escape (expected )):
313- pm .copy_examples (
314- ["packA" ],
315- target_dir = bad_target ,
316- )
0 commit comments