monitors decorator does not fully copy the specification of the monitored phase
- Dominant language
- Python
- Stars
- 722
- Forks
- 237
- Avg merge
- 11h 31m
- Merged PRs (30d)
- 4
Description
`monitor` in `monitors.py` does not copy the specification of the phase being monitored, leading to bugs like #1096 . What's happening in that specific bug is that, `monitored_phase_func` calls the monitored phase using the test state, thus bypassing the plug registration scheme. So, if the phase needs a plug that isn't registered by another phase, the plug lookup will fail with a `KeyError`.
Repro example:
```
import openhtf as htf
class NoOpPlug(htf.plugs.BasePlug):
"""Does nothing."""
def monitor_one(test, *args, **kwargs):
del test # Unused.
return 1
@htf.monitors('f_measurement', monitor_one, poll_interval_ms=100)
@htf.plug(noop=NoOpPlug)
def buggy_monitoring(test, *args, **kwargs):
del test
def main():
test = htf.Test(buggy_monitoring)
test.execute(test_start=lambda: 'MyDutId')
if __name__ == '__main__':
main()
```
This particular issue can be fixed by copying over the plugs e.g. in `def monitors`:
```
own_plugs = {p.name: p.cls for p in phase_desc.plugs}
...
@plugs.plug(update_kwargs=False, **monitor_plugs, **own_plugs)
```
But it's not addressing the root of the problem as described earlier.
Contributor guide
Assessment
This issue has not been assessed yet.