diff options
| author | RamiC <olokki@gmail.com> | 2015-10-28 21:38:22 +0200 |
|---|---|---|
| committer | RamiC <olokki@gmail.com> | 2015-10-28 21:47:46 +0200 |
| commit | 67ff3b9ce4bcaceeee90f2aa4ae900d9220cac8b (patch) | |
| tree | d8df9742eab0249c6e673ce0f0b089f69d0e420b | |
| parent | 4429b543d97712dbec1ce10e3489385ff16a3639 (diff) | |
| download | pyramid-67ff3b9ce4bcaceeee90f2aa4ae900d9220cac8b.tar.gz pyramid-67ff3b9ce4bcaceeee90f2aa4ae900d9220cac8b.tar.bz2 pyramid-67ff3b9ce4bcaceeee90f2aa4ae900d9220cac8b.zip | |
Convert timeout argument to int values when applicable
| -rw-r--r-- | CONTRIBUTORS.txt | 2 | ||||
| -rw-r--r-- | pyramid/session.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_session.py | 16 |
3 files changed, 19 insertions, 1 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 2ef07af75..4edf1b4e9 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -254,3 +254,5 @@ Contributors - Jesse Dhillon, 2015/10/07 - Amos Latteier, 2015/10/22 + +- Rami Chousein, 2015/10/28 diff --git a/pyramid/session.py b/pyramid/session.py index c4cfc1949..525636688 100644 --- a/pyramid/session.py +++ b/pyramid/session.py @@ -244,7 +244,7 @@ def BaseCookieSessionFactory( _cookie_secure = secure _cookie_httponly = httponly _cookie_on_exception = set_on_exception - _timeout = timeout + _timeout = timeout if timeout is None else int(timeout) _reissue_time = reissue_time # dirty flag diff --git a/pyramid/tests/test_session.py b/pyramid/tests/test_session.py index eac6593d9..c3a1f3055 100644 --- a/pyramid/tests/test_session.py +++ b/pyramid/tests/test_session.py @@ -62,6 +62,22 @@ class SharedCookieSessionTests(object): session = self._makeOne(request, timeout=None) self.assertEqual(dict(session), {'state': 1}) + def test_timeout_str(self): + import time + request = testing.DummyRequest() + cookieval = self._serialize((time.time() - 5, 0, {'state': 1})) + request.cookies['session'] = cookieval + session = self._makeOne(request, timeout='1') + self.assertEqual(dict(session), {}) + + def test_timeout_invalid(self): + import time + request = testing.DummyRequest() + cookieval = self._serialize((time.time() - 5, 0, {'state': 1})) + request.cookies['session'] = cookieval + self.assertRaises(ValueError, self._makeOne, request, timeout='error') + + def test_changed(self): request = testing.DummyRequest() session = self._makeOne(request) |
