Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Do the same transformation to egg-info dirs that pkg_resources does #1051

Merged
merged 3 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog/1051.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Do the same transformation to egg_info dirs that pkg_resources does. This makes
it possible for hyphenated names to use the develop-inst-noop optimization (cf.
#910), which previously only worked with non-hyphenated egg names - by
:user:`hashbrowncipher`.
2 changes: 1 addition & 1 deletion src/tox/_pytestplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def initproj_(nameversion, filedefs=None, src_root=".", add_missing_setup_py=Tru
if not src_root:
src_root = "."
if isinstance(nameversion, six.string_types):
parts = nameversion.split(str("-"))
parts = nameversion.rsplit(str("-"), 1)
if len(parts) == 1:
parts.append("0.1")
name, version = parts
Expand Down
3 changes: 2 additions & 1 deletion src/tox/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from itertools import chain

import py
from pkg_resources import to_filename

import tox

Expand Down Expand Up @@ -295,7 +296,7 @@ def _needs_reinstall(self, setupdir, action):
sys_path = json.loads(out)
except ValueError:
sys_path = []
egg_info_fname = ".".join((name, "egg-info"))
egg_info_fname = ".".join((to_filename(name), "egg-info"))
for d in reversed(sys_path):
egg_info = py.path.local(d).join(egg_info_fname)
if egg_info.check():
Expand Down
16 changes: 11 additions & 5 deletions tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,12 @@ def test_usedevelop_mixed(initproj, cmd):
assert "sdist-make" in result.out


@pytest.mark.parametrize("skipsdist", [False, True])
@pytest.mark.parametrize("src_root", [".", "src"])
def test_test_usedevelop(cmd, initproj, src_root, monkeypatch):
def test_test_usedevelop(cmd, initproj, src_root, skipsdist, monkeypatch):
name = "example123-spameggs"
base = initproj(
"example123-0.5",
(name, "0.5"),
src_root=src_root,
filedefs={
"tests": {
Expand All @@ -546,8 +548,12 @@ def test_hello(pytestconfig):
changedir=tests
commands=
pytest --basetemp={envtmpdir} --junitxml=junit-{envname}.xml []
deps=pytest
""",
deps=pytest"""
+ """
skipsdist={}
""".format(
skipsdist
),
},
)
result = cmd("-v")
Expand All @@ -567,7 +573,7 @@ def test_hello(pytestconfig):

# see that things work with a different CWD
monkeypatch.chdir(base.dirname)
result = cmd("-c", "example123/tox.ini")
result = cmd("-c", "{}/tox.ini".format(name))
assert not result.ret
assert "develop-inst-noop" in result.out
assert re.match(
Expand Down