Skip to content

Commit cb6ca79

Browse files
committed
Tests to show issue tox-dev#464
1 parent 5df724f commit cb6ca79

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/test_z_cmdline.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,9 @@ def test_usedevelop_mixed(initproj, cmd):
576576
assert "sdist-make" in result.stdout.str()
577577

578578

579-
def test_test_usedevelop(cmd, initproj):
580-
initproj("example123-0.5", filedefs={
579+
@pytest.mark.parametrize("src_root", [".", "src"])
580+
def test_test_usedevelop(cmd, initproj, src_root):
581+
initproj("example123-0.5", src_root=src_root, filedefs={
581582
'tests': {
582583
'test_hello.py': """
583584
def test_hello(pytestconfig):
@@ -602,6 +603,7 @@ def test_hello(pytestconfig):
602603
assert "sdist-make" not in result.stdout.str()
603604
result = cmd.run("tox", "-epython", )
604605
assert not result.ret
606+
assert "develop-inst-noop" in result.stdout.str()
605607
result.stdout.fnmatch_lines([
606608
"*1 passed*",
607609
"*summary*",
@@ -611,6 +613,7 @@ def test_hello(pytestconfig):
611613
old = cmd.tmpdir.chdir()
612614
result = cmd.run("tox", "-c", "example123/tox.ini")
613615
assert not result.ret
616+
assert "develop-inst-noop" in result.stdout.str()
614617
result.stdout.fnmatch_lines([
615618
"*1 passed*",
616619
"*summary*",
@@ -623,11 +626,18 @@ def test_hello(pytestconfig):
623626
testfile.write("def test_fail(): assert 0")
624627
result = cmd.run("tox", )
625628
assert result.ret
629+
assert "develop-inst-noop" in result.stdout.str()
626630
result.stdout.fnmatch_lines([
627631
"*1 failed*",
628632
"*summary*",
629633
"*python: *failed*",
630634
])
635+
# test develop is called if setup.py changes
636+
setup_py = py.path.local("setup.py")
637+
setup_py.write(setup_py.read() + ' ')
638+
result = cmd.run("tox", )
639+
assert result.ret
640+
assert "develop-inst-nodeps" in result.stdout.str()
631641

632642

633643
def test_alwayscopy(initproj, cmd):

tox/_pytestplugin.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def fnmatch_lines(self, lines2):
290290
@pytest.fixture
291291
def initproj(request, tmpdir):
292292
""" create a factory function for creating example projects. """
293-
def initproj(nameversion, filedefs=None):
293+
def initproj(nameversion, filedefs=None, src_root="."):
294294
if filedefs is None:
295295
filedefs = {}
296296
if _istext(nameversion) or _isbytes(nameversion):
@@ -304,18 +304,20 @@ def initproj(nameversion, filedefs=None):
304304
create_files(base, filedefs)
305305
if 'setup.py' not in filedefs:
306306
create_files(base, {'setup.py': '''
307-
from setuptools import setup
307+
from setuptools import setup, find_packages
308308
setup(
309309
name='%(name)s',
310310
description='%(name)s project',
311311
version='%(version)s',
312312
license='MIT',
313313
platforms=['unix', 'win32'],
314-
packages=['%(name)s', ],
314+
packages=find_packages('%(src_root)s'),
315+
package_dir={'':'%(src_root)s'},
315316
)
316317
''' % locals()})
317318
if name not in filedefs:
318-
create_files(base, {
319+
src_dir = base.ensure(src_root, dir=1)
320+
create_files(src_dir, {
319321
name: {'__init__.py': '__version__ = %r' % version}
320322
})
321323
manifestlines = []

0 commit comments

Comments
 (0)