22
33import pytest
44
5+ from usethis ._config_file import files_manager
56from usethis ._core .author import add_author
67from usethis ._file .pyproject_toml .io_ import PyprojectTOMLManager
78from usethis ._file .toml .errors import (
@@ -17,7 +18,7 @@ def test_no_authors_yet(self, tmp_path: Path, capfd: pytest.CaptureFixture[str])
1718 (tmp_path / "pyproject.toml" ).touch ()
1819
1920 # Act
20- with change_cwd (tmp_path ), PyprojectTOMLManager ():
21+ with change_cwd (tmp_path ), files_manager ():
2122 add_author (
2223 name = "John Cleese" ,
2324 email = "jc@example.com" ,
@@ -48,7 +49,7 @@ def test_append(self, tmp_path: Path):
4849 )
4950
5051 # Act
51- with change_cwd (tmp_path ), PyprojectTOMLManager ():
52+ with change_cwd (tmp_path ), files_manager ():
5253 add_author (
5354 name = "John Cleese" ,
5455 email = "jc@example.com" ,
@@ -71,7 +72,7 @@ def test_email_not_provided(self, tmp_path: Path):
7172 (tmp_path / "pyproject.toml" ).touch ()
7273
7374 # Act
74- with change_cwd (tmp_path ), PyprojectTOMLManager ():
75+ with change_cwd (tmp_path ), files_manager ():
7576 add_author (name = "John Cleese" )
7677
7778 # Assert
@@ -98,7 +99,7 @@ def test_overwrite(self, tmp_path: Path):
9899 )
99100
100101 # Act
101- with change_cwd (tmp_path ), PyprojectTOMLManager ():
102+ with change_cwd (tmp_path ), files_manager ():
102103 add_author (
103104 name = "Python Dev Team" ,
104105 overwrite = True ,
@@ -116,7 +117,7 @@ def test_overwrite(self, tmp_path: Path):
116117
117118 def test_no_pyproject_yet (self , tmp_path : Path ):
118119 # Act
119- with change_cwd (tmp_path ), PyprojectTOMLManager ():
120+ with change_cwd (tmp_path ), files_manager ():
120121 add_author (name = "John Cleese" )
121122
122123 # Assert
@@ -138,12 +139,14 @@ def test_doesnt_break_other_sections(self, tmp_path: Path):
138139 )
139140
140141 # Act
141- with change_cwd (tmp_path ), PyprojectTOMLManager () as manager :
142+ with change_cwd (tmp_path ), files_manager ():
143+ manager = PyprojectTOMLManager ()
142144 add_author (name = "John Cleese" )
143145 assert ["project" , "scripts" ] in manager
144146
145147 # Assert
146- with change_cwd (tmp_path ), PyprojectTOMLManager () as manager :
148+ with change_cwd (tmp_path ), files_manager ():
149+ manager = PyprojectTOMLManager ()
147150 assert ["project" ] in manager
148151 assert ["project" , "scripts" ] in manager
149152
@@ -158,7 +161,7 @@ def test_project_section_not_a_mapping(self, tmp_path: Path):
158161 # Act
159162 with (
160163 change_cwd (tmp_path ),
161- PyprojectTOMLManager (),
164+ files_manager (),
162165 pytest .raises (
163166 TOMLValueMissingError ,
164167 match = r"'project' is not a valid mapping .* does not contain the key 'authors'" ,
@@ -178,7 +181,7 @@ def test_authors_section_not_a_list(self, tmp_path: Path):
178181 # Act
179182 with (
180183 change_cwd (tmp_path ),
181- PyprojectTOMLManager (),
184+ files_manager (),
182185 pytest .raises (
183186 TOMLValueInvalidError , match = r"'project.authors' is not a valid list"
184187 ),
0 commit comments