Ejemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        if kwargs.pop('html_output_from_env', None) is not None or \
                kwargs.pop('html_output_dir', None) is not None:
            warnings.warn(
                'The unit tests HTML support was removed from {0}. Please '
                'stop passing \'html_output_dir\' or \'html_output_from_env\' '
                'as arguments to {0}'.format(self.__class__.__name__),
                category=DeprecationWarning,
                stacklevel=2)

        SaltTestingParser.__init__(self, *args, **kwargs)
        self.code_coverage = None

        # Add the coverage related options
        self.output_options_group.add_option(
            '--coverage',
            default=False,
            action='store_true',
            help='Run tests and report code coverage')
        self.output_options_group.add_option(
            '--no-processes-coverage',
            default=False,
            action='store_true',
            help='Do not track subprocess and/or multiprocessing processes')
        self.output_options_group.add_option(
            '--coverage-xml',
            default=None,
            help='If provided, the path to where a XML report of the code '
            'coverage will be written to')
        self.output_options_group.add_option(
            '--coverage-html',
            default=None,
            help=('The directory where the generated HTML coverage report '
                  'will be saved to. The directory, if existing, will be '
                  'deleted before the report is generated.'))
Ejemplo n.º 2
0
 def pre_execution_cleanup(self):
     if self.options.coverage_html is not None:
         if os.path.isdir(self.options.coverage_html):
             shutil.rmtree(self.options.coverage_html)
     if self.options.coverage_xml is not None:
         if os.path.isfile(self.options.coverage_xml):
             os.unlink(self.options.coverage_xml)
     SaltTestingParser.pre_execution_cleanup(self)
Ejemplo n.º 3
0
 def pre_execution_cleanup(self):
     if self.options.coverage_html is not None:
         if os.path.isdir(self.options.coverage_html):
             shutil.rmtree(self.options.coverage_html)
     if self.options.coverage_xml is not None:
         if os.path.isfile(self.options.coverage_xml):
             os.unlink(self.options.coverage_xml)
     SaltTestingParser.pre_execution_cleanup(self)
Ejemplo n.º 4
0
    def _validate_options(self):
        if (self.options.coverage_xml or self.options.coverage_html) and not self.options.coverage:
            self.options.coverage = True

        if self.options.coverage is True and COVERAGE_AVAILABLE is False:
            self.error("Cannot run tests with coverage report. " "Please install coverage>=3.5.3")

        if self.options.coverage is True:
            coverage_version = tuple(
                [int(part) for part in re.search(r"([0-9.]+)", coverage.__version__).group(0).split(".")]
            )
            if coverage_version < (3, 5, 3):
                # Should we just print the error instead of exiting?
                self.error(
                    "Versions lower than 3.5.3 of the coverage library are "
                    "know to produce incorrect results. Please consider "
                    "upgrading..."
                )
        SaltTestingParser._validate_options(self)
Ejemplo n.º 5
0
    def _validate_options(self):
        if (self.options.coverage_xml or self.options.coverage_html) and \
                not self.options.coverage:
            self.options.coverage = True

        if self.options.coverage is True and COVERAGE_AVAILABLE is False:
            self.error('Cannot run tests with coverage report. '
                       'Please install coverage>=3.5.3')

        if self.options.coverage is True:
            coverage_version = tuple([
                int(part) for part in re.search(
                    r'([0-9.]+)', coverage.__version__).group(0).split('.')
            ])
            if coverage_version < (3, 5, 3):
                # Should we just print the error instead of exiting?
                self.error(
                    'Versions lower than 3.5.3 of the coverage library are '
                    'know to produce incorrect results. Please consider '
                    'upgrading...')
        SaltTestingParser._validate_options(self)
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        if kwargs.pop('html_output_from_env', None) is not None or \
                kwargs.pop('html_output_dir', None) is not None:
            warnings.warn(
                'The unit tests HTML support was removed from {0}. Please '
                'stop passing \'html_output_dir\' or \'html_output_from_env\' '
                'as arguments to {0}'.format(self.__class__.__name__),
                category=DeprecationWarning,
                stacklevel=2
            )

        SaltTestingParser.__init__(self, *args, **kwargs)
        self.code_coverage = None

        # Add the coverage related options
        self.output_options_group.add_option(
            '--coverage',
            default=False,
            action='store_true',
            help='Run tests and report code coverage'
        )
        self.output_options_group.add_option(
            '--no-processes-coverage',
            default=False,
            action='store_true',
            help='Do not track subprocess and/or multiprocessing processes'
        )
        self.output_options_group.add_option(
            '--coverage-xml',
            default=None,
            help='If provided, the path to where a XML report of the code '
                 'coverage will be written to'
        )
        self.output_options_group.add_option(
            '--coverage-html',
            default=None,
            help=('The directory where the generated HTML coverage report '
                  'will be saved to. The directory, if existing, will be '
                  'deleted before the report is generated.')
        )
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        if kwargs.pop("html_output_from_env", None) is not None or kwargs.pop("html_output_dir", None) is not None:
            warnings.warn(
                "The unit tests HTML support was removed from {0}. Please "
                "stop passing 'html_output_dir' or 'html_output_from_env' "
                "as arguments to {0}".format(self.__class__.__name__),
                category=DeprecationWarning,
                stacklevel=2,
            )

        SaltTestingParser.__init__(self, *args, **kwargs)
        self.code_coverage = None

        # Add the coverage related options
        self.output_options_group.add_option(
            "--coverage", default=False, action="store_true", help="Run tests and report code coverage"
        )
        self.output_options_group.add_option(
            "--no-processes-coverage",
            default=False,
            action="store_true",
            help="Do not track subprocess and/or multiprocessing processes",
        )
        self.output_options_group.add_option(
            "--coverage-xml",
            default=None,
            help="If provided, the path to where a XML report of the code " "coverage will be written to",
        )
        self.output_options_group.add_option(
            "--coverage-html",
            default=None,
            help=(
                "The directory where the generated HTML coverage report "
                "will be saved to. The directory, if existing, will be "
                "deleted before the report is generated."
            ),
        )
Ejemplo n.º 8
0
 def finalize(self, exit_code=0):
     if self.options.coverage is True:
         self.stop_coverage(save_coverage=True)
     SaltTestingParser.finalize(self, exit_code)
Ejemplo n.º 9
0
 def finalize(self, exit_code=0):
     if self.options.coverage is True:
         self.stop_coverage(save_coverage=True)
     SaltTestingParser.finalize(self, exit_code)