This version is still in development and is not considered stable yet. For the latest stable version, please use nvda-addon-testkit 2.x!

nvda.addons

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

built_demo_addon and assert_no_unexpected_errors are fixtures defined in this repository’s tests_e2e/conftest.py, not shipped by the plugin. Define your own equivalents (a fixture that builds your bundle, and one that calls nvda.log.assert_no_errors() after filtering the runner-environment errors your CI host produces), or drop them.

@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.