PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/functional_tests/test_plugin_api.py

https://bitbucket.org/jpellerin/nose/
Python | 45 lines | 34 code | 7 blank | 4 comment | 5 complexity | 27e30a232b1c76c8bc4033fceb1f79da MD5 | raw file
 1"""
 2Functional tests of plugin apis -- individual plugintester runs for
 3test plugins that implement one or more hooks for testing.
 4"""
 5import os
 6import sys
 7import unittest
 8from nose.plugins import Plugin, PluginTester
 9
10support = os.path.join(os.path.dirname(__file__), 'support')
11
12class AllFail(Plugin):
13    def prepareTestCase(self, test):
14        self.test = test
15        return self.fail
16
17    def fail(self, result):
18        result.startTest(self.test)
19        try:
20            try:
21                assert False, "I want to fail!"
22            except:
23                result.addFailure(self.test, sys.exc_info())
24        finally:
25            result.stopTest(self.test)
26
27class TestPrepareTestCase_MakeAllFail(PluginTester, unittest.TestCase):
28    activate = '--with-allfail'
29    args = ['-v']
30    plugins = [AllFail()]
31    suitepath = os.path.join(support, 'package2')
32    
33    def runTest(self):
34        print "x" * 70
35        print str(self.output)
36        print "x" * 70
37        for line in self.output:
38            if line.startswith('test_pak'):
39                assert line.strip().endswith('FAIL'), \
40                       "Expected failure but got: %s" % line.strip()
41        assert not str(self.output).strip().endswith('OK')
42
43
44if __name__ == '__main__':
45    unittest.main()