Repository: tox-dev/tox

Issue:
why the arguments are changed?


When using the *posargs*， the path in the argument is changed with no reason. Why ?

tox.ini
```
[tox]
envlist=py27,py36
skipsdist=True

[testenv]
deps = pytest
commands=pytest -s tests {posargs}
```


![image](https://user-images.githubusercontent.com/1487879/49358412-8dc60300-f70d-11e8-890e-7559e484b4ab.png)


Discussion:

Patch:
diff --git a/docs/changelog/1095.bugfix.rst b/docs/changelog/1095.bugfix.rst
new file mode 100644
index 00000000..9d0abc24
--- /dev/null
+++ b/docs/changelog/1095.bugfix.rst
@@ -0,0 +1,1 @@
+Don't rewrite ``{posargs}`` substitution for absolute paths.
diff --git a/src/tox/config.py b/src/tox/config.py
index b499a8aa..4d5e02be 100755
--- a/src/tox/config.py
+++ b/src/tox/config.py
@@ -184,10 +184,10 @@ class PosargsOption:
             if value:
                 args = []
                 for arg in config.option.args:
-                    if arg:
-                        origpath = config.invocationcwd.join(arg, abs=True)
-                        if origpath.check():
-                            arg = testenv_config.changedir.bestrelpath(origpath)
+                    if arg and not os.path.isabs(arg):
+                        origpath = os.path.join(config.invocationcwd.strpath, arg)
+                        if os.path.exists(origpath):
+                            arg = os.path.relpath(origpath, testenv_config.changedir.strpath)
                     args.append(arg)
             testenv_config._reader.addsubstitutions(args)
         return value


Test patch:
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
index 86f36319..08a1ced4 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -11,6 +11,7 @@ import tox
 from tox.config import (
     CommandParser,
     DepOption,
+    PosargsOption,
     SectionReader,
     get_homedir,
     get_version_info,
@@ -2969,3 +2970,29 @@ def test_config_current_py(newconfig, current_tox_py, cmd, tmpdir, monkeypatch):
     assert config.envconfigs[current_tox_py]
     result = cmd()
     assert result.ret == 0, result.out
+
+
+def test_posargs_relative_changedir(newconfig, tmpdir):
+    dir1 = tmpdir.join("dir1").ensure()
+    tmpdir.join("dir2").ensure()
+    with tmpdir.as_cwd():
+        config = newconfig(
+            """\
+            [tox]
+            [testenv]
+            changedir = dir2
+            commands =
+                echo {posargs}
+            """
+        )
+        config.option.args = ["dir1", dir1.strpath, "dir3"]
+        testenv = config.envconfigs["python"]
+        PosargsOption().postprocess(testenv, config.option.args)
+
+        assert testenv._reader.posargs == [
+            # should have relative-ized
+            os.path.join("..", "dir1"),
+            # should have stayed the same,
+            dir1.strpath,
+            "dir3",
+        ]