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
Hide 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):
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()
>>> conn = db.open()
...
...
@@ -661,14 +661,14 @@ See https://bugs.launchpad.net/zodb/+bug/185066
def
readCurrent
():
r"""
The connection's readCurrent method is called to provide a higher
level of consistency in cases where an object if read to compute an
update to a separate object. When this is used, the
checkCurrentSerialInTransaction method on the storage is called in
2-phase commit.
The connection's readCurrent method is called to provide a higher
level of consistency in cases where an object if read to compute an
update to a separate object. When this is used, the
checkCurrentSerialInTransaction method on the storage is called in
2-phase commit.
To demonstrate this, we'll create a storage and give it a test
implementation of checkCurrentSerialInTransaction.
To demonstrate this, we'll create a storage and give it a test
implementation of checkCurrentSerialInTransaction.
>>> import ZODB.MappingStorage
>>> store = ZODB.MappingStorage.MappingStorage()
...
...
@@ -683,8 +683,8 @@ implementation of checkCurrentSerialInTransaction.
>>> store.checkCurrentSerialInTransaction = checkCurrentSerialInTransaction
Now, we'll use the storage as usual. checkCurrentSerialInTransaction
won't normally be called:
Now, we'll use the storage as usual. checkCurrentSerialInTransaction
won't normally be called:
>>> db = ZODB.DB(store)
>>> conn = db.open()
...
...
@@ -692,17 +692,17 @@ won't normally be called:
>>> conn.root.b = ZODB.tests.util.P('b')
>>> transaction.commit()
If we call readCurrent for an object and we modify another object,
then checkCurrentSerialInTransaction will be called for the object
readCurrent was called on.
If we call readCurrent for an object and we modify another object,
then checkCurrentSerialInTransaction will be called for the object
readCurrent was called on.
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x = 0
>>> transaction.commit()
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
It doesn't matter how often we call readCurrent,
checkCurrentSerialInTransaction will be called only once:
It doesn't matter how often we call readCurrent,
checkCurrentSerialInTransaction will be called only once:
>>> conn.readCurrent(conn.root.a)
>>> conn.readCurrent(conn.root.a)
...
...
@@ -712,21 +712,21 @@ checkCurrentSerialInTransaction will be called only once:
>>> transaction.commit()
checkCurrentSerialInTransaction '\x00\x00\x00\x00\x00\x00\x00\x01'
checkCurrentSerialInTransaction won't be called if another object
isn't modified:
checkCurrentSerialInTransaction won't be called if another object
isn't modified:
>>> conn.readCurrent(conn.root.a)
>>> 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.root.a.x = 0
>>> conn.root.b.x += 1
>>> 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
>>> bad.add(conn.root.a._p_oid)
...
...
@@ -739,11 +739,11 @@ If the storage raises a conflict error, it'll be propigated:
>>> 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
The storage may raise it later:
The storage may raise it later:
>>> def checkCurrentSerialInTransaction(oid, serial, trans):
... if not trans == transaction.get(): print('oops')
...
...
@@ -760,7 +760,7 @@ The storage may raise it later:
>>> store.badness = None
>>> store.tpc_vote = tpc_vote
It will still be propigated:
It will still be propigated:
>>> _ = str(conn.root.a) # do read
>>> conn.readCurrent(conn.root.a)
...
...
@@ -772,18 +772,18 @@ It will still be propigated:
>>> 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
Read checks don't leak accross transactions:
Read checks don't leak accross transactions:
>>> conn.readCurrent(conn.root.a)
>>> transaction.commit()
>>> conn.root.b.x = +1
>>> transaction.commit()
Read checks to work accross savepoints.
Read checks to work accross savepoints.
>>> conn.readCurrent(conn.root.a)
>>> conn.root.b.x = +1
...
...
@@ -810,11 +810,11 @@ Read checks to work accross savepoints.
def
cache_management_of_subconnections
():
"""Make that cache management works for subconnections.
When we use multi-databases, we open a connection in one database and
access connections to other databases through it. This test verifies
thatcache management is applied to all of the connections.
When we use multi-databases, we open a connection in one database and
access connections to other databases through it. This test verifies
thatcache management is applied to all of the connections.
Set up a multi-database:
Set up a multi-database:
>>> db1 = ZODB.DB(None)
>>> db2 = ZODB.DB(None, databases=db1.databases, database_name='2',
...
...
@@ -822,45 +822,45 @@ Set up a multi-database:
>>> conn1 = db1.open()
>>> 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):
... 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()
>>> conn2._cache.cache_non_ghost_count
10
Fill it back up:
Fill it back up:
>>> for i in range(100):
... _ = str(conn2.root()[i])
>>> conn2._cache.cache_non_ghost_count
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()
>>> conn2._cache.cache_non_ghost_count
10
Ditto for cache minimize:
Ditto for cache minimize:
>>> conn1.cacheMinimize()
>>> conn2._cache.cache_non_ghost_count
0
Fill it back up:
Fill it back up:
>>> for i in range(100):
... _ = str(conn2.root()[i])
>>> conn2._cache.cache_non_ghost_count
101
GC is done on reopen:
GC is done on reopen:
>>> conn1.close()
>>> db1.open() is conn1
...
...
@@ -901,7 +901,7 @@ def abort_of_savepoint_creating_new_objects_w_exotic_invalidate_doesnt_break():
>>> 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_jar
...
...
@@ -943,22 +943,22 @@ def lp9460655():
def
lp615758_transaction_abort_Incomplete_cleanup_for_new_objects
():
r"""
As the following"DocTest" demonstrates, "abort" forgets to
reset "_p_changed" for new (i.e. "added") objects.
>>> class P(Persistent): pass
...
>>> c = ZODB.connection(None)
>>> obj = P()
>>> c.add(obj)
>>> obj.x = 1
>>> obj._p_changed
True
>>> transaction.abort()
>>> obj._p_changed
False
>>> c.close()
As the following"DocTest" demonstrates, "abort" forgets to
reset "_p_changed" for new (i.e. "added") objects.
>>> class P(Persistent): pass
...
>>> c = ZODB.connection(None)
>>> obj = P()
>>> c.add(obj)
>>> obj.x = 1
>>> obj._p_changed
True
>>> transaction.abort()
>>> obj._p_changed
False
>>> c.close()
"""
class
Clp485456_setattr_in_getstate_doesnt_cause_multiple_stores
(
Persistent
):
...
...
@@ -977,7 +977,7 @@ def lp485456_setattr_in_setstate_doesnt_cause_multiple_stores():
... return oldstore(oid, *args)
>>> 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()
>>> transaction.commit()
...
...
@@ -988,17 +988,17 @@ When we commit a change, we only get a single store call
>>> transaction.commit()
storing '\x00\x00\x00\x00\x00\x00\x00\x02'
We still see updates:
We still see updates:
>>> conn.root.x.y = 1
>>> transaction.commit()
storing '\x00\x00\x00\x00\x00\x00\x00\x01'
Not not non-updates:
Not not non-updates:
>>> transaction.commit()
Let's try some combinations with savepoints:
Let's try some combinations with savepoints:
>>> conn.root.n = 0
>>> _ = 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