Commit 320e4d78 authored by Albertas Agejevas's avatar Albertas Agejevas

More Py3 porting.

parent 366414ae
......@@ -85,7 +85,7 @@ def _main(args=None, prog=None):
packt = time.time()
if options.time:
time_ = map(int, options.time.split(':'))
time_ = list(map(int, options.time.split(':')))
if len(time_) == 1:
time_ += (0, 0)
elif len(time_) == 2:
......
......@@ -14,25 +14,25 @@ for our test:
... logging.getLogger('test.ClientStorage').error(
... "I hate this address, %r", args[0])
... raise ValueError("Bad address")
... print "ClientStorage(%s %s)" % (
... print("ClientStorage(%s %s)" % (
... repr(args)[1:-1],
... ', '.join("%s=%r" % i for i in sorted(kw.items())),
... )
... ))
... def pack(self, t=None, *args, **kw):
... now = time.localtime(time.time())
... local_midnight = time.mktime(now[:3]+(0, 0, 0)+now[6:])
... t -= local_midnight # adjust for tz
... t += 86400*7 # add a week to make sure we're positive
... print "pack(%r,%s %s)" % (
... print("pack(%r,%s %s)" % (
... t, repr(args)[1:-1],
... ', '.join("%s=%r" % i for i in sorted(kw.items())),
... )
... ))
... def is_connected(self):
... self.connect_wait -= 1
... print 'is_connected', self.connect_wait < 0
... print('is_connected', self.connect_wait < 0)
... return self.connect_wait < 0
... def close(self):
... print "close()"
... print("close()")
>>> import ZEO
>>> ClientStorage_orig = ZEO.ClientStorage.ClientStorage
......@@ -83,7 +83,7 @@ value is timezone dependent.
>>> time.time = lambda : time.mktime((2009, 3, 24, 10, 55, 17, 1, 83, -1))
>>> sleep_orig = time.sleep
>>> def sleep(t):
... print 'sleep(%r)' % t
... print('sleep(%r)' % t)
>>> time.sleep = sleep
Normally, we pass one or more TCP server specifications:
......@@ -178,8 +178,8 @@ seconds of waiting for a connect.
... try:
... try:
... main(args)
... except SystemExit, v:
... print "Exited", v
... except SystemExit as v:
... print("Exited", v)
... finally:
... sys.stderr = old_stderr
......
......@@ -82,7 +82,7 @@ dynamic port using ZConfig, you'd use a hostname by itself. In this
case, ZConfig passes None as the port.
>>> import ZEO.runzeo
>>> open('conf', 'w').write("""
>>> r = open('conf', 'w').write("""
... <zeo>
... address 127.0.0.1
... </zeo>
......
......@@ -13,6 +13,7 @@
##############################################################################
"""Test suite for ZEO based on ZODB.tests."""
from __future__ import print_function
import re
from ZEO.ClientStorage import ClientStorage
from ZEO.tests.forker import get_port
......@@ -1453,7 +1454,7 @@ def generate_script(name, src):
def runzeo_logrotate_on_sigusr2():
"""
>>> port = get_port()
>>> open('c', 'w').write('''
>>> r = open('c', 'w').write('''
... <zeo>
... address %s
... </zeo>
......@@ -1756,8 +1757,14 @@ def test_suite():
(re.compile(r"'start': '[^\n]+'"), 'start'),
]),
))
zeo.addTest(doctest.DocTestSuite(ZEO.tests.IterationTests,
setUp=forker.setUp, tearDown=zope.testing.setupstack.tearDown))
zeo.addTest(doctest.DocTestSuite(
ZEO.tests.IterationTests,
setUp=forker.setUp, tearDown=zope.testing.setupstack.tearDown,
checker=renormalizing.RENormalizing((
(re.compile("ZEO.Exceptions.ClientDisconnected"),
"ClientDisconnected"),
)),
))
zeo.addTest(doctest.DocFileSuite('registerDB.test'))
zeo.addTest(
doctest.DocFileSuite(
......
......@@ -231,7 +231,7 @@ We start a transaction and vote, this leads to getting the lock.
ZEO.StorageServer DEBUG
(test-addr-1) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
(test-addr-1) Preparing to commit transaction: 1 objects, 36 bytes
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
1 callAsync serialnos ...
If another client tried to vote, it's lock request will be queued and
......@@ -253,7 +253,7 @@ When we end the first transaction, the queued vote gets the lock.
ZEO.StorageServer DEBUG
(test-addr-2) ('1') lock: transactions waiting: 0
ZEO.StorageServer BLATHER
(test-addr-2) Preparing to commit transaction: 1 objects, 36 bytes
(test-addr-2) Preparing to commit transaction: 1 objects, ... bytes
2 callAsync serialnos ...
Let's try again with the first client. The vote will be queued:
......@@ -328,7 +328,7 @@ release the lock and one of the waiting clients will get the lock.
ZEO.StorageServer WARNING
(test-addr-1) ('1') lock: transactions waiting: 9
ZEO.StorageServer BLATHER
(test-addr-1) Preparing to commit transaction: 1 objects, 36 bytes
(test-addr-1) Preparing to commit transaction: 1 objects, ... bytes
1 callAsync serialnos ...
(In practice, waiting clients won't necessarily get the lock in order.)
......
......@@ -52,7 +52,7 @@ Now, let's write some data:
>>> conn = db.open()
>>> for i in range(1, 101):
... conn.root()[i] = ZODB.blob.Blob()
... conn.root()[i].open('w').write(chr(i)*100)
... w = conn.root()[i].open('w').write((chr(i)*100).encode('ascii'))
>>> transaction.commit()
We've committed 10000 bytes of data, but our target size is 3000. We
......@@ -86,19 +86,19 @@ target:
>>> for i in range(1, 101):
... data = conn.root()[i].open().read()
... if data != chr(i)*100:
... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data))
>>> wait_until("size is reduced", check, 99, onfail)
>>> for i in range(1, 101):
... data = conn.root()[i].open().read()
... if data != chr(i)*100:
... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data))
>>> for i in range(1, 101):
... data = conn.root()[i].open('c').read()
... if data != chr(i)*100:
... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data))
>>> wait_until("size is reduced", check, 99, onfail)
......@@ -115,11 +115,11 @@ provoke problems:
... time.sleep(0)
... i = random.randint(1, 100)
... data = conn.root()[i].open().read()
... if data != chr(i)*100:
... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data))
... i = random.randint(1, 100)
... data = conn.root()[i].open('c').read()
... if data != chr(i)*100:
... if data != (chr(i)*100).encode('ascii'):
... print('bad data', repr(chr(i)), repr(data))
... 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