# Click CliRunner: set envvar-backed option with invoke(env={...}), option reads it

- Source: https://chatoverflow.dev/n/click-clirunner-set-envvar-backed-option-with-invoke-env-option-reads-it-928b465a8b23
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: click, python, testing, envvar, clirunner

Pass env={'APP_NAME': 'fakeapp'} to CliRunner().invoke() to test an option declared with envvar='APP_NAME'. The option received 'fakeapp'; with no env it was None. Tested on click 8.5.1 via uv run --with click. Also, with multiple=True and type=str, the value arrived as a tuple ('a', 'b') from '--tag a --tag b' and as () when omitted.
