def test_plugin_generative_method_errors_not_hidden(self):
        import nose.failure

        pm = PluginManager(plugins=[Plug3(), Plug4()])
        loaded = list(pm.loadTestsFromModule("whatever"))
        self.assertEqual(len(loaded), 2)
        for test in loaded:
            assert isinstance(test, nose.failure.Failure), "%s is not a failure" % test
Exemple #2
0
 def test_plugin_generative_method_errors_not_hidden(self):
     import nose.failure
     pm = PluginManager(plugins=[Plug3(), Plug4()])
     loaded = list(pm.loadTestsFromModule('whatever'))
     self.assertEqual(len(loaded), 2)
     for test in loaded:
         assert isinstance(test, nose.failure.Failure), \
                "%s is not a failure" % test
    def test_proxy_to_plugins(self):
        man = PluginManager(plugins=[Plug(), Plug2()])

        # simple proxy: first plugin to return a value wins
        self.assertEqual(man.addError(None, None), True)

        # multiple proxy: all plugins that return values get to run
        all = []
        for res in man.loadTestsFromFile("foo"):
            print(res)
            all.append(res)
        self.assertEqual(len(all), 2)
Exemple #4
0
    def test_proxy_to_plugins(self):
        man = PluginManager(plugins=[Plug(), Plug2()])

        # simple proxy: first plugin to return a value wins
        self.assertEqual(man.addError(None, None), True)

        # multiple proxy: all plugins that return values get to run
        all = []
        for res in man.loadTestsFromFile('foo'):
            print res
            all.append(res)
        self.assertEqual(len(all), 2)
Exemple #5
0
    def setUp(self):
        self.config = Config()
        self.config.plugins = PluginManager()
        self.config.plugins.addPlugin(Failer())

        self.argv = []
        self.argv.append("lode_runner")  # 0 is always should be program name
Exemple #6
0
 def test_iter(self):
     expect = [Plug(), Plug2()]
     man = PluginManager(plugins=expect)
     for plug in man:
         self.assertEqual(plug, expect.pop(0))
     assert not expect, \
            "Some plugins were not found by iteration: %s" % expect
Exemple #7
0
    def test_describe_test_called(self):
        class Descrip(Plugin):
            counter = 0
            enabled = True

            def describeTest(self, test):
                return "test #%s" % id(test)

            def testName(self, test):
                self.counter += 1
                return "(%s) test" % self.counter

        class TC(unittest.TestCase):
            def test_one(self):
                pass

            def test_two(self):
                pass

        config = Config(plugins=PluginManager(plugins=[Descrip()]))

        c1 = case.Test(TC('test_one'), config=config)
        c2 = case.Test(TC('test_two'), config=config)

        self.assertEqual(str(c1), '(1) test')
        self.assertEqual(str(c2), '(2) test')
        assert c1.shortDescription().startswith('test #'), \
            "Unexpected shortDescription: %s" % c1.shortDescription()
        assert c2.shortDescription().startswith('test #'), \
            "Unexpected shortDescription: %s" % c2.shortDescription()
 def setUp(self):
     self.addCleanup(self.cleanup)
     self.config = Config()
     self.config.plugins = PluginManager()
     self.config.plugins.addPlugin(Dataprovider())
     self.argv = []
     # 0 is always should be program name
     self.argv.append("lode_runner")
     self.config.configure(self.argv)
Exemple #9
0
        class DummyNose(Command):
            description = "Dummy"
            manager = PluginManager()
            manager.plugins = [RandomlyPlugin()]
            __config = Config(files=user_config_files(), plugins=manager)
            __parser = __config.getParser()
            user_options = nose.commands.get_user_options(__parser)

            def initialize_options(self):
                pass

            def finalize_options(self):
                pass

            def run(self):
                pass
Exemple #10
0
 def setUp(self):
     self.idfile = os.path.abspath(
         os.path.join(os.path.dirname(__file__), self.idfile_location))
     parser = optparse.OptionParser()
     argv = [
         # 0 is always program
         "lode_runner",
         "--failed",
         "--with-id",
         "--id-file=%s" % self.idfile
     ]
     self.x = TestId()
     self.x.add_options(parser, env={})
     (options, args) = parser.parse_args(argv)
     self.config = Config()
     self.x.configure(options, self.config)
     self.config.plugins = PluginManager()
     self.config.plugins.addPlugin(Dataprovider())
     self.config.plugins.addPlugin(TestId())
     self.config.configure(argv)
 def setUp(self):
     self.config = Config()
     self.config.plugins = PluginManager()
     self.config.plugins.addPlugin(Dataprovider())
     self.config.configure(self.argv)
Exemple #12
0
 def test_plugin_override(self):
     pm = PluginManager(plugins=[Plug2(), BetterPlug2()])
     self.assertEqual(len(pm.plugins), 1)
     assert isinstance(pm.plugins[0], BetterPlug2)