Skip to content

Commit

Permalink
Tests to show issue tox-dev#464
Browse files Browse the repository at this point in the history
  • Loading branch information
selimb committed Mar 9, 2017
1 parent 35231d4 commit 2402231
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 12 additions & 2 deletions tests/test_z_cmdline.py
Expand Up @@ -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):
Expand All @@ -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*",
Expand All @@ -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*",
Expand All @@ -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):
Expand Down
10 changes: 6 additions & 4 deletions tox/_pytestplugin.py
Expand Up @@ -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):
Expand All @@ -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 = []
Expand Down

0 comments on commit 2402231

Please sign in to comment.