diff options
Diffstat (limited to 'tests/test_context.py')
-rw-r--r-- | tests/test_context.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_context.py b/tests/test_context.py index 961f6eb..199fb64 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -142,3 +142,27 @@ def test_context_meta(runner): assert get_language() == 'de_DE' runner.invoke(cli, [], catch_exceptions=False) + + +def test_context_pushing(): + rv = [] + + @click.command() + def cli(): + pass + + ctx = click.Context(cli) + + @ctx.call_on_close + def test_callback(): + rv.append(42) + + with ctx.scope(cleanup=False): + pass + + assert rv == [] + + with ctx.scope(): + pass + + assert rv == [42] |