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

« back to all changes in this revision

Viewing changes to functional_tests/test_load_tests_from_test_case.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
Tests that plugins can override loadTestsFromTestCase
 
3
"""
 
4
import os
 
5
import unittest
 
6
from nose import loader
 
7
from nose.plugins import PluginTester
 
8
from nose.plugins.base import Plugin
 
9
 
 
10
 
 
11
support = os.path.join(os.path.dirname(__file__), 'support')
 
12
 
 
13
 
 
14
class NoFixturePlug(Plugin):
 
15
    enabled = True
 
16
 
 
17
    def options(self, parser, env):
 
18
        print "options"        
 
19
        pass
 
20
    
 
21
    def configure(self, options, conf):
 
22
        print "configure"
 
23
        pass
 
24
 
 
25
    def loadTestsFromTestCase(self, testCaseClass):
 
26
        print "Called!"
 
27
        class Derived(testCaseClass):
 
28
            def setUp(self):
 
29
                pass
 
30
            def tearDown(self):
 
31
                pass
 
32
        # must use nose loader here because the default loader in 2.3
 
33
        # won't load tests from base classes
 
34
        l = loader.TestLoader()
 
35
        return l.loadTestsFromTestCase(Derived)
 
36
 
 
37
 
 
38
class TestLoadTestsFromTestCaseHook(PluginTester, unittest.TestCase):
 
39
 
 
40
    activate = '-v'
 
41
    args = []
 
42
    plugins = [NoFixturePlug()]
 
43
    suitepath = os.path.join(support, 'ltftc')
 
44
 
 
45
    def runTest(self):
 
46
        expect = [
 
47
            'test_value (%s.Derived) ... ERROR' % __name__,
 
48
            'test_value (tests.Tests) ... ok']
 
49
        print str(self.output)
 
50
        for line in self.output:
 
51
            if expect:
 
52
                self.assertEqual(line.strip(), expect.pop(0))
 
53
                
 
54
 
 
55
if __name__ == '__main__':
 
56
    unittest.main()