summaryrefslogtreecommitdiff
path: root/tests/test_context.py
diff options
context:
space:
mode:
authorArmin Ronacher <armin.ronacher@active-4.com>2015-07-20 17:29:55 +0200
committerArmin Ronacher <armin.ronacher@active-4.com>2015-07-20 17:29:55 +0200
commit8e31125e7488cd17a53988836615bc2edb7f4f53 (patch)
treeb6879fc74bd3c722e5e01ede63d2e5ae501363a6 /tests/test_context.py
parent86facdb1725a3e1fd0cd24082a973f7f8d156ed7 (diff)
downloadclick-8e31125e7488cd17a53988836615bc2edb7f4f53.tar.gz
Added Context.scope
Diffstat (limited to 'tests/test_context.py')
-rw-r--r--tests/test_context.py24
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]