3838 FALLBACK_UV_VERSION ,
3939)
4040from usethis ._file .pyproject_toml .io_ import PyprojectTOMLManager
41+ from usethis ._file .setup_cfg .io_ import SetupCFGManager
4142from usethis ._integrations .pre_commit .hooks import HOOK_GROUPS , get_hook_ids
4243from usethis ._integrations .pre_commit .yaml import PreCommitConfigYAMLManager
4344from usethis ._python .version import PythonVersion
@@ -71,7 +72,7 @@ class TestAdd:
7172 @pytest .mark .usefixtures ("_vary_network_conn" )
7273 def test_config (self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]):
7374 # Arrange
74- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
75+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
7576 add_deps_to_group ([Dependency (name = "codespell" )], "dev" )
7677 ensure_symlink_mode ()
7778
@@ -485,7 +486,7 @@ def test_after_codespell(self, tmp_path: Path):
485486
486487 class TestRemove :
487488 def test_unused (self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]):
488- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
489+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
489490 # Act
490491 use_coverage_py (remove = True )
491492
@@ -554,7 +555,7 @@ class TestAdd:
554555 @pytest .mark .usefixtures ("_vary_network_conn" )
555556 def test_dependency_added (self , uv_init_dir : Path ):
556557 # Act
557- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
558+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
558559 use_deptry ()
559560
560561 # Assert
@@ -564,7 +565,7 @@ def test_dependency_added(self, uv_init_dir: Path):
564565 @pytest .mark .usefixtures ("_vary_network_conn" )
565566 def test_ignore_notebooks (self , uv_init_dir : Path ):
566567 # Act
567- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
568+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
568569 use_deptry ()
569570
570571 # Assert
@@ -580,7 +581,7 @@ def test_stdout(
580581 capfd : pytest .CaptureFixture [str ],
581582 ):
582583 # Act
583- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
584+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
584585 use_deptry ()
585586
586587 # Assert
@@ -604,6 +605,7 @@ def test_stdout_unfrozen(
604605 with (
605606 change_cwd (uv_init_dir ),
606607 PyprojectTOMLManager (),
608+ SetupCFGManager (),
607609 usethis_config .set (frozen = False ),
608610 ):
609611 use_deptry ()
@@ -623,7 +625,7 @@ def test_run_deptry_fail(self, uv_init_dir: Path, uv_path: Path):
623625 f .write_text ("import broken_dependency" )
624626
625627 # Act
626- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
628+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
627629 use_deptry ()
628630
629631 # Assert
@@ -643,6 +645,7 @@ def test_run_deptry_pass(self, uv_init_dir: Path):
643645 with (
644646 change_cwd (uv_init_dir ),
645647 PyprojectTOMLManager (),
648+ SetupCFGManager (),
646649 usethis_config .set (frozen = False ),
647650 ):
648651 # Act
@@ -707,7 +710,7 @@ def test_pre_commit_after(
707710 class TestRemove :
708711 @pytest .mark .usefixtures ("_vary_network_conn" )
709712 def test_dep (self , uv_init_dir : Path ):
710- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
713+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
711714 # Arrange
712715 add_deps_to_group ([Dependency (name = "deptry" )], "dev" )
713716
@@ -726,7 +729,7 @@ def test_use_deptry_removes_config(self, tmp_path: Path):
726729""" )
727730
728731 # Act
729- with change_cwd (tmp_path ), PyprojectTOMLManager ():
732+ with change_cwd (tmp_path ), PyprojectTOMLManager (), SetupCFGManager () :
730733 use_deptry (remove = True )
731734
732735 # Assert
@@ -738,7 +741,7 @@ def test_roundtrip(self, uv_init_dir: Path):
738741 contents = (uv_init_dir / "pyproject.toml" ).read_text ()
739742
740743 # Act
741- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
744+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
742745 use_deptry ()
743746 use_deptry (remove = True )
744747
@@ -2247,12 +2250,13 @@ def test_added(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
22472250 with (
22482251 change_cwd (uv_init_dir ),
22492252 PyprojectTOMLManager (),
2253+ SetupCFGManager (),
22502254 usethis_config .set (quiet = True ),
22512255 ):
22522256 add_deps_to_group ([Dependency (name = "pyproject-fmt" )], "dev" )
22532257
22542258 # Act
2255- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
2259+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
22562260 use_pyproject_fmt ()
22572261
22582262 # Assert
@@ -2276,7 +2280,7 @@ def test_added(self, uv_init_dir: Path, capfd: pytest.CaptureFixture[str]):
22762280 class TestDeps :
22772281 @pytest .mark .usefixtures ("_vary_network_conn" )
22782282 def test_added (self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]):
2279- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
2283+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
22802284 # Act
22812285 use_pyproject_fmt ()
22822286
@@ -2299,7 +2303,7 @@ def test_skips_apply(
22992303 self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]
23002304 ):
23012305 # Act
2302- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
2306+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
23032307 use_pyproject_fmt (no_apply = True )
23042308
23052309 # Assert
@@ -2352,7 +2356,7 @@ def test_config_file(self, uv_init_dir: Path):
23522356 )
23532357
23542358 # Act
2355- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
2359+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
23562360 use_pyproject_fmt (remove = True )
23572361
23582362 # Assert
@@ -2428,7 +2432,11 @@ def test_remove_with_precommit(
24282432 def test_remove_without_precommit (
24292433 self , uv_init_repo_dir : Path , capfd : pytest .CaptureFixture [str ]
24302434 ):
2431- with change_cwd (uv_init_repo_dir ), PyprojectTOMLManager ():
2435+ with (
2436+ change_cwd (uv_init_repo_dir ),
2437+ PyprojectTOMLManager (),
2438+ SetupCFGManager (),
2439+ ):
24322440 # Arrange
24332441 with usethis_config .set (quiet = True ):
24342442 use_pyproject_fmt ()
@@ -2902,6 +2910,7 @@ def test_start_from_nothing_uv_backend(
29022910 with (
29032911 change_cwd (tmp_path ),
29042912 PyprojectTOMLManager (),
2913+ SetupCFGManager (),
29052914 usethis_config .set (backend = BackendEnum .uv ),
29062915 ):
29072916 use_requirements_txt ()
@@ -2926,6 +2935,7 @@ def test_start_from_nothing_none_backend(
29262935 with (
29272936 change_cwd (tmp_path ),
29282937 PyprojectTOMLManager (),
2938+ SetupCFGManager (),
29292939 usethis_config .set (backend = BackendEnum .none ),
29302940 ):
29312941 use_requirements_txt ()
@@ -2946,6 +2956,7 @@ def test_start_from_nothing_poetry_backend(
29462956 with (
29472957 change_cwd (tmp_path ),
29482958 PyprojectTOMLManager (),
2959+ SetupCFGManager (),
29492960 usethis_config .set (backend = BackendEnum .poetry ),
29502961 ):
29512962 use_requirements_txt ()
@@ -2965,6 +2976,7 @@ def test_start_from_uv_init(
29652976 with (
29662977 change_cwd (uv_init_dir ),
29672978 PyprojectTOMLManager (),
2979+ SetupCFGManager (),
29682980 usethis_config .set (frozen = False ),
29692981 ):
29702982 use_requirements_txt ()
@@ -2985,6 +2997,7 @@ def test_start_from_uv_locked(
29852997 with (
29862998 change_cwd (uv_init_dir ),
29872999 PyprojectTOMLManager (),
3000+ SetupCFGManager (),
29883001 usethis_config .set (frozen = False ),
29893002 ):
29903003 # Arrange
@@ -3062,6 +3075,7 @@ def test_none_backend(
30623075 with (
30633076 change_cwd (tmp_path ),
30643077 PyprojectTOMLManager (),
3078+ SetupCFGManager (),
30653079 usethis_config .set (backend = BackendEnum .auto ),
30663080 ):
30673081 # Act
@@ -3092,7 +3106,7 @@ def test_file_gone(self, tmp_path: Path):
30923106 (tmp_path / "requirements.txt" ).touch ()
30933107
30943108 # Act
3095- with change_cwd (tmp_path ), PyprojectTOMLManager ():
3109+ with change_cwd (tmp_path ), PyprojectTOMLManager (), SetupCFGManager () :
30963110 use_requirements_txt (remove = True )
30973111
30983112 # Assert
@@ -3103,7 +3117,7 @@ def test_requirements_dir(self, tmp_path: Path):
31033117 (tmp_path / "requirements.txt" ).mkdir ()
31043118
31053119 # Act
3106- with change_cwd (tmp_path ), PyprojectTOMLManager ():
3120+ with change_cwd (tmp_path ), PyprojectTOMLManager (), SetupCFGManager () :
31073121 use_requirements_txt (remove = True )
31083122
31093123 # Assert
@@ -3130,7 +3144,7 @@ def test_precommit_integration(self, tmp_path: Path):
31303144 assert "uv-export" not in content
31313145
31323146 def test_roundtrip (self , tmp_path : Path ):
3133- with change_cwd (tmp_path ), PyprojectTOMLManager ():
3147+ with change_cwd (tmp_path ), PyprojectTOMLManager (), SetupCFGManager () :
31343148 # Arrange
31353149 use_requirements_txt ()
31363150
@@ -3156,6 +3170,7 @@ def test_custom_output_file_creates_correct_file(
31563170 with (
31573171 change_cwd (tmp_path ),
31583172 PyprojectTOMLManager (),
3173+ SetupCFGManager (),
31593174 usethis_config .set (backend = BackendEnum .uv ),
31603175 ):
31613176 use_requirements_txt (output_file = "constraints.txt" )
@@ -3190,7 +3205,7 @@ def test_custom_output_file_remove(self, tmp_path: Path):
31903205 (tmp_path / "constraints.txt" ).touch ()
31913206
31923207 # Act
3193- with change_cwd (tmp_path ), PyprojectTOMLManager ():
3208+ with change_cwd (tmp_path ), PyprojectTOMLManager (), SetupCFGManager () :
31943209 use_requirements_txt (remove = True , output_file = "constraints.txt" )
31953210
31963211 # Assert
@@ -3203,6 +3218,7 @@ def test_default_output_file_is_requirements_txt(
32033218 with (
32043219 change_cwd (tmp_path ),
32053220 PyprojectTOMLManager (),
3221+ SetupCFGManager (),
32063222 usethis_config .set (backend = BackendEnum .none ),
32073223 ):
32083224 use_requirements_txt ()
@@ -3968,7 +3984,7 @@ def test_dependency_added(self, uv_init_dir: Path):
39683984 @pytest .mark .usefixtures ("_vary_network_conn" )
39693985 def test_config (self , uv_init_dir : Path , capfd : pytest .CaptureFixture [str ]):
39703986 # Arrange
3971- with change_cwd (uv_init_dir ), PyprojectTOMLManager ():
3987+ with change_cwd (uv_init_dir ), PyprojectTOMLManager (), SetupCFGManager () :
39723988 add_deps_to_group ([Dependency (name = "ty" )], "dev" )
39733989
39743990 capfd .readouterr ()
0 commit comments