Imported Upstream version 1.1.2
[platform/upstream/python-nose.git] / functional_tests / test_collector.py
1 import os
2 import sys
3 import unittest
4 import warnings
5 from cStringIO import StringIO
6 from nose.result import _TextTestResult
7 here = os.path.dirname(__file__)
8 support = os.path.join(here, 'support')
9
10
11 class TestRunner(unittest.TextTestRunner):
12     def _makeResult(self):
13         self.result = _TextTestResult(
14             self.stream, self.descriptions, self.verbosity)
15         return self.result
16
17
18 class TestNoseTestCollector(unittest.TestCase):
19
20     def test_skip_works_with_collector(self):
21         verbosity = 2
22         stream = StringIO()
23         runner = TestRunner(stream=stream, verbosity=verbosity)
24         pwd = os.getcwd()
25
26         # we don't need to see our own warnings
27         warnings.filterwarnings(action='ignore',
28                                 category=RuntimeWarning,
29                                 module='nose.plugins.manager')
30
31         try:
32             os.chdir(os.path.join(support, 'issue038'))
33             unittest.TestProgram(
34                 None, None,
35                 argv=['test_collector', '-v', 'nose.collector'],
36                 testRunner=runner)
37         except SystemExit:
38             pass
39         os.chdir(pwd)
40         out = stream.getvalue()
41         assert runner.result.wasSuccessful()
42         assert 'SKIP' in out, "SKIP not found in %s" % out
43
44
45 if __name__ == '__main__':
46     unittest.main()