Exemplo n.º 1
0
    def run(self):
        # Installing required packages, running egg_info and build_ext are
        # part of normal operation for setuptools.command.test.test. Motor
        # has no extensions so build_ext is a no-op.
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        self.run_command('egg_info')
        build_ext_cmd = self.reinitialize_command('build_ext')
        build_ext_cmd.inplace = 1
        self.run_command('build_ext')

        # Construct a MotorTestRunner directly from the unittest imported from
        # test (this will be unittest2 under Python 2.6), which creates a
        # TestResult that supports the 'addSkip' method. setuptools will by
        # default create a TextTestRunner that uses the old TestResult class,
        # resulting in DeprecationWarnings instead of skipping tests under 2.6.
        from test import (unittest, MotorTestLoader, MotorTestRunner,
                          test_environment as testenv)

        loader = MotorTestLoader()
        loader.avoid('high_availability', 'Runs separately')

        if not (testenv.HAVE_ASYNCIO or testenv.HAVE_TORNADO):
            raise ImportError("No tornado nor asyncio")
        elif not testenv.HAVE_TORNADO:
            loader.avoid('tornado_tests', reason='no tornado')
        elif not testenv.HAVE_ASYNCIO:
            loader.avoid('asyncio_tests', reason='no asyncio')

        if self.test_suite is None:
            suite = loader.discover(self.test_module)
        else:
            suite = loader.loadTestsFromName(self.test_suite)

        runner_kwargs = dict(
            verbosity=2,
            failfast=self.failfast,
            tornado_warnings=self.tornado_warnings)

        if sys.version_info[:3] >= (3, 2) and unittest.__name__ != 'unittest2':
            # 'warnings' argument added to TextTestRunner in Python 3.2.
            runner_kwargs['warnings'] = 'default'

        runner = MotorTestRunner(**runner_kwargs)
        result = runner.run(suite)
        sys.exit(not result.wasSuccessful())
Exemplo n.º 2
0
    def run(self):
        # Installing required packages, running egg_info and build_ext are
        # part of normal operation for setuptools.command.test.test. Motor
        # has no extensions so build_ext is a no-op.
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        if self.xunit_output:
            self.distribution.fetch_build_eggs(
                ["unittest-xml-reporting>=1.14.0,<2.0.0a0"])
        self.run_command('egg_info')
        build_ext_cmd = self.reinitialize_command('build_ext')
        build_ext_cmd.inplace = 1
        self.run_command('build_ext')

        from test import (env,
                          suppress_tornado_warnings,
                          MotorTestLoader,
                          test_environment as testenv)

        loader = MotorTestLoader()
        loader.avoid('high_availability', reason='Runs separately')

        if not (testenv.HAVE_ASYNCIO or testenv.HAVE_TORNADO):
            raise ImportError("No tornado nor asyncio")
        elif not testenv.HAVE_TORNADO:
            loader.avoid('tornado_tests', reason='no tornado')
        elif not testenv.HAVE_ASYNCIO:
            loader.avoid('asyncio_tests', reason='no asyncio')

        if not testenv.HAVE_AIOHTTP:
            loader.avoid('asyncio_tests.test_aiohttp_gridfs',
                         reason='no aiohttp')

        if sys.version_info[:2] < (3, 5):
            loader.avoid('asyncio_tests.test_asyncio_await',
                         'asyncio_tests.test_asyncio_change_stream',
                         'asyncio_tests.test_examples',
                         reason='python < 3.5')

        # Decide if we can run async / await tests with Tornado.
        test_motor_await = 'tornado_tests.test_motor_await'
        if not testenv.HAVE_TORNADO:
            loader.avoid(test_motor_await, reason='no tornado')
        elif sys.version_info[:2] < (3, 5):
            loader.avoid(test_motor_await, reason='python < 3.5')
            loader.avoid('tornado_tests.test_motor_change_stream',
                         reason='python < 3.5')

        if self.test_suite is None:
            suite = loader.discover(self.test_module)
        else:
            suite = loader.loadTestsFromName(self.test_suite)

        runner_kwargs = dict(verbosity=2, failfast=self.failfast)

        if self.xunit_output:
            runner_kwargs['output'] = self.xunit_output
            from xmlrunner import XMLTestRunner
            runner_class = XMLTestRunner
        else:
            import unittest
            runner_class = unittest.TextTestRunner

        runner = runner_class(**runner_kwargs)
        env.setup()
        if not self.tornado_warnings:
            suppress_tornado_warnings()

        result = runner.run(suite)
        sys.exit(not result.wasSuccessful())
Exemplo n.º 3
0
    def run(self):
        # Installing required packages, running egg_info and build_ext are
        # part of normal operation for setuptools.command.test.test. Motor
        # has no extensions so build_ext is a no-op.
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        if self.xunit_output:
            self.distribution.fetch_build_eggs(
                ["unittest-xml-reporting>=1.14.0,<2.0.0a0"])
        self.run_command('egg_info')
        build_ext_cmd = self.reinitialize_command('build_ext')
        build_ext_cmd.inplace = 1
        self.run_command('build_ext')

        # Construct a test runner directly from the unittest imported from
        # test (this will be unittest2 under Python 2.6), which creates a
        # TestResult that supports the 'addSkip' method. setuptools will by
        # default create a TextTestRunner that uses the old TestResult class,
        # resulting in DeprecationWarnings instead of skipping tests under 2.6.
        from test import (env, suppress_tornado_warnings, unittest,
                          MotorTestLoader, test_environment as testenv)

        loader = MotorTestLoader()
        loader.avoid('high_availability', 'Runs separately')

        if not (testenv.HAVE_ASYNCIO or testenv.HAVE_TORNADO):
            raise ImportError("No tornado nor asyncio")
        elif not testenv.HAVE_TORNADO:
            loader.avoid('tornado_tests', reason='no tornado')
        elif not testenv.HAVE_ASYNCIO:
            loader.avoid('asyncio_tests', reason='no asyncio')

        if not testenv.HAVE_AIOHTTP:
            loader.avoid('asyncio_tests.test_aiohttp_gridfs',
                         reason='no aiohttp')

        if sys.version_info[:2] < (3, 5):
            loader.avoid('asyncio_tests.test_asyncio_await',
                         reason='python < 3.5')

        # Decide if we can run async / await tests with Tornado.
        test_motor_await = 'tornado_tests.test_motor_await'
        if not testenv.HAVE_TORNADO:
            loader.avoid(test_motor_await, reason='no tornado')
        # We need Tornado after this patch to wrap "async def" with gen_test:
        # https://github.com/tornadoweb/tornado/pull/1550
        elif not testenv.TORNADO_VERSION[:2] > (4, 2):
            loader.avoid(test_motor_await, reason='tornado < 4.3')
        elif sys.version_info[:2] < (3, 5):
            loader.avoid(test_motor_await, reason='python < 3.5')

        if self.test_suite is None:
            suite = loader.discover(self.test_module)
        else:
            suite = loader.loadTestsFromName(self.test_suite)

        runner_kwargs = dict(verbosity=2, failfast=self.failfast)

        if self.xunit_output:
            runner_kwargs['output'] = self.xunit_output
            from xmlrunner import XMLTestRunner
            runner_class = XMLTestRunner
        else:
            runner_class = unittest.TextTestRunner

        runner = runner_class(**runner_kwargs)
        env.setup()
        if not self.tornado_warnings:
            suppress_tornado_warnings()

        result = runner.run(suite)
        env.teardown()
        sys.exit(not result.wasSuccessful())
Exemplo n.º 4
0
    def run(self):
        # Installing required packages, running egg_info and build_ext are
        # part of normal operation for setuptools.command.test.test. Motor
        # has no extensions so build_ext is a no-op.
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        if self.xunit_output:
            self.distribution.fetch_build_eggs(
                ["unittest-xml-reporting>=1.14.0,<2.0.0a0"])
        self.run_command('egg_info')
        build_ext_cmd = self.reinitialize_command('build_ext')
        build_ext_cmd.inplace = 1
        self.run_command('build_ext')

        from test import (env,
                          suppress_tornado_warnings,
                          MotorTestLoader,
                          test_environment as testenv)

        loader = MotorTestLoader()
        loader.avoid('high_availability', reason='Runs separately')

        if not (testenv.HAVE_ASYNCIO or testenv.HAVE_TORNADO):
            raise ImportError("No tornado nor asyncio")
        elif not testenv.HAVE_TORNADO:
            loader.avoid('tornado_tests', reason='no tornado')
        elif not testenv.HAVE_ASYNCIO:
            loader.avoid('asyncio_tests', reason='no asyncio')

        if not testenv.HAVE_AIOHTTP:
            loader.avoid('asyncio_tests.test_aiohttp_gridfs',
                         reason='no aiohttp')

        if sys.version_info[:2] < (3, 5):
            loader.avoid('asyncio_tests.test_asyncio_await',
                         'asyncio_tests.test_asyncio_change_stream',
                         'asyncio_tests.test_examples',
                         reason='python < 3.5')

        # Decide if we can run async / await tests with Tornado.
        test_motor_await = 'tornado_tests.test_motor_await'
        if not testenv.HAVE_TORNADO:
            loader.avoid(test_motor_await, reason='no tornado')
        elif sys.version_info[:2] < (3, 5):
            loader.avoid(test_motor_await, reason='python < 3.5')
            loader.avoid('tornado_tests.test_motor_change_stream',
                         reason='python < 3.5')

        if self.test_suite is None:
            suite = loader.discover(self.test_module)
        else:
            suite = loader.loadTestsFromName(self.test_suite)

        runner_kwargs = dict(verbosity=2, failfast=self.failfast)

        if self.xunit_output:
            runner_kwargs['output'] = self.xunit_output
            from xmlrunner import XMLTestRunner
            runner_class = XMLTestRunner
        else:
            import unittest
            runner_class = unittest.TextTestRunner

        runner = runner_class(**runner_kwargs)
        env.setup()
        if not self.tornado_warnings:
            suppress_tornado_warnings()

        result = runner.run(suite)
        sys.exit(not result.wasSuccessful())
Exemplo n.º 5
0
    def run(self):
        # Installing required packages, running egg_info and build_ext are
        # part of normal operation for setuptools.command.test.test. Motor
        # has no extensions so build_ext is a no-op.
        if self.distribution.install_requires:
            self.distribution.fetch_build_eggs(
                self.distribution.install_requires)
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)
        if self.xunit_output:
            self.distribution.fetch_build_eggs(
                ["unittest-xml-reporting>=1.14.0,<2.0.0a0"])
        self.run_command('egg_info')
        build_ext_cmd = self.reinitialize_command('build_ext')
        build_ext_cmd.inplace = 1
        self.run_command('build_ext')

        # Construct a test runner directly from the unittest imported from
        # test (this will be unittest2 under Python 2.6), which creates a
        # TestResult that supports the 'addSkip' method. setuptools will by
        # default create a TextTestRunner that uses the old TestResult class,
        # resulting in DeprecationWarnings instead of skipping tests under 2.6.
        from test import (env,
                          suppress_tornado_warnings,
                          unittest, MotorTestLoader,
                          test_environment as testenv)

        loader = MotorTestLoader()
        loader.avoid('high_availability', 'Runs separately')

        if not (testenv.HAVE_ASYNCIO or testenv.HAVE_TORNADO):
            raise ImportError("No tornado nor asyncio")
        elif not testenv.HAVE_TORNADO:
            loader.avoid('tornado_tests', reason='no tornado')
        elif not testenv.HAVE_ASYNCIO:
            loader.avoid('asyncio_tests', reason='no asyncio')
        
        if not testenv.HAVE_AIOHTTP:
            loader.avoid('asyncio_tests.test_aiohttp_gridfs', reason='no aiohttp')

        if sys.version_info[:2] < (3, 5):
            loader.avoid('asyncio_tests.test_asyncio_await',
                         reason='python < 3.5')

        # Decide if we can run async / await tests with Tornado.
        test_motor_await = 'tornado_tests.test_motor_await'
        if not testenv.HAVE_TORNADO:
            loader.avoid(test_motor_await, reason='no tornado')
        # We need Tornado after this patch to wrap "async def" with gen_test:
        # https://github.com/tornadoweb/tornado/pull/1550
        elif not testenv.TORNADO_VERSION[:2] > (4, 2):
            loader.avoid(test_motor_await, reason='tornado < 4.3')
        elif sys.version_info[:2] < (3, 5):
            loader.avoid(test_motor_await, reason='python < 3.5')

        if self.test_suite is None:
            suite = loader.discover(self.test_module)
        else:
            suite = loader.loadTestsFromName(self.test_suite)

        runner_kwargs = dict(verbosity=2, failfast=self.failfast)

        if self.xunit_output:
            runner_kwargs['output'] = self.xunit_output
            from xmlrunner import XMLTestRunner
            runner_class = XMLTestRunner
        else:
            runner_class = unittest.TextTestRunner

        runner = runner_class(**runner_kwargs)
        env.setup()
        if not self.tornado_warnings:
            suppress_tornado_warnings()

        result = runner.run(suite)
        env.teardown()
        sys.exit(not result.wasSuccessful())