Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zodb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joshua
zodb
Commits
338536e8
Commit
338536e8
authored
Feb 20, 2013
by
Marius Gedminas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unify doctest indentation
parent
a8657578
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
57 deletions
+57
-57
src/ZODB/tests/testConnection.py
src/ZODB/tests/testConnection.py
+57
-57
No files found.
src/ZODB/tests/testConnection.py
View file @
338536e8
...
@@ -642,7 +642,7 @@ class proper_ghost_initialization_with_empty__p_deactivate_class(Persistent):
...
@@ -642,7 +642,7 @@ class proper_ghost_initialization_with_empty__p_deactivate_class(Persistent):
def
proper_ghost_initialization_with_empty__p_deactivate
():
def
proper_ghost_initialization_with_empty__p_deactivate
():
"""
"""
See https://bugs.launchpad.net/zodb/+bug/185066
See https://bugs.launchpad.net/zodb/+bug/185066
>>> db = ZODB.tests.util.DB()
>>> db = ZODB.tests.util.DB()
>>> conn = db.open()
>>> conn = db.open()
...
@@ -661,14 +661,14 @@ See https://bugs.launchpad.net/zodb/+bug/185066
...
@@ -661,14 +661,14 @@ See https://bugs.launchpad.net/zodb/+bug/185066
def
readCurrent
():
def
readCurrent
():
r"""
r"""
The connection's readCurrent method is called to provide a higher
The connection's readCurrent method is called to provide a higher
level of consistency in cases where an object if read to compute an
level of consistency in cases where an object if read to compute an
update to a separate object. When this is used, the
update to a separate object. When this is used, the
checkCurrentSerialInTransaction method on the storage is called in
checkCurrentSerialInTransaction method on the storage is called in
2-phase commit.
2-phase commit.
To demonstrate this, we'll create a storage and give it a test
To demonstrate this, we'll create a storage and give it a test
implementation of checkCurrentSerialInTransaction.
implementation of checkCurrentSerialInTransaction.
>>> import ZODB.MappingStorage
>>> import ZODB.MappingStorage
>>> store = ZODB.MappingStorage.MappingStorage()
>>> store = ZODB.MappingStorage.MappingStorage()
...
@@ -683,8 +683,8 @@ implementation of checkCurrentSerialInTransaction.
...
@@ -683,8 +683,8 @@ implementation of checkCurrentSerialInTransaction.
>>> store.checkCurrentSerialInTransaction = checkCurrentSerialInTransaction
>>> store.checkCurrentSerialInTransaction = checkCurrentSerialInTransaction
Now, we'll use the storage as usual. checkCurrentSerialInTransaction
Now, we'll use the storage as usual. checkCurrentSerialInTransaction
won't normally be called:
won't normally be called:
>>> db = ZODB.DB(store)
>>> db = ZODB.DB(store)
>>> conn = db.open()
>>> conn = db.open()
...
@@ -692,17 +692,17 @@ won't normally be called:
...
@@ -692,17 +692,17 @@ won't normally be called:
>>> conn.root.b = ZODB.tests.util.P('b')
>>> conn.root.b = ZODB.tests.util.P('b')
>>> transaction.commit()
>>> transaction.commit()
If we call readCurrent for an object and we modify another object,
If we call readCurrent for an object and we modify another object,
then checkCurrentSerialInTransaction will be called for the object
then checkCurrentSerialInTransaction will be called for the object
readCurrent was called on.
readCurrent was called on.
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x = 0
>>> conn.root.b.x = 0
>>> transaction.commit()
>>> transaction.commit()
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
It doesn't matter how often we call readCurrent,
It doesn't matter how often we call readCurrent,
checkCurrentSerialInTransaction will be called only once:
checkCurrentSerialInTransaction will be called only once:
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
...
@@ -712,21 +712,21 @@ checkCurrentSerialInTransaction will be called only once:
...
@@ -712,21 +712,21 @@ checkCurrentSerialInTransaction will be called only once:
>>> transaction.commit()
>>> transaction.commit()
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
checkCurrentSerialInTransaction won't be called if another object
checkCurrentSerialInTransaction won't be called if another object
isn't modified:
isn't modified:
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> transaction.commit()
>>> transaction.commit()
Or if the object it was called on is modified:
Or if the object it was called on is modified:
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> conn.root.a.x = 0
>>> conn.root.a.x = 0
>>> conn.root.b.x += 1
>>> conn.root.b.x += 1
>>> transaction.commit()
>>> transaction.commit()
If the storage raises a conflict error, it'll be propigated:
If the storage raises a conflict error, it'll be propigated:
>>> _ = str(conn.root.a) # do read
>>> _ = str(conn.root.a) # do read
>>> bad.add(conn.root.a._p_oid)
>>> bad.add(conn.root.a._p_oid)
...
@@ -739,11 +739,11 @@ If the storage raises a conflict error, it'll be propigated:
...
@@ -739,11 +739,11 @@ If the storage raises a conflict error, it'll be propigated:
>>> transaction.abort()
>>> transaction.abort()
The conflict error will cause the affected object to be invalidated:
The conflict error will cause the affected object to be invalidated:
>>> conn.root.a._p_changed
>>> conn.root.a._p_changed
The storage may raise it later:
The storage may raise it later:
>>> def checkCurrentSerialInTransaction(oid, serial, trans):
>>> def checkCurrentSerialInTransaction(oid, serial, trans):
... if not trans == transaction.get(): print('oops')
... if not trans == transaction.get(): print('oops')
...
@@ -760,7 +760,7 @@ The storage may raise it later:
...
@@ -760,7 +760,7 @@ The storage may raise it later:
>>> store.badness = None
>>> store.badness = None
>>> store.tpc_vote = tpc_vote
>>> store.tpc_vote = tpc_vote
It will still be propigated:
It will still be propigated:
>>> _ = str(conn.root.a) # do read
>>> _ = str(conn.root.a) # do read
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
...
@@ -772,18 +772,18 @@ It will still be propigated:
...
@@ -772,18 +772,18 @@ It will still be propigated:
>>> transaction.abort()
>>> transaction.abort()
The conflict error will cause the affected object to be invalidated:
The conflict error will cause the affected object to be invalidated:
>>> conn.root.a._p_changed
>>> conn.root.a._p_changed
Read checks don't leak accross transactions:
Read checks don't leak accross transactions:
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> transaction.commit()
>>> transaction.commit()
>>> conn.root.b.x = +1
>>> conn.root.b.x = +1
>>> transaction.commit()
>>> transaction.commit()
Read checks to work accross savepoints.
Read checks to work accross savepoints.
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x = +1
>>> conn.root.b.x = +1
...
@@ -810,11 +810,11 @@ Read checks to work accross savepoints.
...
@@ -810,11 +810,11 @@ Read checks to work accross savepoints.
def
cache_management_of_subconnections
():
def
cache_management_of_subconnections
():
"""Make that cache management works for subconnections.
"""Make that cache management works for subconnections.
When we use multi-databases, we open a connection in one database and
When we use multi-databases, we open a connection in one database and
access connections to other databases through it. This test verifies
access connections to other databases through it. This test verifies
thatcache management is applied to all of the connections.
thatcache management is applied to all of the connections.
Set up a multi-database:
Set up a multi-database:
>>> db1 = ZODB.DB(None)
>>> db1 = ZODB.DB(None)
>>> db2 = ZODB.DB(None, databases=db1.databases, database_name='2',
>>> db2 = ZODB.DB(None, databases=db1.databases, database_name='2',
...
@@ -822,45 +822,45 @@ Set up a multi-database:
...
@@ -822,45 +822,45 @@ Set up a multi-database:
>>> conn1 = db1.open()
>>> conn1 = db1.open()
>>> conn2 = conn1.get_connection('2')
>>> conn2 = conn1.get_connection('2')
Populate it with some data, more than will fit in the cache:
Populate it with some data, more than will fit in the cache:
>>> for i in range(100):
>>> for i in range(100):
... conn2.root()[i] = conn2.root().__class__()
... conn2.root()[i] = conn2.root().__class__()
Upon commit, the cache is reduced to the cache size:
Upon commit, the cache is reduced to the cache size:
>>> transaction.commit()
>>> transaction.commit()
>>> conn2._cache.cache_non_ghost_count
>>> conn2._cache.cache_non_ghost_count
10
10
Fill it back up:
Fill it back up:
>>> for i in range(100):
>>> for i in range(100):
... _ = str(conn2.root()[i])
... _ = str(conn2.root()[i])
>>> conn2._cache.cache_non_ghost_count
>>> conn2._cache.cache_non_ghost_count
101
101
Doing cache GC on the primary also does it on the secondary:
Doing cache GC on the primary also does it on the secondary:
>>> conn1.cacheGC()
>>> conn1.cacheGC()
>>> conn2._cache.cache_non_ghost_count
>>> conn2._cache.cache_non_ghost_count
10
10
Ditto for cache minimize:
Ditto for cache minimize:
>>> conn1.cacheMinimize()
>>> conn1.cacheMinimize()
>>> conn2._cache.cache_non_ghost_count
>>> conn2._cache.cache_non_ghost_count
0
0
Fill it back up:
Fill it back up:
>>> for i in range(100):
>>> for i in range(100):
... _ = str(conn2.root()[i])
... _ = str(conn2.root()[i])
>>> conn2._cache.cache_non_ghost_count
>>> conn2._cache.cache_non_ghost_count
101
101
GC is done on reopen:
GC is done on reopen:
>>> conn1.close()
>>> conn1.close()
>>> db1.open() is conn1
>>> db1.open() is conn1
...
@@ -901,7 +901,7 @@ def abort_of_savepoint_creating_new_objects_w_exotic_invalidate_doesnt_break():
...
@@ -901,7 +901,7 @@ def abort_of_savepoint_creating_new_objects_w_exotic_invalidate_doesnt_break():
>>> transaction.abort()
>>> transaction.abort()
After the abort, the oid and jar are None:
After the abort, the oid and jar are None:
>>> x._p_oid
>>> x._p_oid
>>> x._p_jar
>>> x._p_jar
...
@@ -943,22 +943,22 @@ def lp9460655():
...
@@ -943,22 +943,22 @@ def lp9460655():
def
lp615758_transaction_abort_Incomplete_cleanup_for_new_objects
():
def
lp615758_transaction_abort_Incomplete_cleanup_for_new_objects
():
r"""
r"""
As the following"DocTest" demonstrates, "abort" forgets to
As the following"DocTest" demonstrates, "abort" forgets to
reset "_p_changed" for new (i.e. "added") objects.
reset "_p_changed" for new (i.e. "added") objects.
>>> class P(Persistent): pass
>>> class P(Persistent): pass
...
...
>>> c = ZODB.connection(None)
>>> c = ZODB.connection(None)
>>> obj = P()
>>> obj = P()
>>> c.add(obj)
>>> c.add(obj)
>>> obj.x = 1
>>> obj.x = 1
>>> obj._p_changed
>>> obj._p_changed
True
True
>>> transaction.abort()
>>> transaction.abort()
>>> obj._p_changed
>>> obj._p_changed
False
False
>>> c.close()
>>> c.close()
"""
"""
class
Clp485456_setattr_in_getstate_doesnt_cause_multiple_stores
(
Persistent
):
class
Clp485456_setattr_in_getstate_doesnt_cause_multiple_stores
(
Persistent
):
...
@@ -977,7 +977,7 @@ def lp485456_setattr_in_setstate_doesnt_cause_multiple_stores():
...
@@ -977,7 +977,7 @@ def lp485456_setattr_in_setstate_doesnt_cause_multiple_stores():
... return oldstore(oid, *args)
... return oldstore(oid, *args)
>>> conn._storage.store = store
>>> conn._storage.store = store
When we commit a change, we only get a single store call
When we commit a change, we only get a single store call
>>> conn.root.x = C()
>>> conn.root.x = C()
>>> transaction.commit()
>>> transaction.commit()
...
@@ -988,17 +988,17 @@ When we commit a change, we only get a single store call
...
@@ -988,17 +988,17 @@ When we commit a change, we only get a single store call
>>> transaction.commit()
>>> transaction.commit()
storing '\x00\x00\x00\x00\x00\x00\x00\x02'
storing '\x00\x00\x00\x00\x00\x00\x00\x02'
We still see updates:
We still see updates:
>>> conn.root.x.y = 1
>>> conn.root.x.y = 1
>>> transaction.commit()
>>> transaction.commit()
storing '\x00\x00\x00\x00\x00\x00\x00\x01'
storing '\x00\x00\x00\x00\x00\x00\x00\x01'
Not not non-updates:
Not not non-updates:
>>> transaction.commit()
>>> transaction.commit()
Let's try some combinations with savepoints:
Let's try some combinations with savepoints:
>>> conn.root.n = 0
>>> conn.root.n = 0
>>> _ = transaction.savepoint()
>>> _ = transaction.savepoint()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment