Merge branch 'pytest-2.7'
This commit is contained in:
@@ -865,3 +865,47 @@ def test_unorderable_types(testdir):
|
||||
result = testdir.runpytest()
|
||||
assert "TypeError" not in result.stdout.str()
|
||||
assert result.ret == 0
|
||||
|
||||
|
||||
def test_collect_functools_partial(testdir):
|
||||
"""
|
||||
Test that collection of functools.partial object works, and arguments
|
||||
to the wrapped functions are dealt correctly (see #811).
|
||||
"""
|
||||
testdir.makepyfile("""
|
||||
import functools
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def fix1():
|
||||
return 'fix1'
|
||||
|
||||
@pytest.fixture
|
||||
def fix2():
|
||||
return 'fix2'
|
||||
|
||||
def check1(i, fix1):
|
||||
assert i == 2
|
||||
assert fix1 == 'fix1'
|
||||
|
||||
def check2(fix1, i):
|
||||
assert i == 2
|
||||
assert fix1 == 'fix1'
|
||||
|
||||
def check3(fix1, i, fix2):
|
||||
assert i == 2
|
||||
assert fix1 == 'fix1'
|
||||
assert fix2 == 'fix2'
|
||||
|
||||
test_ok_1 = functools.partial(check1, i=2)
|
||||
test_ok_2 = functools.partial(check1, i=2, fix1='fix1')
|
||||
test_ok_3 = functools.partial(check1, 2)
|
||||
test_ok_4 = functools.partial(check2, i=2)
|
||||
test_ok_5 = functools.partial(check3, i=2)
|
||||
test_ok_6 = functools.partial(check3, i=2, fix1='fix1')
|
||||
|
||||
test_fail_1 = functools.partial(check2, 2)
|
||||
test_fail_2 = functools.partial(check3, 2)
|
||||
""")
|
||||
result = testdir.inline_run()
|
||||
result.assertoutcome(passed=6, failed=2)
|
||||
|
||||
@@ -2482,6 +2482,44 @@ class TestShowFixtures:
|
||||
""")
|
||||
|
||||
|
||||
def test_show_fixtures_different_files(self, testdir):
|
||||
"""
|
||||
#833: --fixtures only shows fixtures from first file
|
||||
"""
|
||||
testdir.makepyfile(test_a='''
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def fix_a():
|
||||
"""Fixture A"""
|
||||
pass
|
||||
|
||||
def test_a(fix_a):
|
||||
pass
|
||||
''')
|
||||
testdir.makepyfile(test_b='''
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def fix_b():
|
||||
"""Fixture B"""
|
||||
pass
|
||||
|
||||
def test_b(fix_b):
|
||||
pass
|
||||
''')
|
||||
result = testdir.runpytest("--fixtures")
|
||||
result.stdout.fnmatch_lines("""
|
||||
* fixtures defined from test_a *
|
||||
fix_a
|
||||
Fixture A
|
||||
|
||||
* fixtures defined from test_b *
|
||||
fix_b
|
||||
Fixture B
|
||||
""")
|
||||
|
||||
|
||||
class TestContextManagerFixtureFuncs:
|
||||
def test_simple(self, testdir):
|
||||
testdir.makepyfile("""
|
||||
|
||||
Reference in New Issue
Block a user