incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject git commit: [#7047] Fixed substitute_extensions not switching back on exception
Date Fri, 24 Jan 2014 16:52:33 GMT
Updated Branches:
  refs/heads/master 3f90515ee -> 3745c29cb


[#7047] Fixed substitute_extensions not switching back on exception

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


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

Branch: refs/heads/master
Commit: 3745c29cbef98ab7a37ad8ef1cc6c8270ac0bf2f
Parents: 3f90515
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Fri Jan 24 16:39:34 2014 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Fri Jan 24 16:52:16 2014 +0000

----------------------------------------------------------------------
 Allura/allura/model/session.py           |  6 ++++--
 Allura/allura/tests/unit/test_session.py | 12 +++++++-----
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3745c29c/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 82973ce..77f8645 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -222,8 +222,10 @@ def substitute_extensions(session, extensions=None):
         session.close()
         session._kwargs['extensions'] = exts
     _set_exts(extensions or [])
-    yield session
-    _set_exts(original_exts)
+    try:
+        yield session
+    finally:
+        _set_exts(original_exts)
 
 
 main_doc_session = Session.by_name('main')

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/3745c29c/Allura/allura/tests/unit/test_session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_session.py b/Allura/allura/tests/unit/test_session.py
index b079004..a5fb080 100644
--- a/Allura/allura/tests/unit/test_session.py
+++ b/Allura/allura/tests/unit/test_session.py
@@ -27,11 +27,13 @@ from allura.model.session import BatchIndexer, substitute_extensions
 def test_extensions_cm():
     session = mock.Mock(_kwargs=dict(extensions=[]))
     extension = mock.Mock()
-    with substitute_extensions(session, [extension]) as sess:
-        assert session.flush.call_count == 1
-        assert session.close.call_count == 1
-        assert sess == session
-        assert sess._kwargs['extensions'] == [extension]
+    with td.raises(ValueError):
+        with substitute_extensions(session, [extension]) as sess:
+            assert session.flush.call_count == 1
+            assert session.close.call_count == 1
+            assert sess == session
+            assert sess._kwargs['extensions'] == [extension]
+            raise ValueError('test')
     assert session.flush.call_count == 2
     assert session.close.call_count == 2
     assert session._kwargs['extensions'] == []


Mime
View raw message