|
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.config
Reading and writing NVDA’s configuration, so a test can set up the exact state your add-on’s code path depends on.
def test_config_round_trips_through_a_real_nvda(nvda):
original = nvda.config.get(("speech", "synth"))
assert isinstance(original, str)
snapshot = nvda.config.snapshot()
assert "speech" in snapshot
snapshot() and restore() let a test change configuration for the duration of one test and
put it back afterwards, without needing to know every key it touched:
def test_something_under_a_changed_setting(nvda):
snapshot = nvda.config.snapshot()
try:
nvda.config.set(("speech", "symbolLevel"), "all")
...
finally:
nvda.config.restore(snapshot)