Mercurial > summit-idp
view tests/test_locking.py @ 62:50297a64414c
Added locking.py for super non-grannular thread safety, and more tests.
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Tue, 29 Jun 2010 11:17:34 -0700 |
parents | |
children |
line wrap: on
line source
from summitidp import locking def fake_start_response(*args, **kwargs): pass class FakeException(Exception): pass def test_synced_app_works_consecutively(): @locking.synced_app def myapp(environ, start_response): assert start_response == fake_start_response assert isinstance(environ, dict) return [] assert myapp({}, fake_start_response) == [] assert myapp({}, fake_start_response) == [] def test_synced_app_throws_exception(): @locking.synced_app def myapp(environ, start_response): assert start_response == fake_start_response assert isinstance(environ, dict) raise FakeException() try: myapp({}, fake_start_response) raise Exception("exception should have been raised!") except FakeException: pass # Ensure the lock was released when the exception was thrown. try: myapp({}, fake_start_response) raise Exception("exception should have been raised!") except FakeException: pass