Skip to content

Commit

Permalink
Python 3 fixups.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbangert committed Aug 13, 2012
1 parent 58f4a2c commit 7d4d055
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions beaker/session.py
Expand Up @@ -683,6 +683,9 @@ def __iter__(self):
def __contains__(self, key):
return key in self._session()

def has_key(self, key):
return key in self._session()

def get_by_id(self, id):
"""Loads a session given a session ID"""
params = self.__dict__['_params']
Expand Down
4 changes: 2 additions & 2 deletions tests/test_increment.py
Expand Up @@ -28,7 +28,7 @@ def simple_app(environ, start_response):
if not session:
start_response('200 OK', [('Content-type', 'text/plain')])
return ["No session id of %s found." % sess_id]
if not session.has_key('value'):
if not 'value' in session:
session['value'] = 0
session['value'] += 1
if not environ['PATH_INFO'].startswith('/nosave'):
Expand All @@ -46,7 +46,7 @@ def simple_auto_app(environ, start_response):
if not session:
start_response('200 OK', [('Content-type', 'text/plain')])
return ["No session id of %s found." % sess_id]
if not session.has_key('value'):
if not 'value' in session:
session['value'] = 0
session['value'] += 1
if environ['PATH_INFO'].startswith('/nosave'):
Expand Down
18 changes: 9 additions & 9 deletions tests/test_namespacing_files/namespace_go.py
@@ -1,5 +1,7 @@
from __future__ import print_function
import time


def go():
import namespace_get
a = namespace_get.get_cached_value()
Expand All @@ -13,13 +15,11 @@ def go():
time.sleep(0.3)
d = test_namespacing_files.namespace_get.get_cached_value()

print a
print b
print c
print d

assert a==b, 'Basic caching problem - should never happen'
assert c==d, 'Basic caching problem - should never happen'
assert a==c, 'Namespaces not consistent when using different import paths'

print(a)
print(b)
print(c)
print(d)

assert a == b, 'Basic caching problem - should never happen'
assert c == d, 'Basic caching problem - should never happen'
assert a == c, 'Namespaces not consistent when using different import paths'

0 comments on commit 7d4d055

Please sign in to comment.