summaryrefslogtreecommitdiff
path: root/functional_tests/test_skip_pdb_interaction.py
blob: 20c5f789108667ce8003a6548293898906f9fd7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import unittest
from nose import case
from nose.config import Config
from nose.plugins import debug
from nose.plugins.manager import PluginManager
from nose.plugins.skip import Skip, SkipTest
from nose.proxy import ResultProxyFactory


class StubPdb:
    called = False
    def post_mortem(self, tb):
        self.called = True

class TestSkipPdbInteraction(unittest.TestCase):
    """Tests interaction between skip plugin and pdb plugin -- pdb should
    not fire on a skip error
    """
    def setUp(self):
        self._pdb = debug.pdb
        debug.pdb = StubPdb()

    def tearDown(self):
        debug.pdb = self._pdb
    
    def test_skip_prevents_pdb_call(self):

        class TC(unittest.TestCase):
            def test(self):
                raise SkipTest('not me')

        skip = Skip()
        skip.enabled = True
        p = debug.Pdb()
        p.enabled = True
        p.enabled_for_errors = True
        res = unittest.TestResult()
        conf = Config(plugins=PluginManager(plugins=[skip, p]))        
        rpf = ResultProxyFactory(conf)
        test = case.Test(TC('test'), resultProxy=rpf)
        test(res)

        assert not res.errors, "Skip was recorded as error %s" % res.errors
        assert not debug.pdb.called, "pdb was called"

        

if __name__ == '__main__':
    unittest.main()