Skip to content

Commit

Permalink
Merge d80b6d6 into aa22c6e
Browse files Browse the repository at this point in the history
  • Loading branch information
itamarst committed May 10, 2021
2 parents aa22c6e + d80b6d6 commit fa9a09a
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
2 changes: 1 addition & 1 deletion integration/conftest.py
Expand Up @@ -28,7 +28,7 @@
import pytest
import pytest_twisted

from util import (
from .util import (
_CollectOutputProtocol,
_MagicTextProtocol,
_DumpOutputProtocol,
Expand Down
16 changes: 14 additions & 2 deletions integration/test_servers_of_happiness.py
@@ -1,9 +1,21 @@
"""
Ported to Python 3.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
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

import sys
from os.path import join

from twisted.internet.error import ProcessTerminated

import util
from . import util

import pytest_twisted

Expand Down Expand Up @@ -42,4 +54,4 @@ def test_upload_immutable(reactor, temp_dir, introducer_furl, flog_gatherer, sto
assert isinstance(e, ProcessTerminated)

output = proto.output.getvalue()
assert "shares could be placed on only" in output
assert b"shares could be placed on only" in output
12 changes: 8 additions & 4 deletions integration/util.py
Expand Up @@ -5,7 +5,7 @@
import json
from os import mkdir, environ
from os.path import exists, join
from six.moves import StringIO
from io import StringIO, BytesIO
from functools import partial
from subprocess import check_output

Expand Down Expand Up @@ -59,7 +59,7 @@ class _CollectOutputProtocol(ProcessProtocol):
"""
def __init__(self):
self.done = Deferred()
self.output = StringIO()
self.output = BytesIO()

def processEnded(self, reason):
if not self.done.called:
Expand All @@ -73,7 +73,7 @@ def outReceived(self, data):
self.output.write(data)

def errReceived(self, data):
print("ERR: {}".format(data))
print("ERR: {!r}".format(data))
self.output.write(data)


Expand All @@ -94,9 +94,11 @@ def processExited(self, reason):
self.done.errback(reason)

def outReceived(self, data):
data = unicode(data, sys.stdout.encoding)
self._out.write(data)

def errReceived(self, data):
data = unicode(data, sys.stdout.encoding)
self._out.write(data)


Expand All @@ -116,13 +118,15 @@ def processEnded(self, reason):
self.exited.callback(None)

def outReceived(self, data):
data = unicode(data, sys.stdout.encoding)
sys.stdout.write(data)
self._output.write(data)
if not self.magic_seen.called and self._magic_text in self._output.getvalue():
print("Saw '{}' in the logs".format(self._magic_text))
self.magic_seen.callback(self)

def errReceived(self, data):
data = unicode(data, sys.stderr.encoding)
sys.stdout.write(data)


Expand Down Expand Up @@ -282,7 +286,7 @@ def created(_):
config,
u'node',
u'log_gatherer.furl',
flog_gatherer.decode("utf-8"),
flog_gatherer,
)
write_config(FilePath(config_path), config)
created_d.addCallback(created)
Expand Down
Empty file added newsfragments/3703.minor
Empty file.
2 changes: 1 addition & 1 deletion src/allmydata/test/web/test_web.py
Expand Up @@ -218,7 +218,7 @@ def is_connected(self): # TODO: remove me
return self.connected
def get_version(self):
return {
"application-version": "1.0"
b"application-version": b"1.0"
}
def get_permutation_seed(self):
return b""
Expand Down
9 changes: 9 additions & 0 deletions src/allmydata/util/_python3.py
Expand Up @@ -16,6 +16,15 @@
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


# Every time a module is added here, also add it to tox.ini environment
# integrations3. Bit of duplication, but it's only a handful of files so quite
# temporary.
PORTED_INTEGRATION_TESTS = [
"integration.test_servers_of_happiness",
]


# Keep these sorted alphabetically, to reduce merge conflicts:
PORTED_MODULES = [
"allmydata",
Expand Down
2 changes: 1 addition & 1 deletion src/allmydata/web/root.py
Expand Up @@ -318,7 +318,7 @@ def _describe_server(self, server):
}
version = server.get_version()
if version is not None:
description[u"version"] = version["application-version"]
description[u"version"] = version[b"application-version"]

return description

Expand Down
15 changes: 13 additions & 2 deletions tox.ini
Expand Up @@ -7,7 +7,7 @@
[gh-actions]
python =
2.7: py27-coverage,codechecks
3.6: py36-coverage
3.6: py36-coverage,integration3
3.7: py37-coverage
3.8: py38-coverage
3.9: py39-coverage,typechecks,codechecks3
Expand All @@ -17,7 +17,7 @@ python =
twisted = 1

[tox]
envlist = typechecks,codechecks,codechecks3,py{27,36,37,38,39}-{coverage},pypy27,pypy3
envlist = typechecks,codechecks,codechecks3,py{27,36,37,38,39}-{coverage},pypy27,pypy3,integration,integration3
minversion = 2.4

[testenv]
Expand Down Expand Up @@ -96,6 +96,17 @@ commands =
coverage report


[testenv:integration3]
basepython = python3
setenv =
COVERAGE_PROCESS_START=.coveragerc
commands =
# NOTE: 'run with "py.test --keep-tempdir -s -v integration/" to debug failures'
py.test --timeout=1800 --coverage -v {posargs:integration/test_servers_of_happiness.py}
coverage combine
coverage report


[testenv:codechecks]
basepython = python2.7
# On macOS, git inside of towncrier needs $HOME.
Expand Down

0 comments on commit fa9a09a

Please sign in to comment.