awips2/pythonPackages/nose/functional_tests/test_cases.py
root 8e80217e59 Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: a02aeb236c [formerly 9f19e3f712] [formerly 06a8b51d6d [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]
Former-commit-id: 06a8b51d6d
Former-commit-id: 3360eb6c5f
2012-01-06 08:55:05 -06:00

38 lines
1.2 KiB
Python
Executable file

import unittest
from nose.config import Config
from nose import case
from nose.plugins import Plugin, PluginManager
class TestTestCasePluginCalls(unittest.TestCase):
def test_describe_test_called(self):
class Descrip(Plugin):
counter = 0
enabled = True
def describeTest(self, test):
return "test #%s" % id(test)
def testName(self, test):
self.counter += 1
return "(%s) test" % self.counter
class TC(unittest.TestCase):
def test_one(self):
pass
def test_two(self):
pass
config = Config(plugins=PluginManager(plugins=[Descrip()]))
c1 = case.Test(TC('test_one'), config=config)
c2 = case.Test(TC('test_two'), config=config)
self.assertEqual(str(c1), '(1) test')
self.assertEqual(str(c2), '(2) test')
assert c1.shortDescription().startswith('test #'), \
"Unexpected shortDescription: %s" % c1.shortDescription()
assert c2.shortDescription().startswith('test #'), \
"Unexpected shortDescription: %s" % c2.shortDescription()
if __name__ == '__main__':
unittest.main()