Tests pass on Python 3.

This commit is contained in:
Itamar Turner-Trauring 2021-03-23 10:53:53 -04:00
parent d182ba8283
commit e140dc06ea
3 changed files with 12 additions and 8 deletions

View File

@ -5,13 +5,12 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from future.utils import PY2
from future.utils import PY2, PY3
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
import io
import os
import json
try:
from allmydata.scripts.types_ import SubCommands
@ -32,7 +31,7 @@ from allmydata.scripts.common import (
from allmydata.scripts.default_nodedir import _default_nodedir
from allmydata.util.assertutil import precondition
from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_local_unicode_path, get_io_encoding
from allmydata.util import fileutil, i2p_provider, iputil, tor_provider
from allmydata.util import fileutil, i2p_provider, iputil, tor_provider, jsonbytes as json
from wormhole import wormhole
@ -389,7 +388,7 @@ def _get_config_via_wormhole(config):
"client-v1": {},
}
}
wh.send_message(json.dumps(intro))
wh.send_message(json.dumps_bytes(intro))
server_intro = yield wh.get_message()
server_intro = json.loads(server_intro)

View File

@ -1,7 +1,5 @@
from __future__ import print_function
import json
try:
from allmydata.scripts.types_ import SubCommands
except ImportError:
@ -13,6 +11,7 @@ from twisted.internet import defer, reactor
from wormhole import wormhole
from allmydata.util.encodingutil import argv_to_abspath
from allmydata.util import jsonbytes as json
from allmydata.scripts.common import get_default_nodedir, get_introducer_furl
from allmydata.node import read_config
@ -54,7 +53,7 @@ def _send_config_via_wormhole(options, config):
code = yield wh.get_code()
print("Invite Code for client: {}".format(code), file=out)
wh.send_message(json.dumps({
wh.send_message(json.dumps_bytes({
u"abilities": {
u"server-v1": {},
}
@ -71,7 +70,7 @@ def _send_config_via_wormhole(options, config):
defer.returnValue(1)
print(" transmitting configuration", file=out)
wh.send_message(json.dumps(config))
wh.send_message(json.dumps_bytes(config))
yield wh.close()

View File

@ -1,3 +1,5 @@
from past.builtins import unicode
import os
import mock
import json
@ -48,6 +50,10 @@ class _FakeWormhole(object):
def _create_fake_wormhole(outgoing_messages):
outgoing_messages = [
m.encode("utf-8") if isinstance(m, unicode) else m
for m in outgoing_messages
]
return _FakeWormhole(outgoing_messages)