Add test_broken_symlink_is_ignored.
This commit is contained in:
parent
067b47fceb
commit
ecfd46d16d
|
@ -282,7 +282,8 @@ class Sender:
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
errmsg = u"{}: {}".format(fn, e.strerror)
|
errmsg = u"{}: {}".format(fn, e.strerror)
|
||||||
if self._args.ignore_unsendable_files:
|
if self._args.ignore_unsendable_files:
|
||||||
print(u"{} (ignoring error)".format(errmsg))
|
print(u"{} (ignoring error)".format(errmsg),
|
||||||
|
file=args.stderr)
|
||||||
else:
|
else:
|
||||||
raise UnsendableFileError(errmsg)
|
raise UnsendableFileError(errmsg)
|
||||||
fd_to_send.seek(0,2)
|
fd_to_send.seek(0,2)
|
||||||
|
|
|
@ -66,7 +66,7 @@ class OfferData(unittest.TestCase):
|
||||||
self.assertEqual(fd_to_send.tell(), 0)
|
self.assertEqual(fd_to_send.tell(), 0)
|
||||||
self.assertEqual(fd_to_send.read(), message)
|
self.assertEqual(fd_to_send.read(), message)
|
||||||
|
|
||||||
def test_broken_symlink(self):
|
def _create_broken_symlink(self):
|
||||||
if not hasattr(os, 'symlink'):
|
if not hasattr(os, 'symlink'):
|
||||||
raise unittest.SkipTest("host OS does not support symlinks")
|
raise unittest.SkipTest("host OS does not support symlinks")
|
||||||
|
|
||||||
|
@ -81,9 +81,20 @@ class OfferData(unittest.TestCase):
|
||||||
self.cfg.what = send_dir_arg
|
self.cfg.what = send_dir_arg
|
||||||
self.cfg.cwd = parent_dir
|
self.cfg.cwd = parent_dir
|
||||||
|
|
||||||
|
def test_broken_symlink_raises_err(self):
|
||||||
|
self._create_broken_symlink()
|
||||||
|
self.cfg.ignore_unsendable_files = False
|
||||||
e = self.assertRaises(UnsendableFileError, build_offer, self.cfg)
|
e = self.assertRaises(UnsendableFileError, build_offer, self.cfg)
|
||||||
self.assertEqual(str(e), "linky: No such file or directory")
|
self.assertEqual(str(e), "linky: No such file or directory")
|
||||||
|
|
||||||
|
def test_broken_symlink_is_ignored(self):
|
||||||
|
self._create_broken_symlink()
|
||||||
|
self.cfg.ignore_unsendable_files = True
|
||||||
|
d, fd_to_send = build_offer(self.cfg)
|
||||||
|
self.assertIn('(ignoring error)', self.cfg.stderr.getvalue())
|
||||||
|
self.assertEqual(d['directory']['numfiles'], 0)
|
||||||
|
self.assertEqual(d['directory']['numbytes'], 0)
|
||||||
|
|
||||||
def test_missing_file(self):
|
def test_missing_file(self):
|
||||||
self.cfg.what = filename = "missing"
|
self.cfg.what = filename = "missing"
|
||||||
send_dir = self.mktemp()
|
send_dir = self.mktemp()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user