10
10
# See the License for the specific language governing permissions and
11
11
# limitations under the License.
12
12
13
+ import os
14
+
13
15
from unittest import mock
14
16
15
17
import pretend
@@ -157,17 +159,17 @@ def test_maybe_set_compound(monkeypatch, environ, base, name, envvar, expected):
157
159
158
160
159
161
@pytest .mark .parametrize (
160
- ("settings" , "environment" , "other_settings" ),
162
+ ("settings" , "environment" ),
161
163
[
162
- (None , config .Environment .production , {} ),
163
- ({}, config .Environment .production , {} ),
164
- ({"my settings" : "the settings value" }, config .Environment .production , {} ),
165
- (None , config .Environment .development , {} ),
166
- ({}, config .Environment .development , {} ),
167
- ({"my settings" : "the settings value" }, config .Environment .development , {} ),
164
+ (None , config .Environment .production ),
165
+ ({}, config .Environment .production ),
166
+ ({"my settings" : "the settings value" }, config .Environment .production ),
167
+ (None , config .Environment .development ),
168
+ ({}, config .Environment .development ),
169
+ ({"my settings" : "the settings value" }, config .Environment .development ),
168
170
],
169
171
)
170
- def test_configure (monkeypatch , settings , environment , other_settings ):
172
+ def test_configure (monkeypatch , settings , environment ):
171
173
json_renderer_obj = pretend .stub ()
172
174
json_renderer_cls = pretend .call_recorder (lambda ** kw : json_renderer_obj )
173
175
monkeypatch .setattr (renderers , "JSON" , json_renderer_cls )
@@ -176,8 +178,17 @@ def test_configure(monkeypatch, settings, environment, other_settings):
176
178
xmlrpc_renderer_cls = pretend .call_recorder (lambda ** kw : xmlrpc_renderer_obj )
177
179
monkeypatch .setattr (config , "XMLRPCRenderer" , xmlrpc_renderer_cls )
178
180
179
- if environment == config .Environment .development :
180
- monkeypatch .setenv ("WAREHOUSE_ENV" , "development" )
181
+ # Ignore all environment variables in the test environment, except for WAREHOUSE_ENV
182
+ monkeypatch .setattr (
183
+ os ,
184
+ "environ" ,
185
+ {
186
+ "WAREHOUSE_ENV" : {
187
+ config .Environment .development : "development" ,
188
+ config .Environment .production : "production" ,
189
+ }[environment ],
190
+ },
191
+ )
181
192
182
193
class FakeRegistry (dict ):
183
194
def __init__ (self ):
@@ -190,7 +201,7 @@ def __init__(self):
190
201
"warehouse.xmlrpc.client.ratelimit_string" : "3600 per hour" ,
191
202
}
192
203
193
- configurator_settings = other_settings . copy ()
204
+ configurator_settings = dict ()
194
205
configurator_obj = pretend .stub (
195
206
registry = FakeRegistry (),
196
207
set_root_factory = pretend .call_recorder (lambda rf : None ),
@@ -225,7 +236,7 @@ def __init__(self):
225
236
)
226
237
monkeypatch .setattr (config , "transaction" , transaction )
227
238
228
- result = config .configure (settings = settings )
239
+ result = config .configure (settings = settings . copy () if settings else None )
229
240
230
241
expected_settings = {
231
242
"warehouse.env" : environment ,
0 commit comments