def __init__(self, default_min_coverage: float = 70.0, allowed_coverage_degradation_percentage: float = 1.0,
                 coverage_file: Optional[str] = os.path.join('coverage_report', '.coverage'), no_cache: Optional[bool] = False,
                 report_dir: str = 'coverage_report', report_type: Optional[str] = None,
                 no_degradation_check: Optional[bool] = False,
                 previous_coverage_report_url: Optional[str] = 'https://storage.googleapis.com/marketplace-dist-dev/code-coverage-reports/coverage-min.json'):
        self.report_dir = report_dir
        self._cov: Optional[coverage.Coverage] = None
        self._report_str: Optional[str] = None
        self.degradation_check = not no_degradation_check
        self.coverage_file = coverage_file
        self.report_types = parse_report_type(report_type)

        if not self.degradation_check:
            return

        self.default = default_min_coverage
        self.epsilon = allowed_coverage_degradation_percentage

        cache_dir = str(os.path.join(self.report_dir, 'cache')) if not no_cache else None
        self._original_summary: Union[CoverageSummary, Dict[str, float]] = CoverageSummary(
            cache_dir=cache_dir,
            previous_coverage_report_url=previous_coverage_report_url,
            no_cache=no_cache
        )
示例#2
0
 def test_with_mixed_values(self):
     with pytest.raises(InvalidReportType) as invalid_report_type:
         parse_report_type('xml,test')
         assert str(invalid_report_type) == "test is not a valid report type. You can use the following report types as a " \
             "comma separated value for the --report-type argument ('text', 'html', 'xml', 'json', 'json-min', 'all')."
示例#3
0
 def test_with_all_and_other_values(self):
     with pytest.raises(InvalidReportType) as invalid_report_type:
         parse_report_type('xml,all')
         assert str(
             invalid_report_type
         ) == 'You may not use the "all" report type in addition to other report types.'
示例#4
0
 def test_all_report_types_explicit(self):
     assert parse_report_type('text,json,json-min,html,xml') == [
         'text', 'json', 'json-min', 'html', 'xml'
     ]
示例#5
0
 def test_with_all(self):
     assert sorted(parse_report_type('all')) == sorted(
         ['text', 'json', 'json-min', 'html', 'xml'])
示例#6
0
 def test_with_multiple(self):
     assert parse_report_type('text,json') == ['text', 'json']
示例#7
0
 def test_with_one(self):
     assert parse_report_type('text') == ['text']
示例#8
0
 def test_with_none(self):
     assert parse_report_type(None) == []