Beispiel #1
0
    def handle(self, *args, **options):
        setup_test_environment()

        verbosity = options['verbosity']
        no_color = options.get('no_color', False)
        apps_to_run = tuple(options['apps'].split(","))
        apps_to_avoid = tuple(options['avoid_apps'].split(","))
        run_server = not options['no_server']
        test_database = options['test_database']
        smtp_queue = options['smtp_queue']
        tags = options['tags']
        failfast = options['failfast']
        auto_pdb = options['auto_pdb']
        threading = options['use_threading']

        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner
            self._testrunner = get_runner(settings)(interactive=False)
            
            if DJANGO_VERSION > StrictVersion('1.10'):
                self._testrunner.teardown_test_environment()
                
            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            if DJANGO_VERSION < StrictVersion('1.7'):
                call_command('syncdb', verbosity=0, interactive=False,)
                if migrate_south:
                   call_command('migrate', verbosity=0, interactive=False,)
            else:
                call_command('migrate', verbosity=0, interactive=False,)

        settings.DEBUG = options.get('debug', False)

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        server = get_server(port=options['port'], threading=threading)

        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise CommandError("Couldn't start Django server: %s" % e)

        os.environ['SERVER_NAME'] = str(server.address)
        os.environ['SERVER_PORT'] = str(server.port)

        failed = False

        registry.call_hook('before', 'harvest', locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook('before_each', 'app', app_module)

                runner = Runner(path, options.get('scenarios'),
                                verbosity, no_color,
                                enable_xunit=options.get('enable_xunit'),
                                enable_subunit=options.get('enable_subunit'),
                                enable_jsonreport=options.get('enable_jsonreport'),
                                xunit_filename=options.get('xunit_file'),
                                subunit_filename=options.get('subunit_file'),
                                jsonreport_filename=options.get('jsonreport_file'),
                                tags=tags, failfast=failfast, auto_pdb=auto_pdb,
                                root_dir=path,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except LettuceRunnerError:
            failed = True

        except Exception as e:
            failed = True
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            if failed:
                raise CommandError("Lettuce tests failed.")
Beispiel #2
0
                                tags=tags, failfast=failfast, auto_pdb=auto_pdb,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except SystemExit, e:
            failed = e.code

        except Exception, e:
            failed = True
            import traceback
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            raise SystemExit(int(failed))
Beispiel #3
0
    def handle(self, *args, **options):
        setup_test_environment()
        settings.DEBUG = options.get('debug', False)
        settings.LETTUCE_BROWSER = options.get('browser', 'chrome')
        settings.LETTUCE_FAILED_STEP_SLEEP = options.get('failed_step_sleep')
        settings.DEFAULT_TABLESPACE = options.get('tablespace')
        settings.DISABLE_JSCOMPILE = options.get('disable_jscompile')
        settings.LETTUCE_BY_STEP = options.get('by_step', False)
        settings.LETTUCE_HEADLESS = options.get('headless', False)

        verbosity = int(options.get('verbosity', 3))
        no_color = int(options.get('no_color', False))
        apps_to_run = tuple(options.get('apps', '').split(","))
        apps_to_avoid = tuple(options.get('avoid_apps', '').split(","))
        run_server = not options.get('no_server', False)
        test_database = options.get('test_database', False)
        smtp_queue = options.get('smtp_queue', False)
        tags = options.get('tags', None)
        failfast = options.get('failfast', False)
        auto_pdb = options.get('auto_pdb', False)
        threading = options.get('use_threading', True)
        with_summary = options.get('summary_display', False)
        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner
            self._testrunner = get_runner(settings)(interactive=False)

            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            call_command(
                'syncdb',
                verbosity=0,
                interactive=False,
            )
            if migrate_south:
                call_command(
                    'migrate',
                    verbosity=0,
                    interactive=False,
                )

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        if not paths:
            paths = options.get('paths', [])
        server = get_server(port=options['port'], threading=threading)
        os.environ['REMOTE_HOST'] = options['host']
        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise SystemExit(e)

        os.environ['SERVER_NAME'] = str(server.address)
        os.environ['SERVER_PORT'] = str(server.port)

        failed = False

        registry.call_hook('before', 'harvest', locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook('before_each', 'app', app_module)

                runner = Runner(path,
                                options.get('scenarios'),
                                verbosity,
                                no_color,
                                enable_xunit=options.get('enable_xunit'),
                                enable_subunit=options.get('enable_subunit'),
                                xunit_filename=options.get('xunit_file'),
                                subunit_filename=options.get('subunit_file'),
                                tags=tags,
                                failfast=failfast,
                                auto_pdb=auto_pdb,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except SystemExit as e:
            failed = e.code

        except Exception as e:
            failed = True
            import traceback
            traceback.print_exc(0)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            raise SystemExit(int(failed))
Beispiel #4
0
    def handle(self, *args, **options):
        setup_test_environment()

        verbosity = int(options.get('verbosity', 3))
        no_color = int(options.get('no_color', False))
        apps_to_run = tuple(options.get('apps', '').split(","))
        apps_to_avoid = tuple(options.get('avoid_apps', '').split(","))
        run_server = not options.get('no_server', False)
        test_database = options.get('test_database', False)
        smtp_queue = options.get('smtp_queue', False)
        tags = options.get('tags', None)
        failfast = options.get('failfast', False)
        auto_pdb = options.get('auto_pdb', False)
        threading = options.get('use_threading', True)
        with_summary = options.get('summary_display', False)

        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner
            self._testrunner = get_runner(settings)(interactive=False)
            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            call_command('syncdb', verbosity=0, interactive=False,)
            if migrate_south:
               call_command('migrate', verbosity=0, interactive=False,)

        settings.DEBUG = options.get('debug', False)

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        server = get_server(port=options['port'], threading=threading)

        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise SystemExit(e)

        os.environ['SERVER_NAME'] = str(server.address)
        os.environ['SERVER_PORT'] = str(server.port)

        failed = False

        registry.call_hook('before', 'harvest', locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook('before_each', 'app', app_module)

                runner = Runner(path, options.get('scenarios'),
                                verbosity, no_color,
                                enable_xunit=options.get('enable_xunit'),
                                enable_subunit=options.get('enable_subunit'),
                                xunit_filename=options.get('xunit_file'),
                                subunit_filename=options.get('subunit_file'),
                                tags=tags, failfast=failfast, auto_pdb=auto_pdb,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except SystemExit as e:
            failed = e.code

        except Exception as e:
            failed = True
            import traceback
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            raise SystemExit(int(failed))
Beispiel #5
0
                                auto_pdb=auto_pdb,
                                smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except SystemExit, e:
            failed = e.code

        except Exception, e:
            failed = True
            import traceback
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            raise SystemExit(int(failed))
Beispiel #6
0
    def handle(self, *args, **options):
        setup_test_environment()

        verbosity = options['verbosity']
        no_color = options.get('no_color', False)
        apps_to_run = tuple(options['apps'].split(","))
        apps_to_avoid = tuple(options['avoid_apps'].split(","))
        run_server = not options['no_server']
        test_database = options['test_database']
        smtp_queue = options['smtp_queue']
        tags = options['tags']
        failfast = options['failfast']
        auto_pdb = options['auto_pdb']
        threading = options['use_threading']

        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup
                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner
            self._testrunner = get_runner(settings)(interactive=False)

            if DJANGO_VERSION > StrictVersion('1.10'):
                self._testrunner.teardown_test_environment()

            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            if DJANGO_VERSION < StrictVersion('1.7'):
                call_command(
                    'syncdb',
                    verbosity=0,
                    interactive=False,
                )
                if migrate_south:
                    call_command(
                        'migrate',
                        verbosity=0,
                        interactive=False,
                    )
            else:
                call_command(
                    'migrate',
                    verbosity=0,
                    interactive=False,
                )

        settings.DEBUG = options.get('debug', False)

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        server = get_server(port=options['port'], threading=threading)

        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise CommandError("Couldn't start Django server: %s" % e)

        os.environ['SERVER_NAME'] = str(server.address)
        os.environ['SERVER_PORT'] = str(server.port)

        failed = False

        registry.call_hook('before', 'harvest', locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook('before_each', 'app', app_module)

                runner = Runner(
                    path,
                    options.get('scenarios'),
                    verbosity,
                    no_color,
                    enable_xunit=options.get('enable_xunit'),
                    enable_subunit=options.get('enable_subunit'),
                    enable_jsonreport=options.get('enable_jsonreport'),
                    xunit_filename=options.get('xunit_file'),
                    subunit_filename=options.get('subunit_file'),
                    jsonreport_filename=options.get('jsonreport_file'),
                    tags=tags,
                    failfast=failfast,
                    auto_pdb=auto_pdb,
                    root_dir=path,
                    smtp_queue=smtp_queue)

                result = runner.run()
                if app_module is not None:
                    registry.call_hook('after_each', 'app', app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except LettuceRunnerError:
            failed = True

        except Exception as e:
            failed = True
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook('after', 'harvest', summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            if failed:
                raise CommandError("Lettuce tests failed.")
Beispiel #7
0
    def handle(self, *args, **options):
        setup_test_environment()

        verbosity = options["verbosity"]
        no_color = options.get("no_color", False)
        apps_to_run = tuple(options["apps"].split(","))
        apps_to_avoid = tuple(options["avoid_apps"].split(","))
        run_server = not options["no_server"]
        test_database = options["test_database"]
        smtp_queue = options["smtp_queue"]
        tags = options["tags"]
        failfast = options["failfast"]
        auto_pdb = options["auto_pdb"]
        threading = options["use_threading"]

        if test_database:
            migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True)
            try:
                from south.management.commands import patch_for_test_db_setup

                patch_for_test_db_setup()
            except:
                migrate_south = False
                pass

            from django.test.utils import get_runner

            self._testrunner = get_runner(settings)(interactive=False)
            self._testrunner.setup_test_environment()
            self._old_db_config = self._testrunner.setup_databases()

            if DJANGO_VERSION < StrictVersion("1.7"):
                call_command("syncdb", verbosity=0, interactive=False)
                if migrate_south:
                    call_command("migrate", verbosity=0, interactive=False)
            else:
                call_command("migrate", verbosity=0, interactive=False)

        settings.DEBUG = options.get("debug", False)

        paths = self.get_paths(args, apps_to_run, apps_to_avoid)
        server = get_server(port=options["port"], threading=threading)

        if run_server:
            try:
                server.start()
            except LettuceServerException as e:
                raise CommandError("Couldn't start Django server: %s" % e)

        os.environ["SERVER_NAME"] = str(server.address)
        os.environ["SERVER_PORT"] = str(server.port)

        failed = False

        registry.call_hook("before", "harvest", locals())
        results = []
        try:
            for path in paths:
                app_module = None
                if isinstance(path, tuple) and len(path) is 2:
                    path, app_module = path

                if app_module is not None:
                    registry.call_hook("before_each", "app", app_module)

                runner = Runner(
                    path,
                    options.get("scenarios"),
                    verbosity,
                    no_color,
                    enable_xunit=options.get("enable_xunit"),
                    enable_subunit=options.get("enable_subunit"),
                    enable_jsonreport=options.get("enable_jsonreport"),
                    xunit_filename=options.get("xunit_file"),
                    subunit_filename=options.get("subunit_file"),
                    jsonreport_filename=options.get("jsonreport_file"),
                    tags=tags,
                    failfast=failfast,
                    auto_pdb=auto_pdb,
                    smtp_queue=smtp_queue,
                )

                result = runner.run()
                if app_module is not None:
                    registry.call_hook("after_each", "app", app_module, result)

                results.append(result)
                if not result or result.steps != result.steps_passed:
                    failed = True
        except LettuceRunnerError:
            failed = True

        except Exception as e:
            failed = True
            traceback.print_exc(e)

        finally:
            summary = SummaryTotalResults(results)
            summary.summarize_all()
            registry.call_hook("after", "harvest", summary)

            if test_database:
                self._testrunner.teardown_databases(self._old_db_config)

            teardown_test_environment()
            server.stop(failed)

            if failed:
                raise CommandError("Lettuce tests failed.")