You are viewing the documentation for a prerelease version. View Latest

nvda.addons

Two-phase install, remove, and state — install and remove only take effect after NVDA restarts, matching how NVDA itself behaves outside tests.

@pytest.mark.fresh_nvda
def test_install_is_two_phase_and_completes_on_restart(
    nvda, built_demo_addon, assert_no_unexpected_errors
):
    assert nvda.addons.state("testkit-demo") is AddonState.NOT_INSTALLED

    info = nvda.addons.install(built_demo_addon)
    assert info.name == "testkit-demo"
    assert nvda.addons.state("testkit-demo") is AddonState.PENDING_INSTALL

    nvda.restart_harness()
    assert nvda.addons.state("testkit-demo") is AddonState.ENABLED
    assert_no_unexpected_errors(nvda)

    nvda.addons.remove("testkit-demo")
    nvda.restart_harness()
    assert nvda.addons.state("testkit-demo") is AddonState.NOT_INSTALLED
AddonState Meaning

NOT_INSTALLED

no trace of the add-on

PENDING_INSTALL

installed, waiting for the restart that enables it

ENABLED

installed and running

DISABLED

installed but turned off

PENDING_REMOVE

marked for removal, waiting for the restart that completes it

INCOMPATIBLE

installed, but NVDA refuses to enable it

Most tests don’t need this directly — the addon_under_test fixture already does the install-and-restart dance for you. Reach for nvda.addons yourself only when a test is about the install/remove lifecycle itself.