mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-11 21:01:44 +00:00
All tests pass on Python 3.
This commit is contained in:
parent
2c3353f2fa
commit
cf418b753a
@ -37,6 +37,7 @@ from __future__ import unicode_literals
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
from six import ensure_text
|
||||
|
||||
import re, time, hashlib
|
||||
|
||||
@ -198,6 +199,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
# doesn't really matter but it makes the logging behavior more
|
||||
# predictable and easier to test (and at least one test does depend on
|
||||
# this sorted order).
|
||||
servers = {ensure_text(key): value for (key, value) in servers.items()}
|
||||
for (server_id, server) in sorted(servers.items()):
|
||||
try:
|
||||
storage_server = self._make_storage_server(
|
||||
|
@ -1,3 +1,4 @@
|
||||
from future.utils import PY2
|
||||
from past.builtins import unicode
|
||||
|
||||
import os, sys
|
||||
@ -23,7 +24,6 @@ from hypothesis.strategies import (
|
||||
)
|
||||
|
||||
from eliot.testing import (
|
||||
capture_logging,
|
||||
assertHasAction,
|
||||
)
|
||||
from twisted.trial import unittest
|
||||
@ -64,6 +64,7 @@ from allmydata.util import (
|
||||
encodingutil,
|
||||
configutil,
|
||||
)
|
||||
from allmydata.util.eliotutil import capture_logging
|
||||
from allmydata.util.fileutil import abspath_expanduser_unicode
|
||||
from allmydata.interfaces import IFilesystemNode, IFileNode, \
|
||||
IImmutableFileNode, IMutableFileNode, IDirectoryNode
|
||||
@ -798,7 +799,7 @@ class StaticServers(Fixture):
|
||||
for (serverid, announcement)
|
||||
in self._server_details
|
||||
},
|
||||
}))
|
||||
}).encode("utf-8"))
|
||||
|
||||
|
||||
class StorageClients(SyncTestCase):
|
||||
@ -847,7 +848,7 @@ class StorageClients(SyncTestCase):
|
||||
succeeded(
|
||||
AfterPreprocessing(
|
||||
get_known_server_details,
|
||||
Equals([(serverid, announcement)]),
|
||||
Equals([(serverid.encode("utf-8"), announcement)]),
|
||||
),
|
||||
),
|
||||
)
|
||||
@ -874,7 +875,7 @@ class StorageClients(SyncTestCase):
|
||||
self.useFixture(
|
||||
StaticServers(
|
||||
self.basedir,
|
||||
[(serverid, announcement),
|
||||
[(serverid.encode("ascii"), announcement),
|
||||
# Along with a "bad" server announcement. Order in this list
|
||||
# doesn't matter, yaml serializer and Python dicts are going
|
||||
# to shuffle everything around kind of randomly.
|
||||
@ -891,7 +892,7 @@ class StorageClients(SyncTestCase):
|
||||
AfterPreprocessing(
|
||||
get_known_server_details,
|
||||
# It should have the good server details.
|
||||
Equals([(serverid, announcement)]),
|
||||
Equals([(serverid.encode("utf-8"), announcement)]),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ from six import ensure_text
|
||||
from sys import (
|
||||
stdout,
|
||||
)
|
||||
from functools import wraps
|
||||
from functools import wraps, partial
|
||||
from logging import (
|
||||
INFO,
|
||||
Handler,
|
||||
@ -66,6 +66,7 @@ from eliot.twisted import (
|
||||
DeferredContext,
|
||||
inline_callbacks,
|
||||
)
|
||||
from eliot.testing import capture_logging as eliot_capture_logging
|
||||
|
||||
from twisted.python.usage import (
|
||||
UsageError,
|
||||
@ -326,3 +327,10 @@ def log_call_deferred(action_type):
|
||||
return DeferredContext(d).addActionFinish()
|
||||
return logged_f
|
||||
return decorate_log_call_deferred
|
||||
|
||||
# On Python 3, encoding bytes to JSON doesn't work, so we have a custom JSON
|
||||
# encoder we want to use when validating messages.
|
||||
if PY2:
|
||||
capture_logging = eliot_capture_logging
|
||||
else:
|
||||
capture_logging = partial(eliot_capture_logging, encoder_=BytesJSONEncoder)
|
||||
|
Loading…
x
Reference in New Issue
Block a user