Merge branch 'master' into merge-master

# Conflicts:
#	AUTHORS
#	CHANGELOG.rst
#	_pytest/monkeypatch.py
#	_pytest/python.py
This commit is contained in:
Bruno Oliveira
2016-07-25 19:04:39 -03:00
18 changed files with 216 additions and 50 deletions

View File

@@ -121,6 +121,18 @@ class TestClass:
colitems = modcol.collect()
assert len(colitems) == 0
def test_issue1579_namedtuple(self, testdir):
testdir.makepyfile("""
import collections
TestCase = collections.namedtuple('TestCase', ['a'])
""")
result = testdir.runpytest('-rw')
result.stdout.fnmatch_lines(
"*cannot collect test class 'TestCase' "
"because it has a __new__ constructor*"
)
class TestGenerator:
def test_generative_functions(self, testdir):

View File

@@ -351,6 +351,38 @@ class TestFillFixtures:
result = testdir.runpytest(testfile)
result.stdout.fnmatch_lines(["*3 passed*"])
def test_override_autouse_fixture_with_parametrized_fixture_conftest_conftest(self, testdir):
"""Test override of the autouse fixture with parametrized one on the conftest level.
This test covers the issue explained in issue 1601
"""
testdir.makeconftest("""
import pytest
@pytest.fixture(autouse=True)
def spam():
return 'spam'
""")
subdir = testdir.mkpydir('subdir')
subdir.join("conftest.py").write(_pytest._code.Source("""
import pytest
@pytest.fixture(params=[1, 2, 3])
def spam(request):
return request.param
"""))
testfile = subdir.join("test_spam.py")
testfile.write(_pytest._code.Source("""
params = {'spam': 1}
def test_spam(spam):
assert spam == params['spam']
params['spam'] += 1
"""))
result = testdir.runpytest()
result.stdout.fnmatch_lines(["*3 passed*"])
result = testdir.runpytest(testfile)
result.stdout.fnmatch_lines(["*3 passed*"])
def test_autouse_fixture_plugin(self, testdir):
# A fixture from a plugin has no baseid set, which screwed up
# the autouse fixture handling.

View File

@@ -930,6 +930,43 @@ class TestMetafuncFunctional:
reprec = testdir.inline_run()
reprec.assertoutcome(passed=5)
def test_parametrize_issue634(self, testdir):
testdir.makepyfile('''
import pytest
@pytest.fixture(scope='module')
def foo(request):
print('preparing foo-%d' % request.param)
return 'foo-%d' % request.param
def test_one(foo):
pass
def test_two(foo):
pass
test_two.test_with = (2, 3)
def pytest_generate_tests(metafunc):
params = (1, 2, 3, 4)
if not 'foo' in metafunc.fixturenames:
return
test_with = getattr(metafunc.function, 'test_with', None)
if test_with:
params = test_with
metafunc.parametrize('foo', params, indirect=True)
''')
result = testdir.runpytest("-s")
output = result.stdout.str()
assert output.count('preparing foo-2') == 1
assert output.count('preparing foo-3') == 1
def test_parametrize_issue323(self, testdir):
testdir.makepyfile("""
import pytest