def opt_exclude_from(self, filepath):
"""Ignore file matching glob patterns listed in file, one per
line. The file is assumed to be in the argv encoding."""
+ abs_filepath = argv_to_abspath(filepath)
try:
- exclude_file = file(filepath)
+ exclude_file = file(abs_filepath)
except:
- raise BackupConfigurationError('Error opening exclude file %r.' % filepath)
+ raise BackupConfigurationError('Error opening exclude file %s.' % quote_output(abs_filepath))
try:
for line in exclude_file:
self.opt_exclude(line)
import urllib, re
import simplejson
+from mock import patch
+
from allmydata.util import fileutil, hashutil, base32
from allmydata import uri
from allmydata.immutable import upload
self._check_filtering(filtered, root_listdir, (u'lib.a', u'_darcs', u'subdir'),
(nice_doc,))
+ @patch('__builtin__.file')
+ def test_exclude_from_tilde_expansion(self, mock):
+ basedir = "cli/Backup/exclude_from_tilde_expansion"
+ fileutil.make_dirs(basedir)
+ nodeurl_path = os.path.join(basedir, 'node.url')
+ fileutil.write(nodeurl_path, 'http://example.net:2357/')
+
+ # ensure that tilde expansion is performed on exclude-from argument
+ exclude_file = u'~/.tahoe/excludes.dummy'
+ backup_options = cli.BackupOptions()
+
+ mock.return_value = StringIO()
+ backup_options.parseOptions(['--exclude-from', unicode_to_argv(exclude_file),
+ '--node-directory', basedir, 'from', 'to'])
+ self.failUnlessIn(((abspath_expanduser_unicode(exclude_file),), {}), mock.call_args_list)
+
def test_ignore_symlinks(self):
if not hasattr(os, 'symlink'):
raise unittest.SkipTest("Symlinks are not supported by Python on this platform.")