Example #1
0
    def test_collect_one_case_method(self):

        class NewFakeTestCase(FakeTestCase):

            def test_(self):
                pass

        expect_case_name = NewFakeTestCase.__name__
        expect_suite_name = 'test_suite_name.test'

        argv = [
            'test',
            '{}:{}'.format(expect_suite_name, expect_case_name),
            '--with-app-configure'
        ]

        expect_suite = Suite(expect_suite_name)
        expect_suite.register(NewFakeTestCase)
        expect_suite.register(NoseAppTestCase)

        suites = [Suite(__name__) for _ in xrange(9)] + [expect_suite]

        app = NoseApp()
        app.register_suites(suites)

        program = TestProgram(
            app=app,
            argv=argv,
            plugins=[AppConfigurePlugin()],
        )

        collector = CollectSuite(program.data)
        result = collector.make_result()

        self.assertIsInstance(result, ContextSuite)

        result = [s for s in result]

        self.assertEqual(len(result), 1)

        for suite in result:
            self.assertIsInstance(suite, ContextSuite)

            for test in suite:
                self.assertIsInstance(test.test, FakeTestCase)
Example #2
0
    def runTest(self):
        self.counter = 0

        suite = Suite(__name__)
        suite.register(FakeTestCase)

        @suite.add_handler
        def handler(test):
            self.counter += 1
            self.assertIsInstance(test, FakeTestCase)

        app = NoseApp()
        app.register_suite(suite)

        try:
            app.run()
        except SystemExit:
            pass

        self.assertEqual(self.counter, 1)
Example #3
0
    def test_build_suite(self):
        from nose.case import Test
        from noseapp.suite.bases.simple import BaseSuite

        class MockOptions:
            app_processes = 0
            gevent_greenlets = 0
            thread_pool = 0
            gevent_pool = 0

        suite = Suite(__name__)
        suite.register(FakeTestCase)

        program = TestProgram(app=NoseApp(), argv=['test'], plugins=[AppConfigurePlugin()],)
        test = suite(program.data)

        self.assertIsInstance(test, BaseSuite)

        test = [t for t in test]

        self.assertEqual(len(test), 1)
        self.assertIsInstance(test[0], Test)
Example #4
0
    def test_register_test_case(self):
        suite = Suite(__name__)
        suite.register(NoseAppTestCase)

        self.assertEqual(len(suite.get_map()), 1)
Example #5
0
    def runTest(self):
        suite = Suite(__name__)
        func = lambda test: 1
        suite.add_handler(func)

        self.assertIn(func, suite.handlers)