Tests pass on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2020-11-06 10:20:18 -05:00
parent 836d41a92d
commit 31ee2e18f3
3 changed files with 8 additions and 7 deletions

View File

@ -187,7 +187,7 @@ class MutableChecker(object):
if self.bad_shares:
report.append("Corrupt Shares:")
summary.append("Corrupt Shares:")
for (server, shnum, f) in sorted(self.bad_shares):
for (server, shnum, f) in self.bad_shares:
serverid = server.get_serverid()
locator = (server, self._storage_index, shnum)
corrupt_share_locators.append(locator)

View File

@ -41,7 +41,7 @@ class Checker(unittest.TestCase, CheckerMixin, PublishMixin):
def test_check_not_enough_shares(self):
for shares in self._storage._peers.values():
for shnum in shares.keys():
for shnum in list(shares.keys()):
if shnum > 0:
del shares[shnum]
d = self._fn.check(Monitor())
@ -52,7 +52,7 @@ class Checker(unittest.TestCase, CheckerMixin, PublishMixin):
d = self.publish_mdmf()
def _then(ignored):
for shares in self._storage._peers.values():
for shnum in shares.keys():
for shnum in list(shares.keys()):
if shnum > 0:
del shares[shnum]
d.addCallback(_then)
@ -242,14 +242,14 @@ class Checker(unittest.TestCase, CheckerMixin, PublishMixin):
return d
def test_verify_sdmf_empty(self):
d = self.publish_sdmf("")
d = self.publish_sdmf(b"")
d.addCallback(lambda ignored: self._fn.check(Monitor(), verify=True))
d.addCallback(self.check_good, "test_verify_sdmf")
d.addCallback(flushEventualQueue)
return d
def test_verify_mdmf_empty(self):
d = self.publish_mdmf("")
d = self.publish_mdmf(b"")
d.addCallback(lambda ignored: self._fn.check(Monitor(), verify=True))
d.addCallback(self.check_good, "test_verify_mdmf")
d.addCallback(flushEventualQueue)

View File

@ -1,3 +1,4 @@
from future.utils import bchr
from past.builtins import long
from io import BytesIO
@ -146,14 +147,14 @@ class FakeStorageServer(object):
def flip_bit(original, byte_offset):
return (original[:byte_offset] +
chr(ord(original[byte_offset]) ^ 0x01) +
bchr(ord(original[byte_offset:byte_offset+1]) ^ 0x01) +
original[byte_offset+1:])
def add_two(original, byte_offset):
# It isn't enough to simply flip the bit for the version number,
# because 1 is a valid version number. So we add two instead.
return (original[:byte_offset] +
chr(ord(original[byte_offset]) ^ 0x02) +
bchr(ord(original[byte_offset:byte_offset+1]) ^ 0x02) +
original[byte_offset+1:])
def corrupt(res, s, offset, shnums_to_corrupt=None, offset_offset=0):