Commit 0d2a65b6 authored by Jason Madden's avatar Jason Madden

Wrap the nested statements.

parent 3acc4b7e
...@@ -34,7 +34,8 @@ A current client should be able to connect to a old server: ...@@ -34,7 +34,8 @@ A current client should be able to connect to a old server:
2 2
>>> conn.root()['blob1'] = ZODB.blob.Blob() >>> conn.root()['blob1'] = ZODB.blob.Blob()
>>> with conn.root()['blob1'].open('w') as f: r = f.write(b'blob data 1') >>> with conn.root()['blob1'].open('w') as f:
... r = f.write(b'blob data 1')
>>> transaction.commit() >>> transaction.commit()
>>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True) >>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True)
...@@ -44,7 +45,8 @@ A current client should be able to connect to a old server: ...@@ -44,7 +45,8 @@ A current client should be able to connect to a old server:
... conn2.root().x += 1 ... conn2.root().x += 1
... transaction.commit() ... transaction.commit()
>>> conn2.root()['blob2'] = ZODB.blob.Blob() >>> conn2.root()['blob2'] = ZODB.blob.Blob()
>>> with conn2.root()['blob2'].open('w') as f: r = f.write(b'blob data 2') >>> with conn2.root()['blob2'].open('w') as f:
... r = f.write(b'blob data 2')
>>> transaction.commit() >>> transaction.commit()
>>> @wait_until("Get the new data") >>> @wait_until("Get the new data")
...@@ -76,9 +78,11 @@ A current client should be able to connect to a old server: ...@@ -76,9 +78,11 @@ A current client should be able to connect to a old server:
>>> conn.root().x >>> conn.root().x
17 17
>>> with conn.root()['blob1'].open() as f: f.read() >>> with conn.root()['blob1'].open() as f:
... f.read()
b'blob data 1' b'blob data 1'
>>> with conn.root()['blob2'].open() as f: f.read() >>> with conn.root()['blob2'].open() as f:
... f.read()
b'blob data 2' b'blob data 2'
Note that when taking to a 3.8 server, iteration won't work: Note that when taking to a 3.8 server, iteration won't work:
...@@ -118,7 +122,8 @@ Note that we'll have to pull some hijinks: ...@@ -118,7 +122,8 @@ Note that we'll have to pull some hijinks:
2 2
>>> conn.root()['blob1'] = ZODB.blob.Blob() >>> conn.root()['blob1'] = ZODB.blob.Blob()
>>> with conn.root()['blob1'].open('w') as f: r = f.write(b'blob data 1') >>> with conn.root()['blob1'].open('w') as f:
... r = f.write(b'blob data 1')
>>> transaction.commit() >>> transaction.commit()
>>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True) >>> db2 = ZEO.DB(addr, blob_dir='server-blobs', shared_blob_dir=True)
...@@ -128,7 +133,8 @@ Note that we'll have to pull some hijinks: ...@@ -128,7 +133,8 @@ Note that we'll have to pull some hijinks:
... conn2.root().x += 1 ... conn2.root().x += 1
... transaction.commit() ... transaction.commit()
>>> conn2.root()['blob2'] = ZODB.blob.Blob() >>> conn2.root()['blob2'] = ZODB.blob.Blob()
>>> with conn2.root()['blob2'].open('w') as f: r = f.write(b'blob data 2') >>> with conn2.root()['blob2'].open('w') as f:
... r = f.write(b'blob data 2')
>>> transaction.commit() >>> transaction.commit()
...@@ -161,9 +167,11 @@ Note that we'll have to pull some hijinks: ...@@ -161,9 +167,11 @@ Note that we'll have to pull some hijinks:
>>> conn.root().x >>> conn.root().x
17 17
>>> with conn.root()['blob1'].open() as f: f.read() >>> with conn.root()['blob1'].open() as f:
... f.read()
b'blob data 1' b'blob data 1'
>>> with conn.root()['blob2'].open() as f: f.read() >>> with conn.root()['blob2'].open() as
... f: f.read()
b'blob data 2' b'blob data 2'
Make some old protocol calls: Make some old protocol calls:
......
...@@ -52,7 +52,8 @@ Now, let's write some data: ...@@ -52,7 +52,8 @@ Now, let's write some data:
>>> conn = db.open() >>> conn = db.open()
>>> for i in range(1, 101): >>> for i in range(1, 101):
... conn.root()[i] = ZODB.blob.Blob() ... conn.root()[i] = ZODB.blob.Blob()
... with conn.root()[i].open('w') as f: w = f.write((chr(i)*100).encode('ascii')) ... with conn.root()[i].open('w') as f:
... w = f.write((chr(i)*100).encode('ascii'))
>>> transaction.commit() >>> transaction.commit()
We've committed 10000 bytes of data, but our target size is 3000. We We've committed 10000 bytes of data, but our target size is 3000. We
...@@ -85,19 +86,22 @@ necessary, but the cache size will remain not much bigger than the ...@@ -85,19 +86,22 @@ necessary, but the cache size will remain not much bigger than the
target: target:
>>> for i in range(1, 101): >>> for i in range(1, 101):
... with conn.root()[i].open() as f: data = f.read() ... with conn.root()[i].open() as f:
... data = f.read()
... if data != (chr(i)*100).encode('ascii'): ... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data)) ... print('bad data', repr(chr(i)), repr(data))
>>> wait_until("size is reduced", check, 99, onfail) >>> wait_until("size is reduced", check, 99, onfail)
>>> for i in range(1, 101): >>> for i in range(1, 101):
... with conn.root()[i].open() as f: data = f.read() ... with conn.root()[i].open() as f:
... data = f.read()
... if data != (chr(i)*100).encode('ascii'): ... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data)) ... print('bad data', repr(chr(i)), repr(data))
>>> for i in range(1, 101): >>> for i in range(1, 101):
... with conn.root()[i].open('c') as f: data = f.read() ... with conn.root()[i].open('c') as f:
... data = f.read()
... if data != (chr(i)*100).encode('ascii'): ... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data)) ... print('bad data', repr(chr(i)), repr(data))
...@@ -114,11 +118,13 @@ provoke problems: ...@@ -114,11 +118,13 @@ provoke problems:
... for i in range(300): ... for i in range(300):
... time.sleep(0) ... time.sleep(0)
... i = random.randint(1, 100) ... i = random.randint(1, 100)
... with conn.root()[i].open() as f: data = f.read() ... with conn.root()[i].open() as f:
... data = f.read()
... if data != (chr(i)*100).encode('ascii'): ... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data)) ... print('bad data', repr(chr(i)), repr(data))
... i = random.randint(1, 100) ... i = random.randint(1, 100)
... with conn.root()[i].open('c') as f: data = f.read() ... with conn.root()[i].open('c') as f:
... data = f.read()
... if data != (chr(i)*100).encode('ascii'): ... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data)) ... print('bad data', repr(chr(i)), repr(data))
... db.close() ... db.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment