Fix some failing tests.

This commit is contained in:
Itamar Turner-Trauring
2020-10-30 13:59:57 -04:00
parent 6b4be7aee3
commit 6264cf15b1
3 changed files with 8 additions and 13 deletions

View File

@ -131,7 +131,7 @@ def _valid_config():
return cfg.update(_client_config) return cfg.update(_client_config)
# this is put into README in new node-directories # this is put into README in new node-directories
CLIENT_README = """ CLIENT_README = u"""
This directory contains files which contain private data for the Tahoe node, This directory contains files which contain private data for the Tahoe node,
such as private keys. On Unix-like systems, the permissions on this directory such as private keys. On Unix-like systems, the permissions on this directory
are set to disallow users other than its owner from reading the contents of are set to disallow users other than its owner from reading the contents of
@ -512,7 +512,7 @@ def create_introducer_clients(config, main_tub, _introducer_factory=None):
config.nickname, config.nickname,
str(allmydata.__full_version__), str(allmydata.__full_version__),
str(_Client.OLDEST_SUPPORTED_VERSION), str(_Client.OLDEST_SUPPORTED_VERSION),
node.get_app_versions(), list(node.get_app_versions()),
partial(_sequencer, config), partial(_sequencer, config),
introducer_cache_filepath, introducer_cache_filepath,
) )

View File

@ -106,8 +106,8 @@ def formatTimeTahoeStyle(self, when):
""" """
d = datetime.datetime.utcfromtimestamp(when) d = datetime.datetime.utcfromtimestamp(when)
if d.microsecond: if d.microsecond:
return d.isoformat(" ")[:-3]+"Z" return d.isoformat(ensure_str(" "))[:-3]+"Z"
return d.isoformat(" ") + ".000Z" return d.isoformat(ensure_str(" ")) + ".000Z"
PRIV_README = """ PRIV_README = """
This directory contains files which contain private data for the Tahoe node, This directory contains files which contain private data for the Tahoe node,
@ -161,6 +161,7 @@ def create_node_dir(basedir, readme_text):
privdir = os.path.join(basedir, "private") privdir = os.path.join(basedir, "private")
if not os.path.exists(privdir): if not os.path.exists(privdir):
fileutil.make_dirs(privdir, 0o700) fileutil.make_dirs(privdir, 0o700)
readme_text = ensure_text(readme_text)
with open(os.path.join(privdir, 'README'), 'w') as f: with open(os.path.join(privdir, 'README'), 'w') as f:
f.write(readme_text) f.write(readme_text)

View File

@ -112,11 +112,11 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
@defer.inlineCallbacks @defer.inlineCallbacks
def test_comment(self): def test_comment(self):
""" """
An unescaped comment character (#) in a furl results in an A comment character (#) in a furl results in an
UnescapedHashError Failure. UnescapedHashError Failure.
""" """
should_fail = [r"test#test", r"#testtest", r"test\\#test"] should_fail = [r"test#test", r"#testtest", r"test\\#test", r"test\#test",
should_not_fail = [r"test\#test", r"test\\\#test", r"testtest"] r"test\\\#test"]
basedir = "test_client.Basic.test_comment" basedir = "test_client.Basic.test_comment"
os.mkdir(basedir) os.mkdir(basedir)
@ -127,17 +127,11 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase):
fileutil.write(os.path.join(basedir, "tahoe.cfg"), config) fileutil.write(os.path.join(basedir, "tahoe.cfg"), config)
for s in should_fail: for s in should_fail:
self.failUnless(_Config._contains_unescaped_hash(s))
write_config(s) write_config(s)
with self.assertRaises(UnescapedHashError) as ctx: with self.assertRaises(UnescapedHashError) as ctx:
yield client.create_client(basedir) yield client.create_client(basedir)
self.assertIn("[client]introducer.furl", str(ctx.exception)) self.assertIn("[client]introducer.furl", str(ctx.exception))
for s in should_not_fail:
self.failIf(_Config._contains_unescaped_hash(s))
write_config(s)
yield client.create_client(basedir)
def test_unreadable_config(self): def test_unreadable_config(self):
if sys.platform == "win32": if sys.platform == "win32":
# if somebody knows a clever way to do this (cause # if somebody knows a clever way to do this (cause