Skip to content

Commit 6dbd865

Browse files
blueyedgaborbernat
authored andcommitted
toxworkdir: use realpath (#1171)
* toxworkdir: use realpath Fixes #1169. * ensure tox.ini * no need for --help anymore * use tmp_path * changelog
1 parent 3551bea commit 6dbd865

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

docs/changelog/1169.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Resolve symlinks with ``toxworkdir`` - by :user:`blueyed`.

src/tox/config/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,9 @@ def __init__(self, config, ini_path, ini_data): # noqa
999999
else:
10001000
config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True)
10011001

1002+
if os.path.exists(str(config.toxworkdir)):
1003+
config.toxworkdir = config.toxworkdir.realpath()
1004+
10021005
if config.option.skip_missing_interpreters == "config":
10031006
val = reader.getbool("skip_missing_interpreters", False)
10041007
config.option.skip_missing_interpreters = "true" if val else "false"

tests/unit/config/test_config.py

+15
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@ def test_explicit_config_path(self, tmpdir):
276276
config = parseconfig(["-c", str(path)])
277277
assert config.toxinipath == config_file_path
278278

279+
@pytest.mark.skipif(sys.platform == "win32", reason="no symlinks on Windows")
280+
def test_workdir_gets_resolved(self, tmp_path, monkeypatch):
281+
"""
282+
Test explicitly setting config path, both with and without the filename
283+
"""
284+
real = tmp_path / "real"
285+
real.mkdir()
286+
symlink = tmp_path / "link"
287+
symlink.symlink_to(real)
288+
289+
(tmp_path / "tox.ini").touch()
290+
monkeypatch.chdir(tmp_path)
291+
config = parseconfig(["--workdir", str(symlink)])
292+
assert config.toxworkdir == real
293+
279294

280295
def test_get_homedir(monkeypatch):
281296
monkeypatch.setattr(py.path.local, "_gethomedir", classmethod(lambda x: {}[1]))

0 commit comments

Comments
 (0)