mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 13:33:09 +00:00
All tests pass on Python 3.
This commit is contained in:
parent
51d472e221
commit
f7a89f76e7
@ -1,3 +1,4 @@
|
||||
from future.utils import PY2
|
||||
from past.builtins import unicode
|
||||
|
||||
import base64
|
||||
@ -153,8 +154,12 @@ class TestCase(testutil.SignalMixin, unittest.TestCase):
|
||||
f.close()
|
||||
|
||||
config = read_config(basedir, "")
|
||||
self.failUnlessEqual(config.get_config("node", "nickname").decode('utf-8'),
|
||||
u"\u2621")
|
||||
# Config returns native strings:
|
||||
expected_nick = u"\u2621"
|
||||
if PY2:
|
||||
expected_nick = expected_nick.encode("utf-8")
|
||||
self.failUnlessEqual(config.get_config("node", "nickname"),
|
||||
expected_nick)
|
||||
|
||||
def test_tahoe_cfg_hash_in_name(self):
|
||||
basedir = "test_node/test_cfg_hash_in_name"
|
||||
|
@ -10,7 +10,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2
|
||||
from future.utils import PY2, PY3
|
||||
if PY2:
|
||||
# We don't do open(), because we want files to read/write native strs when
|
||||
# we do "r" or "w".
|
||||
@ -42,11 +42,12 @@ def get_config(tahoe_cfg):
|
||||
"""
|
||||
config = SafeConfigParser()
|
||||
with open(tahoe_cfg, "r") as f:
|
||||
# On Python 2, where we read in bytes, skip any initial Byte Order
|
||||
# Mark. Since this is an ordinary file, we don't need to handle
|
||||
# incomplete reads, and can assume seekability.
|
||||
# Skip any initial Byte Order Mark. Since this is an ordinary file, we
|
||||
# don't need to handle incomplete reads, and can assume seekability.
|
||||
if PY2 and f.read(3) != b'\xEF\xBB\xBF':
|
||||
f.seek(0)
|
||||
if PY3 and f.read(1) != u"\uFEFF":
|
||||
f.seek(0)
|
||||
config.readfp(f)
|
||||
return config
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user