From a7d03b609833bd5b70e6befa779f2a133e589e78 Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Sun, 3 Nov 2019 23:07:24 +0100 Subject: [PATCH] Few changes based on Cement boss template --- wo/cli/main.py | 18 ++++++++++-------- wo/utils/test.py | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/wo/cli/main.py b/wo/cli/main.py index fc80c05..06c247c 100644 --- a/wo/cli/main.py +++ b/wo/cli/main.py @@ -49,15 +49,12 @@ class WOApp(CementApp): # All built-in application bootstrapping (always run) bootstrap = 'wo.cli.bootstrap' - # Optional plugin bootstrapping (only run if plugin is enabled) + # Internal plugins (ship with application code) plugin_bootstrap = 'wo.cli.plugins' # Internal templates (ship with application code) template_module = 'wo.cli.templates' - # Internal plugins (ship with application code) - plugin_bootstrap = 'wo.cli.plugins' - extensions = ['mustache'] # default output handler @@ -73,18 +70,23 @@ class WOApp(CementApp): class WOTestApp(WOApp): """A test app that is better suited for testing.""" class Meta: + # default argv to empty (don't use sys.argv) argv = [] + + # don't look for config files (could break tests) config_files = [] - exit_on_close = True + + # don't call sys.exit() when app.close() is called in tests + exit_on_close = False # Define the applicaiton object outside of main, as some libraries might wish # to import it as a global (rather than passing it into another class/func) -# app = WOApp() +app = WOApp() def main(): - with WOApp() as app: + with app: try: global sys @@ -99,7 +101,7 @@ def main(): app.exit_code = 1 except exc.WOError as e: # Catch our application errors and exit 1 (error) - print(e) + print('WOError > %s' % e) app.exit_code = 1 except FrameworkError as e: # Catch framework errors and exit 1 (error) diff --git a/wo/utils/test.py b/wo/utils/test.py index d737fdd..920fd62 100644 --- a/wo/utils/test.py +++ b/wo/utils/test.py @@ -1,5 +1,5 @@ """Testing utilities for WordOps""" -from cement.utils.test import CementTestCase +from cement.utils.test import * from wo.cli.main import WOTestApp