コード例 #1
0
ファイル: hudson.py プロジェクト: RobCombs/django-hudson
    def handle(self, *args, **options):
        """
        Run pylint and test with coverage and xml reports
        """
        output_dir=options.get('output_dir')
        if not path.exists(output_dir):
            os.makedirs(output_dir)

        app_labels = Command.app_list()

        # pylint
        pylint().handle(*app_labels, 
                         output_file=path.join(output_dir,'pylint.report'))


        #coverage
        coverage.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]')
        coverage.start()
        
        #tests
        test_runner = XmlDjangoTestSuiteRunner(output_dir=output_dir)
        failures = test_runner.run_tests(app_labels)

        #save coverage report
        coverage.stop()
        
        modules = [module for name, module in sys.modules.items() \
                       if module and any([name.startswith(label) for label in app_labels])]

        morfs = [ m.__file__ for m in modules if hasattr(m, '__file__') ]
        coverage._the_coverage.xml_report(morfs, outfile=path.join(output_dir,'coverage.xml'))
コード例 #2
0
ファイル: hudson.py プロジェクト: cmheisel/django-hudson
    def handle(self, *test_labels, **options):
        """
        Run pylint and test with coverage and xml reports
        """
        patch_for_test_db_setup()

        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)
        excludes = options.get('excludes', '').split(',')
        excludes = [ exclude.strip() for exclude in excludes ]

        tasks = getattr(settings, 'HUDSON_TASKS',
                        ['pylint', 'coverage', 'tests'])

        output_dir=options.get('output_dir')
        if not path.exists(output_dir):
            os.makedirs(output_dir)

        if not test_labels:
            test_labels = Command.test_labels()

        if verbosity > 0:
           print "Testing and covering the following apps:\n %s" % pprint.pformat(test_labels, )

        #TODO: Make lint work and with external rc file
        if 'pylint' in tasks:
            pylint().handle(output_file=path.join(output_dir,'pylint.report'),
                                *test_labels)

        if 'coverage' in tasks:
            coverage.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]')
            coverage.start()

        failures = 0
        if 'tests' in tasks:
            test_runner = XmlDjangoTestSuiteRunner(output_dir=output_dir, interactive=interactive, verbosity=verbosity)
            failures = test_runner.run_tests(test_labels)

        #save coverage report
        if 'coverage' in tasks:
            coverage.stop()

        modules = [ module for name, module in sys.modules.items() \
                    if hasattr(module, "__file__") and self.want_module(module, test_labels, excludes)
        ]
        morfs = [ self.src(m.__file__) for m in modules if self.src(m.__file__).endswith(".py")]

        if verbosity > 0:
            if excludes:
                print "Excluding any module containing of these words:"
                pprint.pprint(excludes)

            print "Coverage being generated for:"
            pprint.pprint(morfs)

        if 'coverage' in tasks:
            coverage._the_coverage.xml_report(morfs, outfile=path.join(output_dir,'coverage.xml'))

        if failures:
            sys.exit(bool(failures))
コード例 #3
0
ファイル: xmltest.py プロジェクト: imcj/pybbs
    def handle(self, *test_labels, **options):
        patch_for_test_db_setup()
        output_dir=options.get('output_dir')
        
        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)
        
        test_runner = XmlDjangoTestSuiteRunner(output_dir=output_dir, interactive=interactive, verbosity=verbosity)
        failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(bool(failures))
コード例 #4
0
    def handle(self, *test_labels, **options):
        patch_for_test_db_setup()
        output_dir = options.get('output_dir')

        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)

        test_runner = XmlDjangoTestSuiteRunner(output_dir=output_dir,
                                               interactive=interactive,
                                               verbosity=verbosity)
        failures = test_runner.run_tests(test_labels)

        if failures:
            sys.exit(bool(failures))
コード例 #5
0
    def handle(self, *test_labels, **options):
        """
        Run pylint and test with coverage and xml reports
        """
        patch_for_test_db_setup()

        verbosity = int(options.get('verbosity', 1))
        interactive = options.get('interactive', True)
        excludes = options.get('excludes', '').split(',')
        excludes = [exclude.strip() for exclude in excludes]

        tasks = getattr(settings, 'HUDSON_TASKS',
                        ['pylint', 'coverage', 'tests'])

        output_dir = options.get('output_dir')
        if not path.exists(output_dir):
            os.makedirs(output_dir)

        if not test_labels:
            test_labels = Command.test_labels()

        if verbosity > 0:
            print "Testing and covering the following apps:\n %s" % pprint.pformat(
                test_labels, )

        #TODO: Make lint work and with external rc file
        if 'pylint' in tasks:
            pylint().handle(output_file=path.join(output_dir, 'pylint.report'),
                            *test_labels)

        if 'coverage' in tasks:
            coverage.exclude('#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]')
            coverage.start()

        failures = 0
        if 'tests' in tasks:
            test_runner = XmlDjangoTestSuiteRunner(output_dir=output_dir,
                                                   interactive=interactive,
                                                   verbosity=verbosity)
            failures = test_runner.run_tests(test_labels)

        #save coverage report
        if 'coverage' in tasks:
            coverage.stop()

        modules = [ module for name, module in sys.modules.items() \
                    if hasattr(module, "__file__") and self.want_module(module, test_labels, excludes)
        ]
        morfs = [
            self.src(m.__file__) for m in modules
            if self.src(m.__file__).endswith(".py")
        ]

        if verbosity > 0:
            if excludes:
                print "Excluding any module containing of these words:"
                pprint.pprint(excludes)

            print "Coverage being generated for:"
            pprint.pprint(morfs)

        if 'coverage' in tasks:
            coverage._the_coverage.xml_report(morfs,
                                              outfile=path.join(
                                                  output_dir, 'coverage.xml'))

        if failures:
            sys.exit(bool(failures))