Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

round the actual coverage to 2 decimal pieces #400

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions spidermon/contrib/scrapy/monitors/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ def test_check_if_field_coverage_rules_are_met(self):
"SPIDERMON_FIELD_COVERAGE_RULES"
)
for field, expected_coverage in field_coverage_rules.items():
actual_coverage = self.data.stats.get(
f"spidermon_field_coverage/{field}", 0
actual_coverage = round(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, to avoid rounding we can change the comparation with:

if  actual_coverage > expected_coverage or math.isclose(actual_coverage, expected_coverage, abs_tol=threshold)  :
   continue
else:
    failure.append(

In any case, the margin of error should be configurable, and the default configuration should be do nothing as compared to the current implementation. Otherwise, this would break backward compatibility and should be clearly warned

self.data.stats.get(f"spidermon_field_coverage/{field}", 0), 2
)
if actual_coverage < expected_coverage:
failures.append(
Expand Down