@@ -248,6 +248,97 @@ def test_config_parse_platform_with_factors(self, newconfig, plat):
248
248
expected = {"win" : "win32" , "lin" : "linux2" , "osx" : "" }.get (plat )
249
249
assert platform == expected
250
250
251
+ def test_platform_install_command (self , newconfig , mocksession , monkeypatch ):
252
+ # Expanded from docs/example/platform.html
253
+ config = newconfig (
254
+ [],
255
+ """
256
+ [tox]
257
+ envlist = py{27,36}-{mylinux,mymacos,mywindows}
258
+
259
+ [testenv]
260
+ platform =
261
+ mylinux: linux
262
+ mymacos: darwin
263
+ mywindows: win32
264
+
265
+ deps =
266
+ mylinux,mymacos: py==1.4.32
267
+ mywindows: py==1.4.30
268
+
269
+ install_command =
270
+ mylinux: python -m pip install {packages} distro
271
+ mywindows: python -m pip install {packages} pywin32
272
+
273
+ commands=
274
+ mylinux: echo Linus
275
+ mymacos: echo Steve
276
+ mywindows: echo Bill
277
+ """ ,
278
+ )
279
+ mocksession .config = config
280
+ assert len (config .envconfigs ) == 6
281
+
282
+ monkeypatch .setattr (sys , "platform" , "linux" )
283
+
284
+ venv = mocksession .getvenv ("py27-mylinux" )
285
+ assert venv .envconfig ._reader .factors == {"py27" , "mylinux" }
286
+ assert venv .matching_platform ()
287
+ assert str (venv .envconfig .deps [0 ]) == "py==1.4.32"
288
+ assert venv .envconfig .install_command == [
289
+ "python" ,
290
+ "-m" ,
291
+ "pip" ,
292
+ "install" ,
293
+ "{packages}" ,
294
+ "distro" ,
295
+ ]
296
+ assert venv .envconfig .commands [0 ] == ["echo" , "Linus" ]
297
+
298
+ venv = mocksession .getvenv ("py27-mymacos" )
299
+ assert venv .envconfig ._reader .factors == {"py27" , "mymacos" }
300
+ assert not venv .matching_platform ()
301
+ assert str (venv .envconfig .deps [0 ]) == "py==1.4.32"
302
+ assert venv .envconfig .install_command == [
303
+ "python" ,
304
+ "-m" ,
305
+ "pip" ,
306
+ "install" ,
307
+ "{opts}" ,
308
+ "{packages}" ,
309
+ ]
310
+ assert venv .envconfig .commands [0 ] == ["echo" , "Steve" ]
311
+
312
+ venv = mocksession .getvenv ("py27-mywindows" )
313
+ assert venv .envconfig ._reader .factors == {"py27" , "mywindows" }
314
+ assert not venv .matching_platform ()
315
+ assert str (venv .envconfig .deps [0 ]) == "py==1.4.30"
316
+ assert venv .envconfig .install_command == [
317
+ "python" ,
318
+ "-m" ,
319
+ "pip" ,
320
+ "install" ,
321
+ "{packages}" ,
322
+ "pywin32" ,
323
+ ]
324
+ assert venv .envconfig .commands [0 ] == ["echo" , "Bill" ]
325
+
326
+ monkeypatch .undo ()
327
+
328
+ monkeypatch .setattr (sys , "platform" , "darwin" )
329
+
330
+ venv = mocksession .getvenv ("py27-mymacos" )
331
+ assert venv .envconfig .install_command == [
332
+ "python" ,
333
+ "-m" ,
334
+ "pip" ,
335
+ "install" ,
336
+ "{opts}" ,
337
+ "{packages}" ,
338
+ ]
339
+
340
+ monkeypatch .undo ()
341
+
251
342
252
343
class TestConfigPackage :
253
344
def test_defaults (self , tmpdir , newconfig ):
0 commit comments