Skip to content

Commit

Permalink
bugfix specifying --installpkg breaks build with 3.5.0
Browse files Browse the repository at this point in the history
Resolves #1042.
  • Loading branch information
gaborbernat committed Oct 8, 2018
1 parent 6f8a1f0 commit 127991b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changelog/1042.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix regression with ``3.5.0``: specifying ``--installpkg`` raises ``AttributeError: 'str' object has no attribute 'basename'``
6 changes: 3 additions & 3 deletions src/tox/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ def get_local_package(config, report, session):
path = config.option.installpkg
if not path:
path = config.sdistsrc
path = session._resolve_package(path)
report.info("using package {!r}, skipping 'sdist' activity ".format(str(path)))
return path
py_path = py.path.local(session._resolve_package(path))
report.info("using package {!r}, skipping 'sdist' activity ".format(str(py_path)))
return py_path


def build_package(config, report, session):
Expand Down
19 changes: 17 additions & 2 deletions tests/unit/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def test_make_sdist_distshare(tmpdir, initproj):
assert package.ext == ".zip"
assert package == config.temp_dir.join(package.basename)

assert dist == config.distdir.join(package.basename[len("1-") :])
assert dist == config.distdir.join(package.basename[len("1-"):])
assert dist.check()
assert os.stat(str(dist)).st_ino == os.stat(str(package)).st_ino

sdist_share = config.distshare.join(package.basename[len("1-") :])
sdist_share = config.distshare.join(package.basename[len("1-"):])
assert sdist_share.check()
assert sdist_share.read("rb") == dist.read("rb"), (sdist_share, package)

Expand Down Expand Up @@ -389,3 +389,18 @@ def build_package(config, report, session):
assert len(dist_after) == 1
sdist = dist_after[0]
assert t1_package != sdist


def test_install_via_installpkg(mock_venv, initproj, cmd):
base = initproj(
"pkg-0.1",
filedefs={
"tox.ini": """
[tox]
install_cmd = python -m -c 'print("ok")' -- {opts} {packages}'
"""
},
)
fake_package = base.ensure(".tox", "dist", "pkg123-0.1.zip")
result = cmd("-e", "py", '--notest', '--installpkg', str(fake_package.relto(base)))
assert result.ret == 0, result.out

0 comments on commit 127991b

Please sign in to comment.