/functional_tests/test_skip_pdb_interaction.py
Python | 49 lines | 35 code | 11 blank | 3 comment | 3 complexity | f275d8d16fd79ac03ddaa63eb9f59923 MD5 | raw file
1import unittest 2from nose import case 3from nose.config import Config 4from nose.plugins import debug 5from nose.plugins.manager import PluginManager 6from nose.plugins.skip import Skip, SkipTest 7from nose.proxy import ResultProxyFactory 8 9 10class StubPdb: 11 called = False 12 def post_mortem(self, tb): 13 self.called = True 14 15class TestSkipPdbInteraction(unittest.TestCase): 16 """Tests interaction between skip plugin and pdb plugin -- pdb should 17 not fire on a skip error 18 """ 19 def setUp(self): 20 self._pdb = debug.pdb 21 debug.pdb = StubPdb() 22 23 def tearDown(self): 24 debug.pdb = self._pdb 25 26 def test_skip_prevents_pdb_call(self): 27 28 class TC(unittest.TestCase): 29 def test(self): 30 raise SkipTest('not me') 31 32 skip = Skip() 33 skip.enabled = True 34 p = debug.Pdb() 35 p.enabled = True 36 p.enabled_for_errors = True 37 res = unittest.TestResult() 38 conf = Config(plugins=PluginManager(plugins=[skip, p])) 39 rpf = ResultProxyFactory(conf) 40 test = case.Test(TC('test'), resultProxy=rpf) 41 test(res) 42 43 assert not res.errors, "Skip was recorded as error %s" % res.errors 44 assert not debug.pdb.called, "pdb was called" 45 46 47 48if __name__ == '__main__': 49 unittest.main()