Ensure that unit tests can be executed under version of Windows different than the one used for building NVDA (#12835)
Fixes regression from #12617. Discovered when working on #12753 as that PR required executing unit tests under various versions of Windows
Summary of the issue:
It is sometimes useful to execute unit tests under various versions of Windows where it is impractical, or even impossible to have full build environment for NVDA. With current master some tests are failing because when importing COM interfaces comtypes complains about them being created on different version of Windows. Before PR #12617 this worked by chance since our monkey patches for compypes were applied when importing core and it just so happened that core was imported before any COM interface was.
Description of how this pull request fixes the issue:
Since we have monkey patch which stops comtypes from complaining about typelib being different than COM interface it has been applied to comtypes before tests starts. To avoid copying code of this monkey patch it was necessary to refactor our monkey patches to make each of them into a separate function - that allows us to apply them selectively rather than just all of them during import.
Testing strategy:
Ensured that unit tests pass under a never version of Windows than the one under which virtual environment for NVDA has been created
Ensured that comtypes monkey patches are properly applied for NVDA in particular that core.CallCancelled is raised when appropriate.