incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#7225] allow these tests to be run from any dir
Date Thu, 27 Feb 2014 22:30:03 GMT
Repository: incubator-allura
Updated Branches:
  refs/heads/db/7225 3024eda61 -> 5b1068d80


[#7225] allow these tests to be run from any dir


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5b1068d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5b1068d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5b1068d8

Branch: refs/heads/db/7225
Commit: 5b1068d808199c565215c46127fd90307db108bd
Parents: 3024eda
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Thu Feb 27 22:29:45 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Feb 27 22:29:45 2014 +0000

----------------------------------------------------------------------
 .../tests/templates/jinja_master/test_lib.py    |  2 ++
 AlluraTest/alluratest/controller.py             | 23 +++++++++++++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5b1068d8/Allura/allura/tests/templates/jinja_master/test_lib.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/templates/jinja_master/test_lib.py b/Allura/allura/tests/templates/jinja_master/test_lib.py
index 5d3e963..4979b99 100644
--- a/Allura/allura/tests/templates/jinja_master/test_lib.py
+++ b/Allura/allura/tests/templates/jinja_master/test_lib.py
@@ -20,6 +20,7 @@ from mock import Mock
 from nose.tools import assert_equal
 
 from allura.config.app_cfg import ForgeConfig
+from alluratest.controller import setup_config_test
 
 
 def strip_space(s):
@@ -28,6 +29,7 @@ def strip_space(s):
 
 class TemplateTest(object):
     def setUp(self):
+        setup_config_test()
         forge_config = ForgeConfig()
         forge_config.setup_jinja_renderer()
         self.jinja2_env = config['pylons.app_globals'].jinja2_env

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5b1068d8/AlluraTest/alluratest/controller.py
----------------------------------------------------------------------
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 5e81b37..7c772ed 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -27,6 +27,7 @@ from paste.deploy.converters import asbool
 from paste.script.appinstall import SetupCommand
 from pylons import tmpl_context as c, app_globals as g
 from pylons import url, request, response, session
+import pylons
 import tg
 from webob import Response, Request
 import ew
@@ -60,8 +61,28 @@ def get_config_file(config=None):
     return os.path.join(conf_dir, config)
 
 
+def setup_config_test(config_file=None, force=False):
+    '''
+    This may be necessary to use within test setup that needs the app config loaded,
+    especially so that the tests can be run from any directory.
+    When run from the ./Allura/ dir, the setup.cfg file there causes a pylons plugin
+    for nose to run, which runs `loadapp` (among other things).
+    This function lets a test run from any directory.
+    '''
+    if not config_file:
+        config_file = get_config_file()
+    already_loaded = pylons.config.get('pylons.app_globals')
+    if not already_loaded or force:
+        loadapp('config:' + config_file)
+setup_config_test.__test__ = False
+
+
 def setup_basic_test(config=None, app_name=DFL_APP_NAME):
-    '''Create clean environment for running tests'''
+    '''
+    Create clean environment for running tests.
+
+    A lightweight alternative is setup_config_test which doesn't bootstrap app data.
+    '''
     try:
         conf_dir = tg.config.here
     except AttributeError:


Mime
View raw message