Skip to content

[BUG]: robotpy coverage test --isolated incorrectly reports coverage #242

@auscompgeek

Description

@auscompgeek

Problem description

No combination of options correctly report test coverage with isolated mode.

> uv run robotpy coverage test
+ /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python -m coverage run --source /Users/davidv/dev/frc/thedropbears/pyreefscape -m robotpy --main /Users/davidv/dev/frc/thedropbears/pyreefscape/robot.py test --coverage-mode
17:52:30:148 INFO    : faulthandler        : registered SIGUSR2 for PID 51812
[phoenix] CANbus Connected: sim
[phoenix] CANbus Network Up: sim
17:52:30:297 INFO    : test                : Isolated test mode not enabled, consider using it if your tests hang
17:52:30:297 INFO    : test                : - See 'robotpy test --help' for details
17:52:30:339 INFO    : pyfrc.physics       : Physics support successfully enabled
======================================= test session starts =======================================
platform darwin -- Python 3.13.2, pytest-8.3.3, pluggy-1.5.0 -- /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/Users/davidv/dev/frc/thedropbears/pyreefscape/.hypothesis/examples'))
rootdir: /Users/davidv/dev/frc/thedropbears/pyreefscape
configfile: pyproject.toml
testpaths: tests
plugins: integration-0.2.3, hypothesis-6.119.3, reraise-2.1.2, typeguard-4.3.0
collected 25 items

tests/pyfrc_test.py::test_disabled PASSED                                                   [  4%]
tests/pyfrc_test.py::test_operator_control PASSED                                           [  8%]
tests/test_caching.py::test_cache_per_loop PASSED                                           [ 12%]
tests/test_constrain_angle.py::test_happy PASSED                                            [ 16%]
tests/test_constrain_angle.py::test_all PASSED                                              [ 20%]
tests/test_constrain_angle.py::test_zero PASSED                                             [ 24%]
tests/test_constrain_angle.py::test_edge_pos PASSED                                         [ 28%]
tests/test_constrain_angle.py::test_edge_neg PASSED                                         [ 32%]
tests/test_constrain_angle.py::test_revolution_pos PASSED                                   [ 36%]
tests/test_constrain_angle.py::test_revolution_neg PASSED                                   [ 40%]
tests/test_constrain_angle.py::test_one_wrap_positive_half PASSED                           [ 44%]
tests/test_constrain_angle.py::test_one_wrap_negative_half PASSED                           [ 48%]
tests/test_functions.py::test_rate_limit2d PASSED                                           [ 52%]
tests/test_functions.py::test_rate_limit_2d_limit PASSED                                    [ 56%]
tests/test_functions.py::test_clamp2d_noconstrain PASSED                                    [ 60%]
tests/test_functions.py::test_clamp2d_constrain PASSED                                      [ 64%]
tests/test_scalers.py::test_deadzone PASSED                                                 [ 68%]
tests/test_scalers.py::test_deadzone_zero_threshold PASSED                                  [ 72%]
tests/test_scalers.py::test_exponential PASSED                                              [ 76%]
tests/test_scalers.py::test_scale_value PASSED                                              [ 80%]
tests/fuzz_test.py::test_fuzz[Blue2] PASSED                                                 [ 84%]
tests/fuzz_test.py::test_fuzz[Red1] PASSED                                                  [ 88%]
tests/fuzz_test.py::test_fuzz_test PASSED                                                   [ 92%]
tests/autonomous_test.py::test_all_autonomous[Red] PASSED                                   [ 96%]
tests/autonomous_test.py::test_all_autonomous[Blue] PASSED                                  [100%]

======================================= 25 passed in 23.38s =======================================
[phoenix-diagnostics] Server shutdown cleanly. (dur:0)

[phoenix] Library shutdown cleanly

Name                               Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------
autonomous/__init__.py                 0      0      0      0   100%
autonomous/auto_base.py               95     12     28      5    83%   51-53, 66->69, 87-88, 94-95, 112, 116->exit, 139-143
autonomous/multi_algae_auto.py        13      0      0      0   100%
components/__init__.py                 0      0      0      0   100%
components/ballistics.py              84      0     16      0   100%
components/chassis.py                265     12     28      6    94%   167, 173, 222, 377-378, 432, 465, 470, 473, 484, 490-491
components/climber.py                 67      5      4      2    90%   59, 62, 74, 97, 102
components/coral_depositor.py         19      0      0      0   100%
components/injector.py                61      0      6      0   100%
components/intake.py                  68      0      6      0   100%
components/led_component.py           99     30     16      0    67%   42-46, 65-68, 75-76, 80-116, 161-190
components/shooter.py                 69      1      0      0    99%   90
components/vision.py                 210     14     46      9    90%   252, 278, 290, 305->316, 316->281, 322, 332, 340, 355->325, 375, 393-394, 399-408
components/wrist.py                   90      1      4      1    98%   91
controllers/__init__.py                0      0      0      0   100%
controllers/algae_measurement.py      59      9     14      3    81%   24, 30->exit, 42-45, 72-86, 90-91
controllers/algae_shooter.py          53      3     12      2    92%   55-56, 76
controllers/climber.py                52      9     14      3    79%   28, 37-38, 51->56, 60-65
controllers/floor_intake.py           44      1     12      3    93%   49->58, 54, 58->exit
controllers/reef_intake.py            76      1     20      1    98%   93
ids.py                                47      0      0      0   100%
physics.py                           137      1     28      1    99%   295
robot.py                             208     24     66      4    87%   69-70, 96-126, 290, 310-328
tests/autonomous_test.py              11      0      0      0   100%
tests/fuzz_test.py                    89      1     14      0    99%   90
tests/pyfrc_test.py                    2      0      0      0   100%
tests/test_caching.py                 27      0      0      0   100%
tests/test_constrain_angle.py         27      0      0      0   100%
tests/test_functions.py               27      0      0      0   100%
tests/test_scalers.py                 41      0     10      0   100%
utilities/__init__.py                  0      0      0      0   100%
utilities/caching.py                  16      0      2      0   100%
utilities/ctre.py                      3      0      0      0   100%
utilities/functions.py                32      0      6      0   100%
utilities/game.py                     45      0      6      0   100%
utilities/position.py                  8      0      0      0   100%
utilities/rev.py                       9      0      0      0   100%
utilities/scalers.py                  19      1      2      0    95%   52
------------------------------------------------------------------------------
TOTAL                               2172    125    360     40    92%

> uv run robotpy coverage test --isolated
+ /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python -m coverage run --source /Users/davidv/dev/frc/thedropbears/pyreefscape -m robotpy --main /Users/davidv/dev/frc/thedropbears/pyreefscape/robot.py test --coverage-mode --isolated
17:53:03:394 INFO    : faulthandler        : registered SIGUSR2 for PID 51871
[phoenix] CANbus Connected: sim
[phoenix] CANbus Network Up: sim
======================================= test session starts =======================================
platform darwin -- Python 3.13.2, pytest-8.3.3, pluggy-1.5.0 -- /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/Users/davidv/dev/frc/thedropbears/pyreefscape/.hypothesis/examples'))
rootdir: /Users/davidv/dev/frc/thedropbears/pyreefscape
configfile: pyproject.toml
testpaths: tests
plugins: integration-0.2.3, hypothesis-6.119.3, reraise-2.1.2, typeguard-4.3.0
collected 25 items

tests/pyfrc_test.py::test_disabled PASSED                                                   [  4%]
tests/pyfrc_test.py::test_operator_control PASSED                                           [  8%]
tests/test_caching.py::test_cache_per_loop PASSED                                           [ 12%]
tests/test_constrain_angle.py::test_happy PASSED                                            [ 16%]
tests/test_constrain_angle.py::test_all PASSED                                              [ 20%]
tests/test_constrain_angle.py::test_zero PASSED                                             [ 24%]
tests/test_constrain_angle.py::test_edge_pos PASSED                                         [ 28%]
tests/test_constrain_angle.py::test_edge_neg PASSED                                         [ 32%]
tests/test_constrain_angle.py::test_revolution_pos PASSED                                   [ 36%]
tests/test_constrain_angle.py::test_revolution_neg PASSED                                   [ 40%]
tests/test_constrain_angle.py::test_one_wrap_positive_half PASSED                           [ 44%]
tests/test_constrain_angle.py::test_one_wrap_negative_half PASSED                           [ 48%]
tests/test_functions.py::test_rate_limit2d PASSED                                           [ 52%]
tests/test_functions.py::test_rate_limit_2d_limit PASSED                                    [ 56%]
tests/test_functions.py::test_clamp2d_noconstrain PASSED                                    [ 60%]
tests/test_functions.py::test_clamp2d_constrain PASSED                                      [ 64%]
tests/test_scalers.py::test_deadzone PASSED                                                 [ 68%]
tests/test_scalers.py::test_deadzone_zero_threshold PASSED                                  [ 72%]
tests/test_scalers.py::test_exponential PASSED                                              [ 76%]
tests/test_scalers.py::test_scale_value PASSED                                              [ 80%]
tests/fuzz_test.py::test_fuzz[Blue1] PASSED                                                 [ 84%]
tests/fuzz_test.py::test_fuzz[Red1] PASSED                                                  [ 88%]
tests/fuzz_test.py::test_fuzz_test PASSED                                                   [ 92%]
tests/autonomous_test.py::test_all_autonomous[Red] PASSED                                   [ 96%]
tests/autonomous_test.py::test_all_autonomous[Blue] PASSED                                  [100%]

======================================= 25 passed in 24.92s =======================================
[phoenix-diagnostics] Server shutdown cleanly. (dur:49)

[phoenix] Library shutdown cleanly

Name                               Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------
autonomous/__init__.py                 0      0      0      0   100%
autonomous/auto_base.py               95     53     28      0    34%   41-53, 59, 65-71, 74, 79, 83-117, 122-135, 139-143, 147-150
autonomous/multi_algae_auto.py        13     13      0      0     0%   1-38
components/__init__.py                 0      0      0      0   100%
components/ballistics.py              84     40     16      0    44%   67, 71-72, 78-89, 93-104, 108-129, 139-154, 179-186
components/chassis.py                265    175     28      0    31%   65-144, 148, 152, 156, 160, 163, 166-191, 196-197, 200, 203, 206, 209-216, 219-222, 252-333, 336, 340, 347, 356-367, 371-372, 377-378, 382, 386-387, 391, 395-396, 406-444, 452-454, 457-462, 465, 470, 473, 478-484, 487-491, 494-495, 498-502, 506-507, 514-517, 527, 536, 540, 544, 547-551, 554-557
components/climber.py                 67     36      4      0    44%   21-45, 52-53, 56, 59, 62, 65, 68, 71, 74, 78, 82, 86, 90, 96-102
components/coral_depositor.py         19      7      0      0    63%   12-13, 16, 19, 22, 25, 28
components/injector.py                61     38      6      0    34%   20-55, 59, 63, 66-67, 70, 73, 76, 82, 88-108
components/intake.py                  68     40      6      0    38%   32-72, 75-81, 84-86, 90, 93, 96, 99-100, 103-121, 124
components/led_component.py           99     71     16      0    24%   16, 21-35, 39, 42-46, 49-50, 53-54, 57-58, 61-62, 65-68, 71-72, 75-76, 80-116, 120, 123-153, 156-158, 161-190, 193-199
components/shooter.py                 69     37      0      0    46%   26-77, 81, 90, 95-96, 100, 108, 116, 122-123, 127, 131, 137-150
components/vision.py                 210    139     46      0    28%   97-152, 156, 160, 165, 169-181, 186-208, 213, 217, 220, 224, 227-242, 247, 252, 255-356, 360, 366, 372-389, 393-394, 399-408
components/wrist.py                   90     50      4      0    43%   33-70, 73-78, 81-85, 88-96, 100, 104, 108, 112, 116, 120, 123-128, 131, 134, 137-148
controllers/__init__.py                0      0      0      0   100%
controllers/algae_measurement.py      59     34     14      0    34%   17-21, 24, 28-31, 35-36, 40-47, 51-86, 90-91, 94-101, 110
controllers/algae_shooter.py          53     23     12      0    46%   31, 34-44, 48-66, 70-79, 82-83
controllers/climber.py                52     33     14      0    29%   17-18, 21, 24, 27-28, 32-56, 60-65, 68-70
controllers/floor_intake.py           44     22     12      0    39%   23, 26, 31-45, 49-59, 62-63
controllers/reef_intake.py            76     46     20      0    31%   30, 33, 37-38, 42-83, 87-106, 109-111
ids.py                                47      0      0      0   100%
physics.py                           137    137     28      0     0%   1-309
robot.py                             208    151     66      0    21%   62-162, 167-168, 175-237, 240, 243-295, 299-336, 339-342
tests/autonomous_test.py              11      4      0      0    64%   12-18
tests/fuzz_test.py                    89     59     14      0    31%   19, 24, 29, 36, 43-45, 52-53, 56-57, 62-66, 71-79, 90, 104-135, 139-154
tests/pyfrc_test.py                    2      0      0      0   100%
tests/test_caching.py                 27     25      0      0     7%   5-34
tests/test_constrain_angle.py         27      9      0      0    67%   13, 18, 22, 26, 30, 34, 38, 43, 48
tests/test_functions.py               27     13      0      0    52%   16-19, 29-31, 37-40, 45-47
tests/test_scalers.py                 41     27     10      0    27%   12-20, 25-28, 35-41, 55-63
utilities/__init__.py                  0      0      0      0   100%
utilities/caching.py                  16      5      2      0    61%   8-9, 26-28
utilities/ctre.py                      3      0      0      0   100%
utilities/functions.py                32     24      6      0    21%   9, 13, 20-29, 41-51, 58-62
utilities/game.py                     45     18      6      0    53%   50-58, 85, 89-105, 109
utilities/position.py                  8      0      0      0   100%
utilities/rev.py                       9      4      0      0    56%   6, 16, 36-37
utilities/scalers.py                  19     13      2      0    29%   9-12, 17-18, 30, 44-48, 52
------------------------------------------------------------------------------
TOTAL                               2172   1346    360      0    33%

> uv run robotpy coverage --parallel-mode test --isolated
+ /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python -m coverage run --source /Users/davidv/dev/frc/thedropbears/pyreefscape --parallel-mode -m robotpy --main /Users/davidv/dev/frc/thedropbears/pyreefscape/robot.py test --coverage-mode --isolated
17:53:44:358 INFO    : faulthandler        : registered SIGUSR2 for PID 52070
[phoenix] CANbus Connected: sim
[phoenix] CANbus Network Up: sim
======================================= test session starts =======================================
platform darwin -- Python 3.13.2, pytest-8.3.3, pluggy-1.5.0 -- /Users/davidv/dev/frc/thedropbears/pyreefscape/.venv/bin/python
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/Users/davidv/dev/frc/thedropbears/pyreefscape/.hypothesis/examples'))
rootdir: /Users/davidv/dev/frc/thedropbears/pyreefscape
configfile: pyproject.toml
testpaths: tests
plugins: integration-0.2.3, hypothesis-6.119.3, reraise-2.1.2, typeguard-4.3.0
collected 25 items

tests/pyfrc_test.py::test_disabled PASSED                                                   [  4%]
tests/pyfrc_test.py::test_operator_control PASSED                                           [  8%]
tests/test_caching.py::test_cache_per_loop PASSED                                           [ 12%]
tests/test_constrain_angle.py::test_happy PASSED                                            [ 16%]
tests/test_constrain_angle.py::test_all PASSED                                              [ 20%]
tests/test_constrain_angle.py::test_zero PASSED                                             [ 24%]
tests/test_constrain_angle.py::test_edge_pos PASSED                                         [ 28%]
tests/test_constrain_angle.py::test_edge_neg PASSED                                         [ 32%]
tests/test_constrain_angle.py::test_revolution_pos PASSED                                   [ 36%]
tests/test_constrain_angle.py::test_revolution_neg PASSED                                   [ 40%]
tests/test_constrain_angle.py::test_one_wrap_positive_half PASSED                           [ 44%]
tests/test_constrain_angle.py::test_one_wrap_negative_half PASSED                           [ 48%]
tests/test_functions.py::test_rate_limit2d PASSED                                           [ 52%]
tests/test_functions.py::test_rate_limit_2d_limit PASSED                                    [ 56%]
tests/test_functions.py::test_clamp2d_noconstrain PASSED                                    [ 60%]
tests/test_functions.py::test_clamp2d_constrain PASSED                                      [ 64%]
tests/test_scalers.py::test_deadzone PASSED                                                 [ 68%]
tests/test_scalers.py::test_deadzone_zero_threshold PASSED                                  [ 72%]
tests/test_scalers.py::test_exponential PASSED                                              [ 76%]
tests/test_scalers.py::test_scale_value PASSED                                              [ 80%]
tests/fuzz_test.py::test_fuzz[Blue3] PASSED                                                 [ 84%]
tests/fuzz_test.py::test_fuzz[Red1] PASSED                                                  [ 88%]
tests/fuzz_test.py::test_fuzz_test PASSED                                                   [ 92%]
tests/autonomous_test.py::test_all_autonomous[Red] PASSED                                   [ 96%]
tests/autonomous_test.py::test_all_autonomous[Blue] PASSED                                  [100%]

======================================= 25 passed in 25.29s =======================================
[phoenix-diagnostics] Server shutdown cleanly. (dur:65)

[phoenix] Library shutdown cleanly

Combined data file .coverage.Davos-MacBook-Pro.local.52070.XzAmgSax
Name                               Stmts   Miss Branch BrPart  Cover   Missing
------------------------------------------------------------------------------
autonomous/__init__.py                 0      0      0      0   100%
autonomous/auto_base.py               95     53     28      0    34%   41-53, 59, 65-71, 74, 79, 83-117, 122-135, 139-143, 147-150
autonomous/multi_algae_auto.py        13     13      0      0     0%   1-38
components/__init__.py                 0      0      0      0   100%
components/ballistics.py              84     40     16      0    44%   67, 71-72, 78-89, 93-104, 108-129, 139-154, 179-186
components/chassis.py                265    175     28      0    31%   65-144, 148, 152, 156, 160, 163, 166-191, 196-197, 200, 203, 206, 209-216, 219-222, 252-333, 336, 340, 347, 356-367, 371-372, 377-378, 382, 386-387, 391, 395-396, 406-444, 452-454, 457-462, 465, 470, 473, 478-484, 487-491, 494-495, 498-502, 506-507, 514-517, 527, 536, 540, 544, 547-551, 554-557
components/climber.py                 67     36      4      0    44%   21-45, 52-53, 56, 59, 62, 65, 68, 71, 74, 78, 82, 86, 90, 96-102
components/coral_depositor.py         19      7      0      0    63%   12-13, 16, 19, 22, 25, 28
components/injector.py                61     38      6      0    34%   20-55, 59, 63, 66-67, 70, 73, 76, 82, 88-108
components/intake.py                  68     40      6      0    38%   32-72, 75-81, 84-86, 90, 93, 96, 99-100, 103-121, 124
components/led_component.py           99     71     16      0    24%   16, 21-35, 39, 42-46, 49-50, 53-54, 57-58, 61-62, 65-68, 71-72, 75-76, 80-116, 120, 123-153, 156-158, 161-190, 193-199
components/shooter.py                 69     37      0      0    46%   26-77, 81, 90, 95-96, 100, 108, 116, 122-123, 127, 131, 137-150
components/vision.py                 210    139     46      0    28%   97-152, 156, 160, 165, 169-181, 186-208, 213, 217, 220, 224, 227-242, 247, 252, 255-356, 360, 366, 372-389, 393-394, 399-408
components/wrist.py                   90     50      4      0    43%   33-70, 73-78, 81-85, 88-96, 100, 104, 108, 112, 116, 120, 123-128, 131, 134, 137-148
controllers/__init__.py                0      0      0      0   100%
controllers/algae_measurement.py      59     34     14      0    34%   17-21, 24, 28-31, 35-36, 40-47, 51-86, 90-91, 94-101, 110
controllers/algae_shooter.py          53     23     12      0    46%   31, 34-44, 48-66, 70-79, 82-83
controllers/climber.py                52     33     14      0    29%   17-18, 21, 24, 27-28, 32-56, 60-65, 68-70
controllers/floor_intake.py           44     22     12      0    39%   23, 26, 31-45, 49-59, 62-63
controllers/reef_intake.py            76     46     20      0    31%   30, 33, 37-38, 42-83, 87-106, 109-111
ids.py                                47      0      0      0   100%
physics.py                           137    137     28      0     0%   1-309
robot.py                             208    151     66      0    21%   62-162, 167-168, 175-237, 240, 243-295, 299-336, 339-342
tests/autonomous_test.py              11      4      0      0    64%   12-18
tests/fuzz_test.py                    89     59     14      0    31%   19, 24, 29, 36, 43-45, 52-53, 56-57, 62-66, 71-79, 90, 104-135, 139-154
tests/pyfrc_test.py                    2      0      0      0   100%
tests/test_caching.py                 27     25      0      0     7%   5-34
tests/test_constrain_angle.py         27      9      0      0    67%   13, 18, 22, 26, 30, 34, 38, 43, 48
tests/test_functions.py               27     13      0      0    52%   16-19, 29-31, 37-40, 45-47
tests/test_scalers.py                 41     27     10      0    27%   12-20, 25-28, 35-41, 55-63
utilities/__init__.py                  0      0      0      0   100%
utilities/caching.py                  16      5      2      0    61%   8-9, 26-28
utilities/ctre.py                      3      0      0      0   100%
utilities/functions.py                32     24      6      0    21%   9, 13, 20-29, 41-51, 58-62
utilities/game.py                     45     18      6      0    53%   50-58, 85, 89-105, 109
utilities/position.py                  8      0      0      0   100%
utilities/rev.py                       9      4      0      0    56%   6, 16, 36-37
utilities/scalers.py                  19     13      2      0    29%   9-12, 17-18, 30, 44-48, 52
------------------------------------------------------------------------------
TOTAL                               2172   1346    360      0    33%

Operating System

MacOS

Installed Python Packages

Package                  Version
------------------------ ----------
attrs                    24.2.0
bcrypt                   4.2.0
cffi                     1.17.1
coverage                 7.6.12
cryptography             43.0.3
flexcache                0.3
flexparser               0.4
hypothesis               6.119.3
iniconfig                2.0.0
mypy                     1.13.0
mypy-extensions          1.0.0
numpy                    2.2.1
opencv-python            4.10.0.84
packaging                23.2
paramiko                 3.5.0
phoenix6                 25.1.0
photonlibpy              2025.1.1
pint                     0.24.4
pip                      24.3.1
platformdirs             4.3.6
pluggy                   1.5.0
pycparser                2.22
pyfrc                    2025.1.0
pynacl                   1.5.0
pynetconsole             2.0.4
pyntcore                 2025.3.1.0
pytest                   8.3.3
pytest-integration       0.2.3
pytest-reraise           2.1.2
robotpy                  2025.3.1.0
robotpy-apriltag         2025.3.1.0
robotpy-cli              2024.0.0
robotpy-cscore           2025.3.1.0
robotpy-ctre             2025.0.0
robotpy-hal              2025.3.1.0
robotpy-halsim-gui       2025.3.1.0
robotpy-installer        2025.0.3
robotpy-rev              2025.0.1
robotpy-wpilib-utilities 2025.0.0
robotpy-wpimath          2025.3.1.0
robotpy-wpinet           2025.3.1.0
robotpy-wpiutil          2025.3.1.0
setuptools               75.5.0
sleipnirgroup-choreolib  2025.0.2
sortedcontainers         2.4.0
tomli                    2.1.0
tomlkit                  0.13.2
typing-extensions        4.12.2
wpilib                   2025.3.1.0

Reproducible example code

https://github.com/thedropbears/pyreefscape/tree/cbded011443dd885ddfcb04169d162c34595c99b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions