/functional_tests/test_skip_pdb_interaction.py

https://bitbucket.org/jpellerin/nose/ · Python · 49 lines · 35 code · 11 blank · 3 comment · 1 complexity · f275d8d16fd79ac03ddaa63eb9f59923 MD5 · raw file

  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. class StubPdb:
  9. called = False
  10. def post_mortem(self, tb):
  11. self.called = True
  12. class TestSkipPdbInteraction(unittest.TestCase):
  13. """Tests interaction between skip plugin and pdb plugin -- pdb should
  14. not fire on a skip error
  15. """
  16. def setUp(self):
  17. self._pdb = debug.pdb
  18. debug.pdb = StubPdb()
  19. def tearDown(self):
  20. debug.pdb = self._pdb
  21. def test_skip_prevents_pdb_call(self):
  22. class TC(unittest.TestCase):
  23. def test(self):
  24. raise SkipTest('not me')
  25. skip = Skip()
  26. skip.enabled = True
  27. p = debug.Pdb()
  28. p.enabled = True
  29. p.enabled_for_errors = True
  30. res = unittest.TestResult()
  31. conf = Config(plugins=PluginManager(plugins=[skip, p]))
  32. rpf = ResultProxyFactory(conf)
  33. test = case.Test(TC('test'), resultProxy=rpf)
  34. test(res)
  35. assert not res.errors, "Skip was recorded as error %s" % res.errors
  36. assert not debug.pdb.called, "pdb was called"
  37. if __name__ == '__main__':
  38. unittest.main()