mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
__init__.py: keep it compatible with older python (True and False == 1 and 0)
test_basics.py: updated for the set_get_returns_none() default of 2 change.
This commit is contained in:
parent
2fb702966c
commit
e33aef7b15
2 changed files with 17 additions and 6 deletions
|
|
@ -184,7 +184,7 @@ def _checkCursor(self):
|
|||
# BerkeleyDB deadlocks (due to being opened with DB_INIT_LOCK
|
||||
# and DB_THREAD to be thread safe) when intermixing database
|
||||
# operations that use the cursor internally with those that don't.
|
||||
def _closeCursors(self, save=True):
|
||||
def _closeCursors(self, save=1):
|
||||
if self.dbc:
|
||||
c = self.dbc
|
||||
self.dbc = None
|
||||
|
|
@ -223,7 +223,7 @@ def __delitem__(self, key):
|
|||
del self.db[key]
|
||||
|
||||
def close(self):
|
||||
self._closeCursors(save=False)
|
||||
self._closeCursors(save=0)
|
||||
if self.dbc is not None:
|
||||
self.dbc.close()
|
||||
v = 0
|
||||
|
|
|
|||
|
|
@ -290,7 +290,7 @@ def test02_DictionaryMethods(self):
|
|||
|
||||
#----------------------------------------
|
||||
|
||||
def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=1):
|
||||
def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
|
||||
if verbose:
|
||||
print '\n', '-=' * 30
|
||||
print "Running %s.test03_SimpleCursorStuff (get_error %s, set_error %s)..." % \
|
||||
|
|
@ -459,9 +459,20 @@ def test03b_SimpleCursorWithoutGetReturnsNone0(self):
|
|||
self.__class__.__name__
|
||||
|
||||
old = self.d.set_get_returns_none(0)
|
||||
assert old == 1
|
||||
assert old == 2
|
||||
self.test03_SimpleCursorStuff(get_raises_error=1, set_raises_error=1)
|
||||
|
||||
def test03b_SimpleCursorWithGetReturnsNone1(self):
|
||||
# same test but raise exceptions instead of returning None
|
||||
if verbose:
|
||||
print '\n', '-=' * 30
|
||||
print "Running %s.test03b_SimpleCursorStuffWithoutGetReturnsNone..." % \
|
||||
self.__class__.__name__
|
||||
|
||||
old = self.d.set_get_returns_none(1)
|
||||
self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=1)
|
||||
|
||||
|
||||
def test03c_SimpleCursorGetReturnsNone2(self):
|
||||
# same test but raise exceptions instead of returning None
|
||||
if verbose:
|
||||
|
|
@ -469,10 +480,10 @@ def test03c_SimpleCursorGetReturnsNone2(self):
|
|||
print "Running %s.test03c_SimpleCursorStuffWithoutSetReturnsNone..." % \
|
||||
self.__class__.__name__
|
||||
|
||||
old = self.d.set_get_returns_none(1)
|
||||
assert old == 2
|
||||
old = self.d.set_get_returns_none(2)
|
||||
assert old == 1
|
||||
old = self.d.set_get_returns_none(2)
|
||||
assert old == 2
|
||||
self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=0)
|
||||
|
||||
#----------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue