diff --git a/tests/test_z_cmdline.py b/tests/test_z_cmdline.py index b2dcb9f50..b9783d53e 100644 --- a/tests/test_z_cmdline.py +++ b/tests/test_z_cmdline.py @@ -576,8 +576,9 @@ def test_usedevelop_mixed(initproj, cmd): assert "sdist-make" in result.stdout.str() -def test_test_usedevelop(cmd, initproj): - initproj("example123-0.5", filedefs={ +@pytest.mark.parametrize("src_root", [".", "src"]) +def test_test_usedevelop(cmd, initproj, src_root): + initproj("example123-0.5", src_root=src_root, filedefs={ 'tests': { 'test_hello.py': """ def test_hello(pytestconfig): @@ -602,6 +603,7 @@ def test_hello(pytestconfig): assert "sdist-make" not in result.stdout.str() result = cmd.run("tox", "-epython", ) assert not result.ret + assert "develop-inst-noop" in result.stdout.str() result.stdout.fnmatch_lines([ "*1 passed*", "*summary*", @@ -611,6 +613,7 @@ def test_hello(pytestconfig): old = cmd.tmpdir.chdir() result = cmd.run("tox", "-c", "example123/tox.ini") assert not result.ret + assert "develop-inst-noop" in result.stdout.str() result.stdout.fnmatch_lines([ "*1 passed*", "*summary*", @@ -623,11 +626,18 @@ def test_hello(pytestconfig): testfile.write("def test_fail(): assert 0") result = cmd.run("tox", ) assert result.ret + assert "develop-inst-noop" in result.stdout.str() result.stdout.fnmatch_lines([ "*1 failed*", "*summary*", "*python: *failed*", ]) + # test develop is called if setup.py changes + setup_py = py.path.local("setup.py") + setup_py.write(setup_py.read() + ' ') + result = cmd.run("tox", ) + assert result.ret + assert "develop-inst-nodeps" in result.stdout.str() def test_alwayscopy(initproj, cmd): diff --git a/tox/_pytestplugin.py b/tox/_pytestplugin.py index 129678a21..047df7160 100644 --- a/tox/_pytestplugin.py +++ b/tox/_pytestplugin.py @@ -290,7 +290,7 @@ def fnmatch_lines(self, lines2): @pytest.fixture def initproj(request, tmpdir): """ create a factory function for creating example projects. """ - def initproj(nameversion, filedefs=None): + def initproj(nameversion, filedefs=None, src_root="."): if filedefs is None: filedefs = {} if _istext(nameversion) or _isbytes(nameversion): @@ -304,18 +304,20 @@ def initproj(nameversion, filedefs=None): create_files(base, filedefs) if 'setup.py' not in filedefs: create_files(base, {'setup.py': ''' - from setuptools import setup + from setuptools import setup, find_packages setup( name='%(name)s', description='%(name)s project', version='%(version)s', license='MIT', platforms=['unix', 'win32'], - packages=['%(name)s', ], + packages=find_packages('%(src_root)s'), + package_dir={'':'%(src_root)s'}, ) ''' % locals()}) if name not in filedefs: - create_files(base, { + src_dir = base.ensure(src_root, dir=1) + create_files(src_dir, { name: {'__init__.py': '__version__ = %r' % version} }) manifestlines = []