Merge remote-tracking branch 'origin/master' into 3566.web-tests-python-3-part-2

This commit is contained in:
Itamar Turner-Trauring 2020-12-22 13:21:49 -05:00
commit 55698cc8f2
9 changed files with 54 additions and 15 deletions

View File

@ -40,3 +40,9 @@ codecov:
# repositories have coverage uploaded to the right place in codecov so
# their reports aren't incomplete.
token: "abf679b6-e2e6-4b33-b7b5-6cfbd41ee691"
notify:
# The reference documentation suggests that this is the default setting:
# https://docs.codecov.io/docs/codecovyml-reference#codecovnotifywait_for_ci
# However observation suggests otherwise.
wait_for_ci: true

0
newsfragments/3567.minor Normal file
View File

0
newsfragments/3568.minor Normal file
View File

View File

@ -57,10 +57,10 @@ def run_cli_native(verb, *args, **kwargs):
Most code should prefer ``run_cli_unicode`` which deals with all the
necessary encoding considerations.
:param native_str verb: The command to run. For example, ``b"create-node"``.
:param native_str verb: The command to run. For example, ``"create-node"``.
:param [native_str] args: The arguments to pass to the command. For example,
``(b"--hostname=localhost",)``.
``("--hostname=localhost",)``.
:param [native_str] nodeargs: Extra arguments to pass to the Tahoe executable
before ``verb``.

View File

@ -457,7 +457,8 @@ class StoragePluginWebPresence(AsyncTestCase):
self.storage_plugin = u"tahoe-lafs-dummy-v1"
from twisted.internet import reactor
_, port_endpoint = self.port_assigner.assign(reactor)
_, webport_endpoint = self.port_assigner.assign(reactor)
tubport_location, tubport_endpoint = self.port_assigner.assign(reactor)
tempdir = TempDir()
self.useFixture(tempdir)
@ -468,8 +469,12 @@ class StoragePluginWebPresence(AsyncTestCase):
"web": "1",
},
node_config={
"tub.location": "127.0.0.1:1",
"web.port": ensure_text(port_endpoint),
# We don't really need the main Tub listening but if we
# disable it then we also have to disable storage (because
# config validation policy).
"tub.port": tubport_endpoint,
"tub.location": tubport_location,
"web.port": ensure_text(webport_endpoint),
},
storage_plugin=self.storage_plugin,
basedir=self.basedir,

View File

@ -70,7 +70,13 @@ from ..scripts.common import (
def run_cli(*args, **kwargs):
"""
Backwards compatible version so we don't have to change all the tests.
Run a Tahoe-LAFS CLI utility, but inline.
Version of run_cli_unicode() that takes any kind of string, and the
command-line args inline instead of as verb + list.
Backwards compatible version so we don't have to change all the tests that
expected this API.
"""
nodeargs = [ensure_text(a) for a in kwargs.pop("nodeargs", [])]
kwargs["nodeargs"] = nodeargs
@ -658,7 +664,7 @@ def flush_but_dont_ignore(res):
def _render_config(config):
"""
Convert a ``dict`` of ``dict`` of ``bytes`` to an ini-format string.
Convert a ``dict`` of ``dict`` of ``unicode`` to an ini-format string.
"""
return u"\n\n".join(list(
_render_config_section(k, v)
@ -668,8 +674,8 @@ def _render_config(config):
def _render_config_section(heading, values):
"""
Convert a ``bytes`` heading and a ``dict`` of ``bytes`` to an ini-format
section as ``bytes``.
Convert a ``unicode`` heading and a ``dict`` of ``unicode`` to an ini-format
section as ``unicode``.
"""
return u"[{}]\n{}\n".format(
heading, _render_section_values(values)
@ -677,8 +683,8 @@ def _render_config_section(heading, values):
def _render_section_values(values):
"""
Convert a ``dict`` of ``bytes`` to the body of an ini-format section as
``bytes``.
Convert a ``dict`` of ``unicode`` to the body of an ini-format section as
``unicode``.
"""
return u"\n".join(list(
u"{} = {}".format(k, v)

View File

@ -134,8 +134,7 @@ def a2b(cs):
@param cs the base-32 encoded data (as bytes)
"""
# Workaround Future newbytes issues by converting to real bytes on Python 2:
if hasattr(cs, "__native__"):
cs = cs.__native__()
cs = backwardscompat_bytes(cs)
precondition(could_be_base32_encoded(cs), "cs is required to be possibly base32 encoded data.", cs=cs)
precondition(isinstance(cs, bytes), cs)

View File

@ -211,7 +211,15 @@ def compute_rate(bytes, seconds):
return 1.0 * bytes / seconds
def abbreviate_rate(data):
# 21.8kBps, 554.4kBps 4.37MBps
"""
Convert number of bytes/second into human readable strings (unicode).
Uses metric measures, so 1000 not 1024, e.g. 21.8kBps, 554.4kBps, 4.37MBps.
:param data: Either ``None`` or integer.
:return: Unicode string.
"""
if data is None:
return u""
r = float(data)
@ -222,7 +230,15 @@ def abbreviate_rate(data):
return u"%.0fBps" % r
def abbreviate_size(data):
# 21.8kB, 554.4kB 4.37MB
"""
Convert number of bytes into human readable strings (unicode).
Uses metric measures, so 1000 not 1024, e.g. 21.8kB, 554.4kB, 4.37MB.
:param data: Either ``None`` or integer.
:return: Unicode string.
"""
if data is None:
return u""
r = float(data)

View File

@ -105,6 +105,13 @@ class MultiFormatResource(resource.Resource, object):
def abbreviate_time(data):
"""
Convert number of seconds into human readable string.
:param data: Either ``None`` or integer or float, seconds.
:return: Unicode string.
"""
# 1.23s, 790ms, 132us
if data is None:
return u""