Skip to content

Commit

Permalink
Fix many deprecation/resource warnings, and bump up test verbosity on…
Browse files Browse the repository at this point in the history
… travis

Some of the tests are being killed because we don't produce any output
when running parallel tests in a layer with -v1
  • Loading branch information
jamadden committed Mar 27, 2018
1 parent a2e12be commit 5b17bb1
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ cache:
directories:
- eggs
script:
- bin/test -v1j99
- bin/test -vv -j99
notifications:
email: false
2 changes: 1 addition & 1 deletion src/ZEO/asyncio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def _close(self):

self.server.close()

f = asyncio.async(self.server.wait_closed(), loop=loop)
f = asyncio.ensure_future(self.server.wait_closed(), loop=loop)
@f.add_done_callback
def server_closed(f):
# stop the loop when the server closes:
Expand Down
42 changes: 21 additions & 21 deletions src/ZEO/asyncio/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def testClientBasics(self):

# Now we're connected, the cache was initialized, and the
# queued message has been sent:
self.assert_(client.connected.done())
self.assertTrue(client.connected.done())
self.assertEqual(cache.getLastTid(), 'a'*8)
self.assertEqual(self.pop(), (4, False, 'foo', (1, 2)))

Expand All @@ -192,7 +192,7 @@ def testClientBasics(self):

# Now we can make async calls:
f2 = self.async('bar', 3, 4)
self.assert_(f2.done() and f2.exception() is None)
self.assertTrue(f2.done() and f2.exception() is None)
self.assertEqual(self.pop(), (0, True, 'bar', (3, 4)))

# Loading objects gets special handling to leverage the cache.
Expand Down Expand Up @@ -289,8 +289,8 @@ def finished_cb(tid):
self.assertEqual(f1.exception().args, (exc,))

# Because we reconnected, a new protocol and transport were created:
self.assert_(protocol is not loop.protocol)
self.assert_(transport is not loop.transport)
self.assertTrue(protocol is not loop.protocol)
self.assertTrue(transport is not loop.transport)
protocol = loop.protocol
transport = loop.transport

Expand All @@ -313,7 +313,7 @@ def finished_cb(tid):

# Because the server tid matches the cache tid, we're done connecting
wrapper.notify_connected.assert_called_with(client, {'length': 42})
self.assert_(client.connected.done() and not transport.data)
self.assertTrue(client.connected.done() and not transport.data)
self.assertEqual(cache.getLastTid(), b'e'*8)

# Because we were able to update the cache, we didn't have to
Expand All @@ -322,7 +322,7 @@ def finished_cb(tid):

# The close method closes the connection and cache:
client.close()
self.assert_(transport.closed and cache.closed)
self.assertTrue(transport.closed and cache.closed)

# The client doesn't reconnect
self.assertEqual(loop.protocol, protocol)
Expand Down Expand Up @@ -351,7 +351,7 @@ def test_cache_behind(self):
self.respond(4, dict(length=42))

# Now that verification is done, we're done connecting
self.assert_(client.connected.done() and not transport.data)
self.assertTrue(client.connected.done() and not transport.data)
self.assertEqual(cache.getLastTid(), b'e'*8)

# And the cache has been updated:
Expand Down Expand Up @@ -388,7 +388,7 @@ def test_cache_way_behind(self):
self.respond(4, dict(length=42))

# Now that verification is done, we're done connecting
self.assert_(client.connected.done() and not transport.data)
self.assertTrue(client.connected.done() and not transport.data)
self.assertEqual(cache.getLastTid(), b'e'*8)

# But the cache is now empty and we invalidated the database cache
Expand All @@ -402,7 +402,7 @@ def test_multiple_addresses(self):
addrs, ())

# We haven't connected yet
self.assert_(protocol is None and transport is None)
self.assertTrue(protocol is None and transport is None)

# There are 2 connection attempts outstanding:
self.assertEqual(sorted(loop.connecting), addrs)
Expand All @@ -413,7 +413,7 @@ def test_multiple_addresses(self):

# The failed connection is attempted in the future:
delay, func, args, _ = loop.later.pop(0)
self.assert_(1 <= delay <= 2)
self.assertTrue(1 <= delay <= 2)
func(*args)
self.assertEqual(sorted(loop.connecting), addrs)

Expand Down Expand Up @@ -447,7 +447,7 @@ def test_bad_server_tid(self):
self.pop()
self.assertFalse(client.connected.done() or transport.data)
delay, func, args, _ = loop.later.pop(1) # first in later is heartbeat
self.assert_(8 < delay < 10)
self.assertTrue(8 < delay < 10)
self.assertEqual(len(loop.later), 1) # first in later is heartbeat
func(*args) # connect again
self.assertFalse(protocol is loop.protocol)
Expand All @@ -461,8 +461,8 @@ def test_bad_server_tid(self):
self.pop(4)
self.assertEqual(self.pop(), (3, False, 'get_info', ()))
self.respond(3, dict(length=42))
self.assert_(client.connected.done() and not transport.data)
self.assert_(client.ready)
self.assertTrue(client.connected.done() and not transport.data)
self.assertTrue(client.ready)

def test_readonly_fallback(self):
addrs = [('1.2.3.4', 8200), ('2.2.3.4', 8200)]
Expand Down Expand Up @@ -493,7 +493,7 @@ def test_readonly_fallback(self):

# At this point, the client is ready and using the protocol,
# and the protocol is read-only:
self.assert_(client.ready)
self.assertTrue(client.ready)
self.assertEqual(client.protocol, protocol)
self.assertEqual(protocol.read_only, True)
connected = client.connected
Expand All @@ -502,7 +502,7 @@ def test_readonly_fallback(self):
self.assertEqual(self.pop(), (4, False, 'get_info', ()))
self.respond(4, dict(length=42))

self.assert_(connected.done())
self.assertTrue(connected.done())

# We connect the second address:
loop.connect_connecting(addrs[1])
Expand All @@ -527,16 +527,16 @@ def test_readonly_fallback(self):
self.assertFalse(client.protocol is protocol)
self.assertEqual(client.protocol, loop.protocol)
self.assertEqual(protocol.closed, True)
self.assert_(client.connected is not connected)
self.assertTrue(client.connected is not connected)
self.assertFalse(client.connected.done())
protocol, transport = loop.protocol, loop.transport
self.assertEqual(protocol.read_only, False)

# Now, we finish verification
self.respond(2, 'b'*8)
self.respond(3, dict(length=42))
self.assert_(client.ready)
self.assert_(client.connected.done())
self.assertTrue(client.ready)
self.assertTrue(client.connected.done())

def test_invalidations_while_verifying(self):
# While we're verifying, invalidations are ignored
Expand All @@ -553,8 +553,8 @@ def test_invalidations_while_verifying(self):

# We'll disconnect:
protocol.connection_lost(Exception("lost"))
self.assert_(protocol is not loop.protocol)
self.assert_(transport is not loop.transport)
self.assertTrue(protocol is not loop.protocol)
self.assertTrue(transport is not loop.transport)
protocol = loop.protocol
transport = loop.transport

Expand Down Expand Up @@ -606,7 +606,7 @@ def test_bad_protocol(self):
with mock.patch("ZEO.asyncio.client.logger.error") as error:
self.assertFalse(error.called)
protocol.data_received(sized(self.enc + b'200'))
self.assert_(isinstance(error.call_args[0][1], ProtocolError))
self.assertTrue(isinstance(error.call_args[0][1], ProtocolError))


def test_get_peername(self):
Expand Down
17 changes: 9 additions & 8 deletions src/ZEO/tests/ConnectionTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def checkReadOnlyFallbackReadOnlyServer(self):
self.startServer(create=0, index=0, ro_svr=1)
# Start a read-only-fallback client
self._storage = self.openClientStorage(read_only_fallback=1)
self.assert_(self._storage.isReadOnly())
self.assertTrue(self._storage.isReadOnly())
# Stores should fail here
self.assertRaises(ReadOnlyError, self._dostore)
self._storage.close()
Expand Down Expand Up @@ -949,7 +949,7 @@ def checkMultipleServers(self):
break
except ClientDisconnected:
time.sleep(0.5)
self.assert_(did_a_store)
self.assertTrue(did_a_store)
self._storage.close()

class TimeoutTests(CommonSetupTearDown):
Expand All @@ -971,7 +971,7 @@ def checkTimeout(self):
):
break
else:
self.assert_(False, 'bad logging')
self.assertTrue(False, 'bad logging')

storage.close()

Expand All @@ -993,7 +993,7 @@ def checkTimeoutOnAbortNoLock(self):
def checkTimeoutAfterVote(self):
self._storage = storage = self.openClientStorage()
# Assert that the zeo cache is empty
self.assert_(not list(storage._cache.contents()))
self.assertTrue(not list(storage._cache.contents()))
# Create the object
oid = storage.new_oid()
obj = MinPO(7)
Expand All @@ -1005,17 +1005,17 @@ def checkTimeoutAfterVote(self):
storage.tpc_vote(t)
# Now sleep long enough for the storage to time out
time.sleep(3)
self.assert_(
self.assertTrue(
(not storage.is_connected())
or
(storage.connection_count_for_tests > old_connection_count)
)
storage._wait()
self.assert_(storage.is_connected())
self.assertTrue(storage.is_connected())
# We expect finish to fail
self.assertRaises(ClientDisconnected, storage.tpc_finish, t)
# The cache should still be empty
self.assert_(not list(storage._cache.contents()))
self.assertTrue(not list(storage._cache.contents()))
# Load should fail since the object should not be in either the cache
# or the server.
self.assertRaises(KeyError, storage.load, oid, '')
Expand Down Expand Up @@ -1102,7 +1102,8 @@ def short_timeout(self):

# Run IPv6 tests if V6 sockets are supported
try:
socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
pass
except (socket.error, AttributeError):
pass
else:
Expand Down
22 changes: 11 additions & 11 deletions src/ZEO/tests/IterationTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _assertIteratorIdsEmpty(self):
# make sure there's no race conditions cleaning out the weak refs
gc.disable()
try:
self.assertEquals(0, len(self._storage._iterator_ids))
self.assertEqual(0, len(self._storage._iterator_ids))
except AssertionError:
# Ok, we have ids. That should also mean that the
# weak dictionary has the same length.
Expand All @@ -50,7 +50,7 @@ def _assertIteratorIdsEmpty(self):

self.assertEqual(len(self._storage._iterators),
len(self._storage._iterator_ids))
self.assertEquals(0, len(self._storage._iterator_ids))
self.assertEqual(0, len(self._storage._iterator_ids))
finally:
if gc_enabled:
gc.enable()
Expand All @@ -63,7 +63,7 @@ def checkIteratorGCProtocol(self):

iid = server.iterator_start(None, None)
# None signals the end of iteration.
self.assertEquals(None, server.iterator_next(iid))
self.assertEqual(None, server.iterator_next(iid))
# The server has disposed the iterator already.
self.assertRaises(KeyError, server.iterator_next, iid)

Expand All @@ -80,10 +80,10 @@ def checkIteratorExhaustionStorage(self):
# At this point, a wrapping iterator might not have called the CS
# iterator yet. We'll consume one item to make sure this happens.
six.advance_iterator(iterator)
self.assertEquals(1, len(self._storage._iterator_ids))
self.assertEqual(1, len(self._storage._iterator_ids))
iid = list(self._storage._iterator_ids)[0]
self.assertEquals([], list(iterator))
self.assertEquals(0, len(self._storage._iterator_ids))
self.assertEqual([], list(iterator))
self.assertEqual(0, len(self._storage._iterator_ids))

# The iterator has run through, so the server has already disposed it.
self.assertRaises(KeyError, self._storage._call, 'iterator_next', iid)
Expand All @@ -98,7 +98,7 @@ def checkIteratorGCSpanTransactions(self):
# don't see the transaction we just wrote being picked up, because
# iterators only see the state from the point in time when they were
# created.)
self.assert_(list(iterator))
self.assertTrue(list(iterator))

def checkIteratorGCStorageCommitting(self):
# We want the iterator to be garbage-collected, so we don't keep any
Expand All @@ -111,7 +111,7 @@ def checkIteratorGCStorageCommitting(self):
self._dostore()
six.advance_iterator(self._storage.iterator())

self.assertEquals(1, len(self._storage._iterator_ids))
self.assertEqual(1, len(self._storage._iterator_ids))
iid = list(self._storage._iterator_ids)[0]

# GC happens at the transaction boundary. After that, both the storage
Expand Down Expand Up @@ -154,7 +154,7 @@ def checkIteratorGCStorageDisconnect(self):
# as well. I'm calling this directly to avoid accidentally
# calling tpc_abort implicitly.
self._storage.notify_disconnected()
self.assertEquals(0, len(self._storage._iterator_ids))
self.assertEqual(0, len(self._storage._iterator_ids))

def checkIteratorParallel(self):
self._dostore()
Expand All @@ -163,10 +163,10 @@ def checkIteratorParallel(self):
iter2 = self._storage.iterator()
txn_info1 = six.advance_iterator(iter1)
txn_info2 = six.advance_iterator(iter2)
self.assertEquals(txn_info1.tid, txn_info2.tid)
self.assertEqual(txn_info1.tid, txn_info2.tid)
txn_info1 = six.advance_iterator(iter1)
txn_info2 = six.advance_iterator(iter2)
self.assertEquals(txn_info1.tid, txn_info2.tid)
self.assertEqual(txn_info1.tid, txn_info2.tid)
self.assertRaises(StopIteration, next, iter1)
self.assertRaises(StopIteration, next, iter2)

Expand Down
2 changes: 1 addition & 1 deletion src/ZEO/tests/ThreadTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def checkMTStores(self):
for t in threads:
t.join(30)
for i in threads:
self.failUnless(not t.isAlive())
self.assertFalse(t.isAlive())

# Helper for checkMTStores
def mtstorehelper(self):
Expand Down
4 changes: 4 additions & 0 deletions src/ZEO/tests/testConversionSupport.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def test_client_record_iternext():
... next = None
...
... return oid, oid*8, 'data ' + oid, next
...
... def close(self):
... pass
>>> client = ZEO.client(
... '', wait=False, _client_factory=Client)
Expand All @@ -138,6 +141,7 @@ def test_client_record_iternext():
2
3
4
>>> client.close()
"""

Expand Down
1 change: 1 addition & 0 deletions src/ZEO/tests/testTransactionBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def checkOrderPreserved(self):
for i, (oid, d, resolved) in enumerate(tbuf):
self.assertEqual((oid, d), data[i][0])
self.assertEqual(resolved, data[i][1])
tbuf.close()

def test_suite():
return unittest.makeSuite(TransBufTests, 'check')
Loading

0 comments on commit 5b17bb1

Please sign in to comment.