merge in current default

This commit is contained in:
holger krekel
2014-03-27 13:57:54 +01:00
22 changed files with 295 additions and 153 deletions

View File

@@ -277,7 +277,7 @@ class TestFunction:
assert hasattr(modcol.obj, 'test_func')
def test_function_as_object_instance_ignored(self, testdir):
item = testdir.makepyfile("""
testdir.makepyfile("""
class A:
def __call__(self, tmpdir):
0/0

View File

@@ -124,12 +124,16 @@ class TestMockDecoration:
def test_hello(self, abspath):
os.path.abspath("hello")
abspath.assert_any_call("hello")
def mock_basename(path):
return "mock_basename"
@mock.patch("os.path.abspath")
@mock.patch("os.path.normpath")
@mock.patch("os.path.basename", new=mock_basename)
def test_someting(normpath, abspath, tmpdir):
abspath.return_value = "this"
os.path.normpath(os.path.abspath("hello"))
normpath.assert_any_call("this")
assert os.path.basename("123") == "mock_basename"
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=2)

View File

@@ -533,6 +533,24 @@ def test_capture_conftest_runtest_setup(testdir):
assert 'hello19' not in result.stdout.str()
@pytest.mark.xfail(reason='demonstrate #412')
def test_capture_badoutput(testdir):
testdir.makepyfile("""
import os
def test_func():
omg = bytearray([1,129,1])
os.write(1, omg)
assert 0
""")
result = testdir.runpytest('--cap=fd')
#this fails on python3 - fnmatch first for debugging
result.stdout.fnmatch_lines([
'*1 failed*',
])
assert result.ret == 1
def test_capture_early_option_parsing(testdir):
testdir.makeconftest("""
def pytest_runtest_setup():

View File

@@ -330,12 +330,26 @@ def test_setup_teardown_linking_issue265(testdir):
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1, skipped=1)
def test_SkipTest_during_collection(testdir):
testdir.makepyfile("""
p = testdir.makepyfile("""
import nose
raise nose.SkipTest("during collection")
def test_failing():
assert False
""")
result = testdir.runpytest(p)
outcome = result.parseoutcomes()
outcome.pop('seconds')
assert outcome == dict(skipped=1)
def test_SkipTest_in_test(testdir):
testdir.makepyfile("""
import nose
def test_skipping():
raise nose.SkipTest("in test")
""")
reprec = testdir.inline_run()
reprec.assertoutcome(skipped=1)