1212from tests .helpers .runner import CliRunner , Result
1313
1414
15+ @pytest .fixture (autouse = True )
16+ # Ensure the local override is removed from any test if we have generated it
17+ def delete_local_override_config (config_file : ConfigFileWithOverrides ):
18+ yield
19+ if config_file .overrides_available ():
20+ config_file .overrides_path .unlink ()
21+
22+
1523@pytest .fixture
1624def repo_with_ddev_tool_config (repository_as_cwd : ClonedRepo ) -> Generator [ClonedRepo , None , None ]:
1725 pyproject_path = repository_as_cwd .path / "pyproject.toml"
@@ -130,7 +138,10 @@ def test_not_in_repo_ask_user(ddev: CliRunner, config_file: ConfigFileWithOverri
130138def test_pyproject_not_found_ask_user (
131139 ddev : CliRunner , config_file : ConfigFileWithOverrides , helpers , repository_as_cwd : ClonedRepo
132140):
133- (repository_as_cwd .path / "pyproject.toml" ).unlink ()
141+ original_pyproject = repository_as_cwd .path / "pyproject.toml"
142+ backup_pyproject = original_pyproject .with_suffix (".bak" )
143+ original_pyproject .rename (backup_pyproject )
144+
134145 result = ddev ("config" , "override" , input = "extras" )
135146 extras_path = str (config_file .overrides_path .parent ).replace ("\\ " , "\\ \\ " )
136147
@@ -145,13 +156,17 @@ def test_pyproject_not_found_ask_user(
145156 extras = "{ extras_path } "
146157 """
147158 )
159+
148160 # Reload new values
149161 config_file .load ()
150162 assert_valid_local_config (config_file , config_file .overrides_path .parent , result , expected_output )
151163
164+ # Restore the original pyproject.toml
165+ backup_pyproject .rename (original_pyproject )
166+
152167
153168def test_misconfigured_pyproject_fails (
154- ddev : CliRunner , config_file : ConfigFileWithOverrides , helpers , repository_as_cwd : ClonedRepo
169+ ddev : CliRunner , config_file : ConfigFileWithOverrides , repository_as_cwd : ClonedRepo
155170):
156171 # Setup wrongly configured pyproject.toml
157172 pyproject_path = repository_as_cwd .path / "pyproject.toml"
0 commit comments