Ejemplo n.º 1
0
    def test_is_selected_SyntaxError(self):
        # means we have SyntaxError in this file
        name = None
        plugin = NoseSelectPlugin()

        plugin.selected_tests = ['configure']
        self.assertTrue(plugin._is_selected(DummyTest(name, exc_class=SyntaxError)))
Ejemplo n.º 2
0
 def test_is_selected_negative(self):
     to = build_tst_object('func', 
                       module='noseselecttests.tests', 
                       cls='NoseSelectPluginTest', 
                       func= 'test_configure_complex')
     plugin = NoseSelectPlugin()
     plugin.add_criterion('foobar')
     self.assertFalse(plugin._is_selected(to))
Ejemplo n.º 3
0
 def test_is_selected_selects_method_unbound(self):
     to = build_tst_object('class', 
                       module='noseselecttests.tests', 
                       cls='NoseSelectPluginTest', 
                       func= 'test_configure_complex')
     plugin = NoseSelectPlugin()
     plugin.add_criterion('NoseSelectPluginTest.test_configure_complex')
     self.assertTrue(plugin._is_selected(to.test_configure_complex))
Ejemplo n.º 4
0
 def test_is_selected_wildcard(self):
     to = build_tst_object('func', 
                       module='noseselecttests.tests', 
                       cls='NoseSelectPluginTest', 
                       func= 'test_configure_complex')
     plugin = NoseSelectPlugin()
     plugin.add_criterion('configure*complex')
     self.assertTrue(plugin._is_selected(to))
Ejemplo n.º 5
0
 def test_is_selected_case_insensitive(self):
     to = build_tst_object('func', 
                       module='noseselecttests.tests', 
                       cls='NoseSelectPluginTest', 
                       func= 'test_configure_complex')
     plugin = NoseSelectPlugin()
     plugin.add_criterion('ConfigurE_CompLex')
     self.assertTrue(plugin._is_selected(to))
Ejemplo n.º 6
0
    def test_options(self):
        plugin = NoseSelectPlugin()
        parser = DummyOptParser()
        plugin.add_options(parser)

        self.assertEqual(parser.opts, [
            (('-t', '--select-tests'),
             {'action': 'append',
              'default': [],
              'dest': 'selected_tests',
              'help': 'Run only tests that match case-insensitive to this parameter',
              'metavar': 'SELECT'})
        ])
Ejemplo n.º 7
0
class NoseSelectPluginTesterPositiveTest(PluginTester, unittest.TestCase):
    activate = ''
    plugins = [NoseSelectPlugin()]
    suitepath = base_dir
    args = ['-v', '--exe', '--select-tests=is_selected']

    def test_selection_is_correct(self):
        assert all(x in self.output
                   for x in ['tests.test_module.TestClassWithSetupAndSelectedMethod_but_Class_that_is_not_selected',
                             'tests.test_module.test_bare_function_that_is_selected',
                             'tests.test_module_with_not_selected_class.test_bare_function_that_is_selected',])
Ejemplo n.º 8
0
class NoseSelectPluginTesterIvertedTest(PluginTester, unittest.TestCase):
    activate = ''
    plugins = [NoseSelectPlugin()]
    suitepath = base_dir
    args = ['-v', '--exe', '--select-tests=is_not_selected']

    def test_selection_is_correctly_inverted(self):
        assert all(x in self.output
                   for x in ['FAIL: tests.test_module_with_not_selected_class.test_bare_function_that_is_not_selected',
                             "ERROR: test suite for <class 'tests.test_module_with_not_selected_class.TestClassWithSetupNotSelected_that_is_not_selected'>",
                             'test_method_that_is_not_selected (tests.test_module.TestClassWithSetupAndSelectedMethod_but_Class_that_is_not_selected) ... ok',
                             'test_method_that_is_selected (tests.test_module.TestClassWithSetupAndSelectedMethod_but_Class_that_is_not_selected) ... ok',
        ])
Ejemplo n.º 9
0
    def test_configure_empty_string(self):
        plugin = NoseSelectPlugin()
        plugin.configure(self._get_options(['']), self._get_config())

        self.assertEqual(plugin.selection_criteria, [])
        self.assertFalse(plugin.enabled)
Ejemplo n.º 10
0
 def test_is_selected_selects_method_bound(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('DummyTest.test_foo')
     self.assertTrue(plugin._is_selected(DummyTest().test_foo))
Ejemplo n.º 11
0
 def test_is_selected_selects_class(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('DummyTest')
     self.assertTrue(plugin._is_selected(DummyTest))
Ejemplo n.º 12
0
    def test_configure_empty_string(self):
        plugin = NoseSelectPlugin()
        plugin.configure(self._get_options(['']), None)

        self.assertEqual(plugin.selected_tests, [])
        self.assertFalse(plugin.enabled)
Ejemplo n.º 13
0
 def test_is_selected_case_insensitive(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('fObJ')
     self.assertTrue(plugin._is_selected(fobj))
Ejemplo n.º 14
0
 def test_is_selected_case_insensitive(self):
     name = "noseselecttests.tests.NoseSelectPluginTest.test_configure_complex"
     plugin = NoseSelectPlugin()
     plugin.selected_tests = ['noseselectplugintest']
     self.assertTrue(plugin._is_selected(DummyTest(name)))
Ejemplo n.º 15
0
 def test_prepareTestCase_exclude(self):
     plugin = NoseSelectPlugin()
     plugin._is_selected = lambda x: False
     self.assertEqual(plugin.prepareTestCase(DummyTest('foobar'))('test'), None)
Ejemplo n.º 16
0
    def test_is_selected_simple(self):
        name = "noseselecttests.tests.NoseSelectPluginTest.test_configure_complex"
        plugin = NoseSelectPlugin()

        plugin.selected_tests = ['configure']
        self.assertTrue(plugin._is_selected(DummyTest(name)))
Ejemplo n.º 17
0
    def test_configure_or(self):
        plugin = NoseSelectPlugin()
        plugin.configure(self._get_options(['foobar', 'foo']), None)

        self.assertEqual(plugin.selected_tests, ['foobar', 'foo'])
        self.assertTrue(plugin.enabled)
Ejemplo n.º 18
0
    def test_configure_or(self):
        plugin = NoseSelectPlugin()
        plugin.configure(self._get_options(['foobar', 'FOO']), self._get_config())

        self.assertEqual(plugin.selection_criteria, ['*foobar*', '*foo*'])
        self.assertTrue(plugin.enabled)
Ejemplo n.º 19
0
    def test_is_selected_function(self):
        plugin = NoseSelectPlugin()

        plugin.add_criterion('fobj')
        self.assertTrue(plugin._is_selected(fobj))
Ejemplo n.º 20
0
 def test_is_selected_false(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('foobar')
     self.assertFalse(plugin._is_selected(fobj))
Ejemplo n.º 21
0
 def test_is_selected_wildcard(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('configure*complex')
     self.assertTrue(plugin._is_selected(configure_complex))
Ejemplo n.º 22
0
 def test_prepareTestCase_select(self):
     plugin = NoseSelectPlugin()
     plugin._is_selected = lambda x: True
     self.assertEqual(plugin.prepareTestCase(DummyTest('foobar')), None)
Ejemplo n.º 23
0
 def test_is_selected_selects_module(self):
     plugin = NoseSelectPlugin()
     plugin.add_criterion('noseselecttests.tests')
     self.assertTrue(plugin._is_selected(DummyTest))
Ejemplo n.º 24
0
 def test_is_selected_negative(self):
     name = "noseselecttests.tests.NoseSelectPluginTest.test_configure_complex"
     plugin = NoseSelectPlugin()
     plugin.selected_tests = ['foobar']
     self.assertFalse(plugin._is_selected(DummyTest(name)))