Imported Upstream version 1.1.2
[platform/upstream/python-nose.git] / functional_tests / test_skip_pdb_interaction.py
1 import unittest
2 from nose import case
3 from nose.config import Config
4 from nose.plugins import debug
5 from nose.plugins.manager import PluginManager
6 from nose.plugins.skip import Skip, SkipTest
7 from nose.proxy import ResultProxyFactory
8
9
10 class StubPdb:
11     called = False
12     def post_mortem(self, tb):
13         self.called = True
14
15 class 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
48 if __name__ == '__main__':
49     unittest.main()