mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-11 07:23:04 +00:00
Try to fix some failing unit tests in ASCII locale.
This commit is contained in:
parent
dce8d3598a
commit
c76afc9ece
@ -10,17 +10,12 @@ import os.path
|
|||||||
import re
|
import re
|
||||||
import types
|
import types
|
||||||
import errno
|
import errno
|
||||||
from io import StringIO
|
|
||||||
import tempfile
|
import tempfile
|
||||||
from base64 import b32decode, b32encode
|
from base64 import b32decode, b32encode
|
||||||
|
|
||||||
# On Python 2 this will be the backported package.
|
# On Python 2 this will be the backported package.
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
from future.utils import PY2
|
|
||||||
if PY2:
|
|
||||||
from io import BytesIO as StringIO # noqa: F811
|
|
||||||
|
|
||||||
from twisted.python import log as twlog
|
from twisted.python import log as twlog
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
@ -213,7 +208,9 @@ def config_from_string(basedir, portnumfile, config_str, _valid_config=None):
|
|||||||
|
|
||||||
# load configuration from in-memory string
|
# load configuration from in-memory string
|
||||||
parser = configparser.SafeConfigParser()
|
parser = configparser.SafeConfigParser()
|
||||||
parser.readfp(StringIO(config_str))
|
if isinstance(config_str, bytes):
|
||||||
|
config_str = config_str.decode("utf-8")
|
||||||
|
parser.read_string(config_str)
|
||||||
|
|
||||||
fname = "<in-memory>"
|
fname = "<in-memory>"
|
||||||
configutil.validate_config(fname, parser, _valid_config)
|
configutil.validate_config(fname, parser, _valid_config)
|
||||||
|
@ -168,7 +168,11 @@ class Tor(unittest.TestCase):
|
|||||||
tor_provider = create_tor_provider(reactor, config)
|
tor_provider = create_tor_provider(reactor, config)
|
||||||
tor_provider.get_tor_handler()
|
tor_provider.get_tor_handler()
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"invalid literal for int() with base 10: 'kumquat'",
|
"invalid literal for int()",
|
||||||
|
str(ctx.exception)
|
||||||
|
)
|
||||||
|
self.assertIn(
|
||||||
|
"kumquat",
|
||||||
str(ctx.exception)
|
str(ctx.exception)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,15 +35,11 @@ def get_config(tahoe_cfg):
|
|||||||
Configuration is returned as native strings.
|
Configuration is returned as native strings.
|
||||||
"""
|
"""
|
||||||
config = SafeConfigParser(strict=False)
|
config = SafeConfigParser(strict=False)
|
||||||
with open(tahoe_cfg, "r") as f:
|
# Byte Order Mark is an optional garbage byte you sometimes get at the
|
||||||
# Who put the BOM in the BOM SHOO BOP SHOO BOP.
|
# start of UTF-8 encoded files. Especially on Windows. Skip it by using
|
||||||
#
|
# utf-8-sig. https://en.wikipedia.org/wiki/Byte_order_mark
|
||||||
# Byte Order Mark is an optional garbage byte you sometimes get at the
|
with open(tahoe_cfg, "r", encoding="utf-8-sig") as f:
|
||||||
# start of UTF-8 encoded files. Especially on Windows. Skip it.
|
config.read_file(f)
|
||||||
# https://en.wikipedia.org/wiki/Byte_order_mark
|
|
||||||
if f.read(1) != u'\uFEFF':
|
|
||||||
f.seek(0)
|
|
||||||
config.readfp(f)
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
def set_config(config, section, option, value):
|
def set_config(config, section, option, value):
|
||||||
|
Loading…
Reference in New Issue
Block a user