import mock from nose.tools import assert_true import math class ClassUnderTest(): def function_under_test(): return @mock.patch('math.pi', mock.MagicMock()) # delete to get expected.out class Tests(): """ $ nosetests silentfail.py """ def test_generator_never_run(arg): """ this test is never executed. nose reports it as "OK" """ assert_true(True) yield def test_generator_should_fail(arg): """ this test is never executed. nose reports it as "OK" """ assert_true(False) yield def test_nongenerator_is_run(arg): """ this test is executed; it passes """ assert_true(True) def test_nongenerator_should_fail(arg): """ this test is executed and fails, just as expected """ assert_true(False)