~ubuntu-branches/debian/squeeze/nose/squeeze

« back to all changes in this revision

Viewing changes to functional_tests/test_plugin_api.py

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Marek, Torsten Marek, Gustavo Noronha Silva
  • Date: 2008-06-12 13:39:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080612133943-2q7syp67fwl4on13
Tags: 0.10.3-1

[Torsten Marek]
* New upstream release (Closes: #461994)
* debian/control
  - bump standards version to 3.8.0, no changes necessary
  - add suggestions for python-coverage (Closes: #457053)
  - change dependency on python-setuptools into 
    python-pkg-resources (Closes: #468719)
  - added myself to uploaders

[Gustavo Noronha Silva]
* debian/control:
  - remove -1 from build-dep on setuptools

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
Functional tests of plugin apis -- individual plugintester runs for
 
3
test plugins that implement one or more hooks for testing.
 
4
"""
 
5
import os
 
6
import sys
 
7
import unittest
 
8
from nose.plugins import Plugin, PluginTester
 
9
 
 
10
support = os.path.join(os.path.dirname(__file__), 'support')
 
11
 
 
12
class 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
 
 
27
class 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
 
 
44
if __name__ == '__main__':
 
45
    unittest.main()