Skip to content

Commit

Permalink
toxworkdir: use realpath (#1171)
Browse files Browse the repository at this point in the history
* toxworkdir: use realpath

Fixes #1169.

* ensure tox.ini

* no need for --help anymore

* use tmp_path

* changelog
  • Loading branch information
blueyed authored and gaborbernat committed Feb 24, 2019
1 parent 3551bea commit 6dbd865
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1169.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Resolve symlinks with ``toxworkdir`` - by :user:`blueyed`.
3 changes: 3 additions & 0 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down

0 comments on commit 6dbd865

Please sign in to comment.