diff --git a/docs/changelog/1169.bugfix.rst b/docs/changelog/1169.bugfix.rst new file mode 100644 index 000000000..7079b1fdb --- /dev/null +++ b/docs/changelog/1169.bugfix.rst @@ -0,0 +1 @@ +Resolve symlinks with ``toxworkdir`` - by :user:`blueyed`. diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 156272359..666125811 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -999,6 +999,9 @@ def __init__(self, config, ini_path, ini_data): # noqa else: config.toxworkdir = config.toxinidir.join(config.option.workdir, abs=True) + if os.path.exists(str(config.toxworkdir)): + config.toxworkdir = config.toxworkdir.realpath() + if config.option.skip_missing_interpreters == "config": val = reader.getbool("skip_missing_interpreters", False) config.option.skip_missing_interpreters = "true" if val else "false" diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py index a134fd657..02aff7988 100644 --- a/tests/unit/config/test_config.py +++ b/tests/unit/config/test_config.py @@ -276,6 +276,21 @@ def test_explicit_config_path(self, tmpdir): config = parseconfig(["-c", str(path)]) assert config.toxinipath == config_file_path + @pytest.mark.skipif(sys.platform == "win32", reason="no symlinks on Windows") + def test_workdir_gets_resolved(self, tmp_path, monkeypatch): + """ + Test explicitly setting config path, both with and without the filename + """ + real = tmp_path / "real" + real.mkdir() + symlink = tmp_path / "link" + symlink.symlink_to(real) + + (tmp_path / "tox.ini").touch() + monkeypatch.chdir(tmp_path) + config = parseconfig(["--workdir", str(symlink)]) + assert config.toxworkdir == real + def test_get_homedir(monkeypatch): monkeypatch.setattr(py.path.local, "_gethomedir", classmethod(lambda x: {}[1]))