Re: Proposal/research: compatibility mode for add-ons

Noelia Ruiz

Hi Alberto:

This PR contains the mentioned unit tests. The relationship with your
proposal may not be obvious, but an add-on or other kind of helpeer
maybe used to search common sentences used to import code in all
modules contained in a folder.
For example, some kind of json file maybe included in NVDA or in
anadd-on with deprecations or removed modules, and this maybe used by
third party application. I use just git grep for now, and the changes
for developers.

In my PR for the cursorLocator add-on, unittests are used to import
the utils module contained in the add-on, and MagicMock class is used
to simulate the config module, since the add-on itself doesn't contain
it but it's used by utils, so, if MagicMoc is not used, tests fail.
Then, some tests cases are designed, for example, providing
preconditions like:
config.conf["cursorLocator"]["maxStartNotificationNumber"+ is 1. Then,
the utils.shouldReportStartOfLine(text) function will return True and
this is evaluated.
Just an example. See the tests folder on this PR for more info:

2022-05-08 15:05 GMT+02:00, Alberto Buffolino <a.buffolino@...>:

Noelia Ruiz, il 8/5/2022, ha scritto:
Now I'm working
including unit tests for an add-on (very simple tests and just for a
Python module recently included, not posted on GitHub for now), and
results are satisfactory.
Hi Noelia,
I don't practically nothing about unit test, that is, its powers and
extendibility. Hope to see something soon! :)
Anyway, about complexity of catching all cases, there obviously could be
various mechanisms included: if an add-on fails or will fail on absolute
imports (Python and NVDA core modules), for example, I think it may
safely disabled (and for this task AST static analysis seems to perform
quite well, if we can compare its results with a list of deprecated
modules and do not want to wait an exception in a potential dangerous
situation); if this stage passes, then other techniques are required...
About an add-on encapsulating all of this... I'll think, it's not the
solution, clearly, but could be feasible at least as helper tool.

Join to automatically receive all group messages.