You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2013/08/23 00:25:12 UTC

git commit: [#3154] fix test; behavior changed due to more immediate error raising in monqtask during tests

Updated Branches:
  refs/heads/master d91d964e2 -> 0fb6390f1


[#3154] fix test; behavior changed due to more immediate error raising in monqtask during tests


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

Branch: refs/heads/master
Commit: 0fb6390f19fdfeff5ac51864f7070f8507e1037b
Parents: d91d964
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Aug 22 22:21:57 2013 +0000
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Thu Aug 22 22:21:57 2013 +0000

----------------------------------------------------------------------
 Allura/allura/tests/decorators.py    | 9 +++++++--
 Allura/allura/tests/test_commands.py | 7 +++----
 2 files changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0fb6390f/Allura/allura/tests/decorators.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/decorators.py b/Allura/allura/tests/decorators.py
index 8c9e4c9..dd9fdf1 100644
--- a/Allura/allura/tests/decorators.py
+++ b/Allura/allura/tests/decorators.py
@@ -87,16 +87,21 @@ with_wiki = with_tool('test', 'Wiki', 'wiki')
 with_url = with_tool('test', 'ShortUrl', 'url')
 
 class raises(object):
-    'test helper in the form of a context manager, to assert that something raises an exception'
+    '''
+    Test helper in the form of a context manager, to assert that something raises an exception.
+    After completion, the 'exc' attribute can be used to do further inspection of the exception
+    '''
 
     def __init__(self, ExcType):
         self.ExcType = ExcType
+        self.exc = None
 
     def __enter__(self):
-        pass
+        return self
 
     def __exit__(self, exc_type, exc_val, exc_t):
         if exc_type:
+            self.exc = exc_val
             if issubclass(exc_type, self.ExcType):
                 # ok
                 return True

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0fb6390f/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 09dc3b6..b290380 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -344,10 +344,9 @@ class TestBackgroundCommand(object):
     def test_invalid_args(self):
         M.MonQTask.query.remove()
         show_models.ReindexCommand.post('--invalid-option')
-        M.MonQTask.run_ready()
-        task = M.MonQTask.query.get(task_name=self.task_name)
-        assert_equal(task.state, 'error')
-        assert_in('Error parsing args', task.result)
+        with td.raises(Exception) as e:
+            M.MonQTask.run_ready()
+        assert_in('Error parsing args', str(e.exc))
 
 
 class TestReindexCommand(object):