mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +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 types
|
||||
import errno
|
||||
from io import StringIO
|
||||
import tempfile
|
||||
from base64 import b32decode, b32encode
|
||||
|
||||
# On Python 2 this will be the backported package.
|
||||
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.application import service
|
||||
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
|
||||
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>"
|
||||
configutil.validate_config(fname, parser, _valid_config)
|
||||
|
@ -168,7 +168,11 @@ class Tor(unittest.TestCase):
|
||||
tor_provider = create_tor_provider(reactor, config)
|
||||
tor_provider.get_tor_handler()
|
||||
self.assertIn(
|
||||
"invalid literal for int() with base 10: 'kumquat'",
|
||||
"invalid literal for int()",
|
||||
str(ctx.exception)
|
||||
)
|
||||
self.assertIn(
|
||||
"kumquat",
|
||||
str(ctx.exception)
|
||||
)
|
||||
|
||||
|
@ -35,15 +35,11 @@ def get_config(tahoe_cfg):
|
||||
Configuration is returned as native strings.
|
||||
"""
|
||||
config = SafeConfigParser(strict=False)
|
||||
with open(tahoe_cfg, "r") as f:
|
||||
# Who put the BOM in the BOM SHOO BOP SHOO BOP.
|
||||
#
|
||||
# Byte Order Mark is an optional garbage byte you sometimes get at the
|
||||
# start of UTF-8 encoded files. Especially on Windows. Skip it.
|
||||
# https://en.wikipedia.org/wiki/Byte_order_mark
|
||||
if f.read(1) != u'\uFEFF':
|
||||
f.seek(0)
|
||||
config.readfp(f)
|
||||
# Byte Order Mark is an optional garbage byte you sometimes get at the
|
||||
# start of UTF-8 encoded files. Especially on Windows. Skip it by using
|
||||
# utf-8-sig. https://en.wikipedia.org/wiki/Byte_order_mark
|
||||
with open(tahoe_cfg, "r", encoding="utf-8-sig") as f:
|
||||
config.read_file(f)
|
||||
return config
|
||||
|
||||
def set_config(config, section, option, value):
|
||||
|
Loading…
Reference in New Issue
Block a user