teemtee / tmt

Test Management Tool
MIT License
79 stars 117 forks source link

Expose CLI invocation reset #2903

Open LecrisUT opened 2 months ago

LecrisUT commented 2 months ago

I've found that in order to test tmt click command, we need to reset the cli invocation as: https://github.com/teemtee/tmt/blob/78742f93789da5bbc13db3713cd6de3e8f744443/tests/__init__.py#L8-L29

For external plugin support it would be good to expose this function in tmt.utils or have a generic tmt.testing to simplify writing tests. I can try to gather some more ideas for the latter as I stumble upon them if that is the preferred approach. So far I have:

LecrisUT commented 2 months ago

Actually a mock for Command.run would really be useful. I've been trying with flexmock, unittest.mock and pytest-subprocess. So far unsuccessful