Skip to content

Commit 194d011

Browse files
committed
consider a total of 0 as a percentage of 100%
1 parent d703c2c commit 194d011

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

python_tool_competition_2024/results.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __post_init__(self) -> None:
5757
@property
5858
def ratio(self) -> float:
5959
"""The total covarage. The value is between 0.0 and 1.0."""
60-
return 0.0 if self.total == 0 else self.successful / self.total
60+
return 1.0 if self.total == 0 else self.successful / self.total
6161

6262
def __add__(self, other: "RatioResult") -> "RatioResult":
6363
"""Add the results together."""

tests/cli/test_run.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,9 @@ def test_run_with_real_tests(wd_tmp_path: Path) -> None:
307307
┃ Target ┃ Success ┃ Line Coverage ┃ Branch Coverage ┃ Mutation Score ┃
308308
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
309309
│ example1.py │ ✔ │ 44.44 % │ 25.00 % │ 62.50 % │
310-
│ example2.py │ ✖ │ 0.00 % │ 0.00 % │ 0.00 % │
310+
│ example2.py │ ✖ │ 0.00 % │ 100.00 % │ 0.00 % │
311311
│ sub_example/__init__.py │ ✖ │ 0.00 % │ 0.00 % │ 0.00 % │
312-
│ sub_example/example3.py │ ✔ │ 100.00 % │ 0.00 % │ 0.00 % │
312+
│ sub_example/example3.py │ ✔ │ 100.00 % │ 100.00 % │ 0.00 % │
313313
├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤
314314
│ Total │ 50.00 % │ 38.89 % │ 16.67 % │ 45.45 % │
315315
└─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘
@@ -341,9 +341,9 @@ def test_run_with_real_tests(wd_tmp_path: Path) -> None:
341341
"mutation score,mutants,killed mutants"
342342
),
343343
"example1.py,1.0,1,1,0.4444444444444444,9,4,0.25,4,1,0.625,8,5",
344-
"example2.py,0.0,1,0,0.0,2,0,0.0,0,0,0.0,1,0",
344+
"example2.py,0.0,1,0,0.0,2,0,1.0,0,0,0.0,1,0",
345345
"sub_example/__init__.py,0.0,1,0,0.0,4,0,0.0,2,0,0.0,1,0",
346-
"sub_example/example3.py,1.0,1,1,1.0,3,3,0.0,0,0,0.0,1,0",
346+
"sub_example/example3.py,1.0,1,1,1.0,3,3,1.0,0,0,0.0,1,0",
347347
"total,0.5,4,2,0.3888888888888889,18,7,0.16666666666666666,6,1,0.45454545454545453,11,5",
348348
)
349349
targets = (TARGETS_DIR / "sub_example" / "example3.py", TARGETS_DIR / "example1.py")
@@ -363,9 +363,9 @@ def test_run_with_different_targets_and_dummy(wd_tmp_path: Path) -> None:
363363
┃ Target ┃ Success ┃ Line Coverage ┃ Branch Coverage ┃ Mutation Score ┃
364364
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
365365
│ example1.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
366-
│ example2.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
366+
│ example2.py │ ✔ │ 0.00 % │ 100.00 % │ 0.00 % │
367367
│ sub_example/__init__.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
368-
│ sub_example/example3.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
368+
│ sub_example/example3.py │ ✔ │ 0.00 % │ 100.00 % │ 0.00 % │
369369
├─────────────────────────┼──────────┼───────────────┼─────────────────┼────────────────┤
370370
│ Total │ 100.00 % │ 0.00 % │ 0.00 % │ 0.00 % │
371371
└─────────────────────────┴──────────┴───────────────┴─────────────────┴────────────────┘
@@ -399,9 +399,9 @@ def test_run_with_different_targets_and_dummy(wd_tmp_path: Path) -> None:
399399
"mutation score,mutants,killed mutants"
400400
),
401401
"example1.py,1.0,1,1,0.0,9,0,0.0,4,0,0.0,8,0",
402-
"example2.py,1.0,1,1,0.0,2,0,0.0,0,0,0.0,1,0",
402+
"example2.py,1.0,1,1,0.0,2,0,1.0,0,0,0.0,1,0",
403403
"sub_example/__init__.py,1.0,1,1,0.0,4,0,0.0,2,0,0.0,1,0",
404-
"sub_example/example3.py,1.0,1,1,0.0,3,0,0.0,0,0,0.0,1,0",
404+
"sub_example/example3.py,1.0,1,1,0.0,3,0,1.0,0,0,0.0,1,0",
405405
"total,1.0,4,4,0.0,18,0,0.0,6,0,0.0,11,0",
406406
)
407407
targets = (
@@ -438,9 +438,9 @@ def test_run_with_different_targets_and_results(wd_tmp_path: Path) -> None:
438438
┃ Target ┃ Success ┃ Line Coverage ┃ Branch Coverage ┃ Mutation Score ┃
439439
┡━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩
440440
│ example1.py │ ✖ │ 0.00 % │ 0.00 % │ 0.00 % │
441-
│ example2.py │ ✖ │ 0.00 % │ 0.00 % │ 0.00 % │
441+
│ example2.py │ ✖ │ 0.00 % │ 100.00 % │ 0.00 % │
442442
│ sub_example/__init__.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
443-
│ sub_example/example3.py │ ✔ │ 0.00 % │ 0.00 % │ 0.00 % │
443+
│ sub_example/example3.py │ ✔ │ 0.00 % │ 100.00 % │ 0.00 % │
444444
├─────────────────────────┼─────────┼───────────────┼─────────────────┼────────────────┤
445445
│ Total │ 50.00 % │ 0.00 % │ 0.00 % │ 0.00 % │
446446
└─────────────────────────┴─────────┴───────────────┴─────────────────┴────────────────┘
@@ -471,9 +471,9 @@ def test_run_with_different_targets_and_results(wd_tmp_path: Path) -> None:
471471
"mutation score,mutants,killed mutants"
472472
),
473473
"example1.py,0.0,1,0,0.0,9,0,0.0,4,0,0.0,8,0",
474-
"example2.py,0.0,1,0,0.0,2,0,0.0,0,0,0.0,1,0",
474+
"example2.py,0.0,1,0,0.0,2,0,1.0,0,0,0.0,1,0",
475475
"sub_example/__init__.py,1.0,1,1,0.0,4,0,0.0,2,0,0.0,1,0",
476-
"sub_example/example3.py,1.0,1,1,0.0,3,0,0.0,0,0,0.0,1,0",
476+
"sub_example/example3.py,1.0,1,1,0.0,3,0,1.0,0,0,0.0,1,0",
477477
"total,0.5,4,2,0.0,18,0,0.0,6,0,0.0,11,0",
478478
)
479479
targets = (

0 commit comments

Comments
 (0)