PageRenderTime 14ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/unit_tests/test_selector_plugins.py

https://bitbucket.org/jpellerin/nose/
Python | 30 lines | 23 code | 7 blank | 0 comment | 4 complexity | 6e763f4d125acc20e3269ffc14fa7b78 MD5 | raw file
 1import unittest
 2import nose.selector
 3from nose.config import Config
 4from nose.plugins.base import Plugin
 5from nose.plugins.manager import PluginManager
 6
 7class TestSelectorPlugins(unittest.TestCase):
 8
 9    def test_rejection(self):
10        class EvilSelector(Plugin):
11            def wantFile(self, filename, package=None):
12                if 'good' in filename:
13                    return False
14                return None
15
16        c = Config(plugins=PluginManager(plugins=[EvilSelector()]))
17        s = nose.selector.Selector(c)
18        s2 = nose.selector.Selector(Config())
19        
20        assert s.wantFile('test_neutral.py')
21        assert s2.wantFile('test_neutral.py')
22        
23        assert s.wantFile('test_evil.py')
24        assert s2.wantFile('test_evil.py')
25        
26        assert not s.wantFile('test_good.py')
27        assert s2.wantFile('test_good.py')
28        
29if __name__ == '__main__':
30    unittest.main()