@@ -91,6 +91,28 @@ def test_envdir_set_manually_with_substitutions(self, newconfig):
91
91
envconfig = config .envconfigs ["dev" ]
92
92
assert envconfig .envdir == config .toxworkdir .join ("foobar" )
93
93
94
+ def test_envdir_set_manually_with_pound (self , newconfig ):
95
+ config = newconfig (
96
+ [],
97
+ """
98
+ [testenv:dev]
99
+ envdir = {toxworkdir}/foo#bar
100
+ """ ,
101
+ )
102
+ envconfig = config .envconfigs ["dev" ]
103
+ assert envconfig .envdir == config .toxworkdir .join ("foo#bar" )
104
+
105
+ def test_envdir_set_manually_with_whitespace (self , newconfig ):
106
+ config = newconfig (
107
+ [],
108
+ """
109
+ [testenv:dev]
110
+ envdir = {toxworkdir}/foo bar
111
+ """ ,
112
+ )
113
+ envconfig = config .envconfigs ["dev" ]
114
+ assert envconfig .envdir == config .toxworkdir .join ("foo bar" )
115
+
94
116
def test_force_dep_version (self , initproj ):
95
117
"""
96
118
Make sure we can override dependencies configured in tox.ini when using the command line
@@ -496,6 +518,85 @@ def test_regression_issue595(self, newconfig):
496
518
assert config .envconfigs ["bar" ].setenv ["VAR" ] == "x"
497
519
assert "VAR" not in config .envconfigs ["baz" ].setenv
498
520
521
+ def test_command_substitution_pound (self , tmpdir , newconfig ):
522
+ """Ensure pound in path is kept in commands."""
523
+ config = newconfig (
524
+ """
525
+ [tox]
526
+ toxworkdir = {toxinidir}/.tox#dir
527
+
528
+ [testenv:py27]
529
+ commands = '{envpython}' '{toxworkdir}'{/}'foo#bar'
530
+ """ ,
531
+ )
532
+
533
+ assert config .toxworkdir .realpath () == tmpdir .join (".tox#dir" ).realpath ()
534
+
535
+ envconfig = config .envconfigs ["py27" ]
536
+
537
+ assert envconfig .envbindir .realpath () in [
538
+ tmpdir .join (".tox#dir" , "py27" , "bin" ).realpath (),
539
+ tmpdir .join (".tox#dir" , "py27" , "Scripts" ).realpath (),
540
+ ]
541
+
542
+ assert envconfig .commands [0 ] == [
543
+ str (envconfig .envbindir .join ("python" )),
544
+ str (config .toxworkdir .join ("foo#bar" )),
545
+ ]
546
+
547
+ def test_command_substitution_whitespace (self , tmpdir , newconfig ):
548
+ """Ensure spaces in path is kept in commands."""
549
+ config = newconfig (
550
+ """
551
+ [tox]
552
+ toxworkdir = {toxinidir}/.tox dir
553
+
554
+ [testenv:py27]
555
+ commands = '{envpython}' '{toxworkdir}'{/}'foo bar'
556
+ """ ,
557
+ )
558
+
559
+ assert config .toxworkdir .realpath () == tmpdir .join (".tox dir" ).realpath ()
560
+
561
+ envconfig = config .envconfigs ["py27" ]
562
+
563
+ assert envconfig .envbindir .realpath () in [
564
+ tmpdir .join (".tox dir" , "py27" , "bin" ).realpath (),
565
+ tmpdir .join (".tox dir" , "py27" , "Scripts" ).realpath (),
566
+ ]
567
+
568
+ assert envconfig .commands [0 ] == [
569
+ str (envconfig .envbindir .join ("python" )),
570
+ str (config .toxworkdir .join ("foo bar" ).realpath ()),
571
+ ]
572
+
573
+ def test_command_env_substitution_bracket (self , tmpdir , newconfig ):
574
+ """Ensure bracket in path is kept in commands using setenv."""
575
+ config = newconfig (
576
+ """
577
+ [tox]
578
+ toxworkdir = {toxinidir}/.tox{dir
579
+
580
+ [testenv:py27]
581
+ setenv = VAR = '{toxworkdir}'{/}'foo{bar'
582
+ commands = '{envpython}' '{env:VAR}'
583
+ """ ,
584
+ )
585
+
586
+ assert config .toxworkdir .realpath () == tmpdir .join (".tox{dir" ).realpath ()
587
+
588
+ envconfig = config .envconfigs ["py27" ]
589
+
590
+ assert envconfig .envbindir .realpath () in [
591
+ tmpdir .join (".tox{dir" , "py27" , "bin" ).realpath (),
592
+ tmpdir .join (".tox{dir" , "py27" , "Scripts" ).realpath (),
593
+ ]
594
+
595
+ assert envconfig .commands [0 ] == [
596
+ str (envconfig .envbindir .join ("python" )),
597
+ str (config .toxworkdir .join ("foo{bar" ).realpath ()),
598
+ ]
599
+
499
600
500
601
class TestIniParser :
501
602
def test_getstring_single (self , newconfig ):
@@ -1084,6 +1185,46 @@ def test_envbindir(self, newconfig):
1084
1185
envconfig = config .envconfigs ["python" ]
1085
1186
assert envconfig .envpython == envconfig .envbindir .join ("python" )
1086
1187
1188
+ def test_envbindir_with_pound (self , newconfig ):
1189
+ config = newconfig (
1190
+ """
1191
+ [tox]
1192
+ toxworkdir = {toxinidir}/.tox#dir
1193
+ [testenv]
1194
+ basepython=python
1195
+ """ ,
1196
+ )
1197
+ assert len (config .envconfigs ) == 1
1198
+ envconfig = config .envconfigs ["python" ]
1199
+
1200
+ assert ".tox#dir" in str (envconfig .envbindir )
1201
+ assert ".tox#dir" in str (envconfig .envpython )
1202
+
1203
+ assert "'" not in str (envconfig .envbindir )
1204
+ assert "'" not in str (envconfig .envpython )
1205
+
1206
+ assert envconfig .envpython == envconfig .envbindir .join ("python" )
1207
+
1208
+ def test_envbindir_with_whitespace (self , newconfig ):
1209
+ config = newconfig (
1210
+ """
1211
+ [tox]
1212
+ toxworkdir = {toxinidir}/.tox dir
1213
+ [testenv]
1214
+ basepython=python
1215
+ """ ,
1216
+ )
1217
+ assert len (config .envconfigs ) == 1
1218
+ envconfig = config .envconfigs ["python" ]
1219
+
1220
+ assert ".tox dir" in str (envconfig .envbindir )
1221
+ assert ".tox dir" in str (envconfig .envpython )
1222
+
1223
+ assert "'" not in str (envconfig .envbindir )
1224
+ assert "'" not in str (envconfig .envpython )
1225
+
1226
+ assert envconfig .envpython == envconfig .envbindir .join ("python" )
1227
+
1087
1228
@pytest .mark .parametrize ("bp" , ["jython" , "pypy" , "pypy3" ])
1088
1229
def test_envbindir_jython (self , newconfig , bp ):
1089
1230
config = newconfig (
@@ -1511,7 +1652,7 @@ def test_rewrite_posargs(self, tmpdir, newconfig):
1511
1652
argv = conf .commands
1512
1653
assert argv [0 ] == ["cmd1" , "hello" ]
1513
1654
1514
- def test_rewrite_simple_posargs (self , tmpdir , newconfig ):
1655
+ def test_rewrite_posargs_simple (self , tmpdir , newconfig ):
1515
1656
inisource = """
1516
1657
[testenv:py27]
1517
1658
args_are_paths = True
@@ -1531,6 +1672,47 @@ def test_rewrite_simple_posargs(self, tmpdir, newconfig):
1531
1672
argv = conf .commands
1532
1673
assert argv [0 ] == ["cmd1" , "hello" ]
1533
1674
1675
+ def test_rewrite_posargs_pound (self , tmpdir , newconfig ):
1676
+ inisource = """
1677
+ [testenv:py27]
1678
+ args_are_paths = True
1679
+ changedir = test#dir
1680
+ commands = cmd1 {posargs:hello}
1681
+ """
1682
+ conf = newconfig ([], inisource ).envconfigs ["py27" ]
1683
+ argv = conf .commands
1684
+ assert argv [0 ] == ["cmd1" , "hello" ]
1685
+
1686
+ if sys .platform != "win32" :
1687
+ conf = newconfig (["test#dir/hello" ], inisource ).envconfigs ["py27" ]
1688
+ argv = conf .commands
1689
+ assert argv [0 ] == ["cmd1" , "test#dir/hello" ]
1690
+
1691
+ tmpdir .ensure ("test#dir" , "hello" )
1692
+ conf = newconfig (["test#dir/hello" ], inisource ).envconfigs ["py27" ]
1693
+ argv = conf .commands
1694
+ assert argv [0 ] == ["cmd1" , "hello" ]
1695
+
1696
+ def test_rewrite_posargs_whitespace (self , tmpdir , newconfig ):
1697
+ inisource = """
1698
+ [testenv:py27]
1699
+ args_are_paths = True
1700
+ changedir = test dir
1701
+ commands = cmd1 {posargs:hello}
1702
+ """
1703
+ conf = newconfig ([], inisource ).envconfigs ["py27" ]
1704
+ argv = conf .commands
1705
+ assert argv [0 ] == ["cmd1" , "hello" ]
1706
+
1707
+ conf = newconfig (["test dir/hello" ], inisource ).envconfigs ["py27" ]
1708
+ argv = conf .commands
1709
+ assert argv [0 ] == ["cmd1" , "test dir/hello" ]
1710
+
1711
+ tmpdir .ensure ("test dir" , "hello" )
1712
+ conf = newconfig (["test dir/hello" ], inisource ).envconfigs ["py27" ]
1713
+ argv = conf .commands
1714
+ assert argv [0 ] == ["cmd1" , "hello" ]
1715
+
1534
1716
@pytest .mark .parametrize (
1535
1717
"envlist, deps" ,
1536
1718
[
0 commit comments