Ejemplo n.º 1
0
    def test_plugin_calls_package1_verbose(self):
        wdir = os.path.join(support, 'package1')
        man = RecordingPluginManager()
        conf = Config(plugins=man, stream=sys.stdout)
        t = TestProgram(defaultTest=wdir,
                        config=conf,
                        argv=['test_plugin_calls_package1', '-v'],
                        exit=False)
        print man.calls()
        assert man.called

        self.assertEqual(man.calls(), [
            'loadPlugins', 'addOptions', 'configure', 'begin',
            'prepareTestLoader', 'loadTestsFromNames', 'loadTestsFromName',
            'prepareTestRunner', 'prepareTest', 'setOutputStream',
            'prepareTestResult', 'beforeDirectory', 'wantFile',
            'wantDirectory', 'beforeContext', 'beforeImport', 'afterImport',
            'wantModule', 'wantClass', 'wantFunction', 'makeTest',
            'wantMethod', 'loadTestsFromTestClass', 'loadTestsFromTestCase',
            'loadTestsFromModule', 'startContext', 'beforeTest',
            'prepareTestCase', 'startTest', 'describeTest', 'testName',
            'addSuccess', 'stopTest', 'afterTest', 'stopContext',
            'afterContext', 'loadTestsFromDir', 'afterDirectory', 'report',
            'finalize'
        ])
Ejemplo n.º 2
0
    def test_proxy_calls_plugins(self):
        from nose.case import Test
        res = unittest.TestResult()

        class TC(unittest.TestCase):
            def test_error(self):
                print
                "So long"
                raise TypeError("oops")

            def test_fail(self):
                print
                "Hello"
                self.fail()

            def test(self):
                pass

        plugs = RecordingPluginManager()
        config = Config(plugins=plugs)

        factory = ResultProxyFactory(config=config)

        case_e = Test(TC('test_error'))
        case_f = Test(TC('test_fail'))
        case_t = Test(TC('test'))

        pres_e = factory(res, case_e)
        case_e(pres_e)
        assert 'beforeTest' in plugs.called
        assert 'startTest' in plugs.called
        assert 'addError' in plugs.called
        assert 'stopTest' in plugs.called
        assert 'afterTest' in plugs.called
        plugs.reset()

        pres_f = factory(res, case_f)
        case_f(pres_f)
        assert 'beforeTest' in plugs.called
        assert 'startTest' in plugs.called
        assert 'addFailure' in plugs.called
        assert 'stopTest' in plugs.called
        assert 'afterTest' in plugs.called
        plugs.reset()

        pres_t = factory(res, case_t)
        case_t(pres_t)
        assert 'beforeTest' in plugs.called
        assert 'startTest' in plugs.called
        assert 'addSuccess' in plugs.called
        assert 'stopTest' in plugs.called
        assert 'afterTest' in plugs.called
        plugs.reset()