File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ """
2+ Shared fixtures for relink tests.
3+ """
4+
5+ import os
6+ import tempfile
7+ import shutil
8+
9+ import pytest
10+
11+
12+ @pytest .fixture (scope = "function" , name = "temp_dirs" )
13+ def fixture_temp_dirs ():
14+ """Create temporary source and target directories for testing."""
15+ source_dir = tempfile .mkdtemp (prefix = "test_source_" )
16+ target_dir = tempfile .mkdtemp (prefix = "test_target_" )
17+
18+ yield source_dir , target_dir
19+
20+ # Cleanup
21+ shutil .rmtree (source_dir , ignore_errors = True )
22+ shutil .rmtree (target_dir , ignore_errors = True )
23+
24+
25+ @pytest .fixture (name = "current_user" )
26+ def fixture_current_user ():
27+ """Get the current user's username."""
28+ username = os .environ ["USER" ]
29+ return username
Original file line number Diff line number Diff line change 44
55import os
66import sys
7- import tempfile
8- import shutil
97import logging
108
119import pytest
1816import relink # noqa: E402
1917
2018
21- @pytest .fixture (scope = "function" , name = "temp_dirs" )
22- def fixture_temp_dirs ():
23- """Create temporary source and target directories for testing."""
24- source_dir = tempfile .mkdtemp (prefix = "test_source_" )
25- target_dir = tempfile .mkdtemp (prefix = "test_target_" )
26-
27- yield source_dir , target_dir
28-
29- # Cleanup
30- shutil .rmtree (source_dir , ignore_errors = True )
31- shutil .rmtree (target_dir , ignore_errors = True )
32-
33-
3419@pytest .fixture (name = "dry_run_setup" )
3520def fixture_dry_run_setup (temp_dirs ):
3621 """Set up directories and files for dry-run tests."""
Original file line number Diff line number Diff line change 55import os
66import sys
77import tempfile
8- import shutil
98import pwd
109import logging
1110from unittest .mock import patch
1211
13- import pytest
14-
1512# Add parent directory to path to import relink module
1613sys .path .insert (
1714 0 , os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
2017import relink # noqa: E402
2118
2219
23- @pytest .fixture (scope = "function" , name = "temp_dirs" )
24- def fixture_temp_dirs ():
25- """Create temporary source and target directories for testing."""
26- source_dir = tempfile .mkdtemp (prefix = "test_source_" )
27- target_dir = tempfile .mkdtemp (prefix = "test_target_" )
28-
29- yield source_dir , target_dir
30-
31- # Cleanup
32- shutil .rmtree (source_dir , ignore_errors = True )
33- shutil .rmtree (target_dir , ignore_errors = True )
34-
35-
36- @pytest .fixture (name = "current_user" )
37- def fixture_current_user ():
38- """Get the current user's username."""
39- username = os .environ ["USER" ]
40- return username
41-
42-
4320def test_basic_file_replacement (temp_dirs , current_user ):
4421 """Test basic functionality: replace owned file with symlink."""
4522 source_dir , target_dir = temp_dirs
Original file line number Diff line number Diff line change 55import os
66import sys
77import tempfile
8- import shutil
98import logging
109from unittest .mock import patch
1110
12- import pytest
13-
1411# Add parent directory to path to import relink module
1512sys .path .insert (
1613 0 , os .path .dirname (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
1916import relink # noqa: E402
2017
2118
22- @pytest .fixture (scope = "function" , name = "temp_dirs" )
23- def fixture_temp_dirs ():
24- """Create temporary source and target directories for testing."""
25- source_dir = tempfile .mkdtemp (prefix = "test_source_" )
26- target_dir = tempfile .mkdtemp (prefix = "test_target_" )
27-
28- yield source_dir , target_dir
29-
30- # Cleanup
31- shutil .rmtree (source_dir , ignore_errors = True )
32- shutil .rmtree (target_dir , ignore_errors = True )
33-
34-
3519def test_quiet_mode_suppresses_info_messages (temp_dirs , caplog ):
3620 """Test that quiet mode suppresses INFO level messages."""
3721 source_dir , target_dir = temp_dirs
You can’t perform that action at this time.
0 commit comments