Skip to content

Commit b035e7c

Browse files
committed
fix break in CLI test context usage
1 parent de8b450 commit b035e7c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

keg/testing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,14 @@ class CLIBase(object):
187187
# child classes will need to set these values in order to use the class
188188
app_cls = None
189189
cmd_name = None
190+
force_app_context_cleanup = False
190191

191192
@classmethod
192193
def setup_class(cls):
193194
# If a current app context is set, it may complicate what click is doing to
194195
# set up and run a specific app.
195-
cleanup_app_contexts()
196+
if cls.app_cls or cls.force_app_context_cleanup:
197+
cleanup_app_contexts()
196198

197199
cls.runner = click.testing.CliRunner()
198200

keg/tests/test_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ def test_default_exception_handling(self):
8282

8383

8484
class TestCLI2(CLIBase):
85+
# We don't set an app_cls (see below), but we do want any current app context cleaned
86+
# up before constructing a new one.
87+
force_app_context_cleanup = True
8588

8689
@classmethod
8790
def setup_class(cls):

0 commit comments

Comments
 (0)