12
12
from tests .helpers .runner import CliRunner , Result
13
13
14
14
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
+
15
23
@pytest .fixture
16
24
def repo_with_ddev_tool_config (repository_as_cwd : ClonedRepo ) -> Generator [ClonedRepo , None , None ]:
17
25
pyproject_path = repository_as_cwd .path / "pyproject.toml"
@@ -130,7 +138,10 @@ def test_not_in_repo_ask_user(ddev: CliRunner, config_file: ConfigFileWithOverri
130
138
def test_pyproject_not_found_ask_user (
131
139
ddev : CliRunner , config_file : ConfigFileWithOverrides , helpers , repository_as_cwd : ClonedRepo
132
140
):
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
+
134
145
result = ddev ("config" , "override" , input = "extras" )
135
146
extras_path = str (config_file .overrides_path .parent ).replace ("\\ " , "\\ \\ " )
136
147
@@ -145,13 +156,17 @@ def test_pyproject_not_found_ask_user(
145
156
extras = "{ extras_path } "
146
157
"""
147
158
)
159
+
148
160
# Reload new values
149
161
config_file .load ()
150
162
assert_valid_local_config (config_file , config_file .overrides_path .parent , result , expected_output )
151
163
164
+ # Restore the original pyproject.toml
165
+ backup_pyproject .rename (original_pyproject )
166
+
152
167
153
168
def 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
155
170
):
156
171
# Setup wrongly configured pyproject.toml
157
172
pyproject_path = repository_as_cwd .path / "pyproject.toml"
0 commit comments