duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #04781
[Merge] lp:~aaron-whitehouse/duplicity/08-adorn-strings into lp:duplicity
Aaron Whitehouse has proposed merging lp:~aaron-whitehouse/duplicity/08-adorn-strings into lp:duplicity.
Commit message:
Adorning string literals (normally to make these unicode), in support of a transition to Python 3.
See https://blueprints.launchpad.net/duplicity/+spec/adorn-string-literals
* Adorn string in duplicity/globmatch.py.
* Adorn strings in testing/unit/test_globmatch.py
* Adorn strings in selection.py
* Adorn strings in functional/test_selection.py and unit/test_selection.py
* Remove ignores for these files in test_code.py
Requested reviews:
duplicity-team (duplicity-team)
For more details, see:
https://code.launchpad.net/~aaron-whitehouse/duplicity/08-adorn-strings/+merge/350078
Adorning string literals (normally to make these unicode), in support of a transition to Python 3.
See https://blueprints.launchpad.net/duplicity/+spec/adorn-string-literals
* Adorn string in duplicity/globmatch.py.
* Adorn strings in testing/unit/test_globmatch.py
* Adorn strings in selection.py
* Adorn strings in functional/test_selection.py and unit/test_selection.py
* Remove ignores for these files in test_code.py
Note that I accidentally wrote "adorn globs" instead of "adorn strings" in some of the commit messages.
--
Your team duplicity-team is requested to review the proposed merge of lp:~aaron-whitehouse/duplicity/08-adorn-strings into lp:duplicity.
=== modified file 'duplicity/globmatch.py'
--- duplicity/globmatch.py 2017-12-01 22:39:33 +0000
+++ duplicity/globmatch.py 2018-07-19 21:12:04 +0000
@@ -30,17 +30,17 @@
class GlobbingError(Exception):
- """Something has gone wrong when parsing a glob string"""
+ u"""Something has gone wrong when parsing a glob string"""
pass
class FilePrefixError(GlobbingError):
- """Signals that a specified file doesn't start with correct prefix"""
+ u"""Signals that a specified file doesn't start with correct prefix"""
pass
def _glob_get_prefix_regexs(glob_str):
- """Return list of regexps equivalent to prefixes of glob_str"""
+ u"""Return list of regexps equivalent to prefixes of glob_str"""
# Internal. Used by glob_get_normal_sf.
glob_parts = glob_str.split(u"/")
if u"" in glob_parts[1:-1]:
@@ -56,7 +56,7 @@
def select_fn_from_glob(glob_str, include, ignore_case=False):
- """Return a function test_fn(path) which
+ u"""Return a function test_fn(path) which
tests whether path matches glob, as per the Unix shell rules, taking as
arguments a path, a glob string and include (0 indicating that the glob
string is an exclude glob and 1 indicating that it is an include glob,
@@ -147,7 +147,7 @@
def glob_to_regex(pat):
- """Returned regular expression equivalent to shell glob pat
+ u"""Returned regular expression equivalent to shell glob pat
Currently only the ?, *, [], and ** expressions are supported.
Ranges like [a-z] are currently unsupported. There is no
@@ -161,7 +161,7 @@
assert isinstance(pat, unicode)
- i, n, res = 0, len(pat), ''
+ i, n, res = 0, len(pat), u''
while i < n:
c, s = pat[i], pat[i:i + 2]
i = i + 1
=== modified file 'duplicity/selection.py'
--- duplicity/selection.py 2018-06-08 09:46:45 +0000
+++ duplicity/selection.py 2018-07-19 21:12:04 +0000
@@ -35,7 +35,7 @@
from duplicity.globmatch import GlobbingError, FilePrefixError, \
select_fn_from_glob
-"""Iterate exactly the requested files in a directory
+u"""Iterate exactly the requested files in a directory
Parses includes and excludes to yield correct files. More
documentation on what this code does can be found on the man page.
@@ -44,12 +44,12 @@
class SelectError(Exception):
- """Some error dealing with the Select class"""
+ u"""Some error dealing with the Select class"""
pass
class Select:
- """Iterate appropriate Paths in given directory
+ u"""Iterate appropriate Paths in given directory
This class acts as an iterator on account of its next() method.
Basically, it just goes through all the files in a directory in
@@ -83,17 +83,17 @@
"""
# This re should not match normal filenames, but usually just globs
- glob_re = re.compile("(.*[*?[]|ignorecase\\:)", re.I | re.S)
+ glob_re = re.compile(u"(.*[*?[]|ignorecase\\:)", re.I | re.S)
def __init__(self, path):
- """Initializer, called with Path of root directory"""
+ u"""Initializer, called with Path of root directory"""
assert isinstance(path, Path), str(path)
self.selection_functions = []
self.rootpath = path
self.prefix = self.rootpath.uc_name
def set_iter(self):
- """Initialize generator, prepare to iterate."""
+ u"""Initialize generator, prepare to iterate."""
# Externally-accessed method
self.rootpath.setdata() # this may have changed since Select init
self.iter = self.Iterate(self.rootpath)
@@ -102,7 +102,7 @@
return self
def Iterate(self, path):
- """Return iterator yielding paths in path
+ u"""Return iterator yielding paths in path
This function looks a bit more complicated than it needs to be
because it avoids extra recursion (and no extra function calls
@@ -116,20 +116,20 @@
try:
mode = os.stat(fullpath)[stat.ST_MODE]
if stat.S_ISSOCK(mode):
- log.Info(_("Skipping socket %s") % util.fsdecode(fullpath),
+ log.Info(_(u"Skipping socket %s") % util.fsdecode(fullpath),
log.InfoCode.skipping_socket,
util.escape(fullpath))
else:
- log.Warn(_("Error initializing file %s") % util.fsdecode(fullpath),
+ log.Warn(_(u"Error initializing file %s") % util.fsdecode(fullpath),
log.WarningCode.cannot_iterate,
util.escape(fullpath))
except OSError:
- log.Warn(_("Error accessing possibly locked file %s") % util.fsdecode(fullpath),
+ log.Warn(_(u"Error accessing possibly locked file %s") % util.fsdecode(fullpath),
log.WarningCode.cannot_stat, util.escape(fullpath))
return None
def diryield(path):
- """Generate relevant files in directory path
+ u"""Generate relevant files in directory path
Returns (path, num) where num == 0 means path should be
generated normally, num == 1 means the path is a directory
@@ -144,12 +144,12 @@
error_handler, Path.append, (path, filename))
if new_path:
s = self.Select(new_path)
- if (new_path.type in ["reg", "dir"]
+ if (new_path.type in [u"reg", u"dir"]
and not os.access(new_path.name, os.R_OK)) \
and (s == 1 or s == 2):
# Path is a file or folder that cannot be read, but
# should be included or scanned.
- log.Warn(_("Error accessing possibly locked file %s") %
+ log.Warn(_(u"Error accessing possibly locked file %s") %
new_path.uc_name,
log.WarningCode.cannot_read,
util.escape(new_path.name))
@@ -197,7 +197,7 @@
diryield_stack.append(diryield(subpath))
def Select(self, path):
- """Run through the selection functions and return dominant val 0/1/2"""
+ u"""Run through the selection functions and return dominant val 0/1/2"""
# Only used by diryield and tests. Internal.
log.Debug(u"Selection: examining path %s" % path.uc_name)
if not self.selection_functions:
@@ -234,7 +234,7 @@
return result
def ParseArgs(self, argtuples, filelists):
- """Create selection functions based on list of tuples
+ u"""Create selection functions based on list of tuples
The tuples are created when the initial commandline arguments
are read. They have the form (option string, additional
@@ -246,9 +246,9 @@
filelists_index = 0
try:
for opt, arg in argtuples:
- assert isinstance(opt, unicode), u"option " + opt.decode(sys.getfilesystemencoding(), "ignore") + \
+ assert isinstance(opt, unicode), u"option " + opt.decode(sys.getfilesystemencoding(), u"ignore") + \
u" is not unicode"
- assert isinstance(arg, unicode), u"option " + arg.decode(sys.getfilesystemencoding(), "ignore") + \
+ assert isinstance(arg, unicode), u"option " + arg.decode(sys.getfilesystemencoding(), u"ignore") + \
u" is not unicode"
if opt == u"--exclude":
@@ -287,7 +287,7 @@
self.parse_last_excludes()
def parse_catch_error(self, exc):
- """Deal with selection error exc"""
+ u"""Deal with selection error exc"""
# Internal, used by ParseArgs.
if isinstance(exc, FilePrefixError):
log.FatalError(_(u"""\
@@ -300,12 +300,12 @@
(exc, self.prefix), log.ErrorCode.file_prefix_error)
elif isinstance(exc, GlobbingError):
log.FatalError(_(u"Fatal Error while processing expression\n"
- "%s") % exc, log.ErrorCode.globbing_error)
+ u"%s") % exc, log.ErrorCode.globbing_error)
else:
raise # pylint: disable=misplaced-bare-raise
def parse_last_excludes(self):
- """Exit with error if last selection function isn't an exclude"""
+ u"""Exit with error if last selection function isn't an exclude"""
# Internal. Used by ParseArgs.
if (self.selection_functions and not self.selection_functions[-1].exclude):
log.FatalError(_(u"""\
@@ -318,7 +318,7 @@
log.ErrorCode.redundant_inclusion)
def add_selection_func(self, sel_func, add_to_start=None):
- """Add another selection function at the end or beginning"""
+ u"""Add another selection function at the end or beginning"""
# Internal. Used by ParseArgs.
if add_to_start:
self.selection_functions.insert(0, sel_func)
@@ -326,7 +326,7 @@
self.selection_functions.append(sel_func)
def filelist_sanitise_line(self, line, include_default):
- """
+ u"""
Sanitises lines of both normal and globbing filelists, returning (line, include) and line=None if blank/comment
The aim is to parse filelists in a consistent way, prior to the interpretation of globbing statements.
@@ -355,7 +355,7 @@
return line, include
def filelist_globbing_get_sfs(self, filelist_fp, inc_default, list_name):
- """Return list of selection functions by reading fileobj
+ u"""Return list of selection functions by reading fileobj
filelist_fp should be an open file object
inc_default is true iff this is an include list
@@ -375,7 +375,7 @@
yield self.glob_get_sf(line, include)
def other_filesystems_get_sf(self, include):
- """Return selection function matching files on other filesystems"""
+ u"""Return selection function matching files on other filesystems"""
# Internal. Used by ParseArgs and unit tests.
assert include == 0 or include == 1
root_devloc = self.rootpath.getdevloc()
@@ -391,7 +391,7 @@
return sel_func
def regexp_get_sf(self, regexp_string, include):
- """Return selection function given by regexp_string"""
+ u"""Return selection function given by regexp_string"""
# Internal. Used by ParseArgs and unit tests.
assert include == 0 or include == 1
try:
@@ -411,11 +411,11 @@
return sel_func
def devfiles_get_sf(self):
- """Return a selection function to exclude all dev files"""
+ u"""Return a selection function to exclude all dev files"""
# Internal. Used by ParseArgs.
if self.selection_functions:
log.Warn(_(u"Warning: exclude-device-files is not the first "
- "selector.\nThis may not be what you intended"))
+ u"selector.\nThis may not be what you intended"))
def sel_func(path):
if path.isdev():
@@ -428,7 +428,7 @@
return sel_func
def glob_get_sf(self, glob_str, include):
- """Return selection function given by glob string"""
+ u"""Return selection function given by glob string"""
# Internal. Used by ParseArgs, filelist_globbing_get_sfs and unit tests.
assert include == 0 or include == 1
assert isinstance(glob_str, unicode)
@@ -443,7 +443,7 @@
return sel_func
def present_get_sf(self, filename, include):
- """Return selection function given by existence of a file in a directory"""
+ u"""Return selection function given by existence of a file in a directory"""
# Internal. Used by ParseArgs.
assert include == 0 or include == 1
@@ -479,7 +479,7 @@
return sel_func
def glob_get_normal_sf(self, glob_str, include):
- """Return selection function based on glob_str
+ u"""Return selection function based on glob_str
The basic idea is to turn glob_str into a regular expression,
and just use the normal regular expression. There is a
@@ -494,13 +494,13 @@
"""
assert isinstance(glob_str, unicode), \
- u"The glob string " + glob_str.decode(sys.getfilesystemencoding(), "ignore") + u" is not unicode"
+ u"The glob string " + glob_str.decode(sys.getfilesystemencoding(), u"ignore") + u" is not unicode"
ignore_case = False
- if glob_str.lower().startswith("ignorecase:"):
+ if glob_str.lower().startswith(u"ignorecase:"):
# Glob string starts with ignorecase, so remove that from the
# string and change it to lowercase.
- glob_str = glob_str[len("ignorecase:"):].lower()
+ glob_str = glob_str[len(u"ignorecase:"):].lower()
ignore_case = True
# Check to make sure prefix is ok, i.e. the glob string is within
@@ -508,13 +508,13 @@
file_prefix_selection = select_fn_from_glob(glob_str, include=1)(self.rootpath)
if not file_prefix_selection:
# file_prefix_selection == 1 (include) or 2 (scan)
- raise FilePrefixError(glob_str + " glob with " + self.rootpath.name
- + " path gives " + str(file_prefix_selection))
+ raise FilePrefixError(glob_str + u" glob with " + self.rootpath.uc_name
+ + u" path gives " + unicode(file_prefix_selection))
return select_fn_from_glob(glob_str, include, ignore_case)
def exclude_older_get_sf(self, date):
- """Return selection function based on files older than modification date """
+ u"""Return selection function based on files older than modification date """
# Internal. Used by ParseArgs.
def sel_func(path):
@@ -528,5 +528,5 @@
return None
sel_func.exclude = True
- sel_func.name = "Select older than %s" % (date,)
+ sel_func.name = u"Select older than %s" % (date,)
return sel_func
=== modified file 'testing/functional/test_selection.py'
--- testing/functional/test_selection.py 2017-07-15 20:31:11 +0000
+++ testing/functional/test_selection.py 2018-07-19 21:12:04 +0000
@@ -30,7 +30,7 @@
class IncludeExcludeFunctionalTest(FunctionalTestCase):
- """
+ u"""
This contains methods used in the tests below for testing the include, exclude and various filelist features.
"""
@@ -146,7 +146,7 @@
[u"trailing_space sub2_file.txt"]]
def directory_tree_to_list_of_lists(self, parent_directory):
- """
+ u"""
This takes a folder as an input and returns a list with its contents. If the directory has subdirectories, it
returns a list of lists with the contents of those subdirectories.
"""
@@ -165,20 +165,20 @@
class TestCheckTestFiles(IncludeExcludeFunctionalTest):
- """ Tests the testfiles required by the exclude/include tests are as expected. """
+ u""" Tests the testfiles required by the exclude/include tests are as expected. """
def test_files_are_as_expected(self):
- """Test that the contents of testfiles/select are as expected."""
+ u"""Test that the contents of testfiles/select are as expected."""
testfiles = self.directory_tree_to_list_of_lists(u"testfiles/select2")
# print(testfiles)
self.assertEqual(testfiles, self.complete_directory_tree)
class TestIncludeExcludeOptions(IncludeExcludeFunctionalTest):
- """ This tests the behaviour of the duplicity binary when the include/exclude options are passed directly """
+ u""" This tests the behaviour of the duplicity binary when the include/exclude options are passed directly """
def test_include_exclude_basic(self):
- """ Test --include and --exclude work in the basic case """
+ u""" Test --include and --exclude work in the basic case """
self.backup(u"full", u"testfiles/select2",
options=[u"--include", u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt",
u"--exclude", u"testfiles/select2/3/3sub3/3sub3sub2",
@@ -205,7 +205,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_include_exclude_trailing_whitespace(self):
- """Test that folders with trailing whitespace in the names work correctly when passing as include/exclude"""
+ u"""Test that folders with trailing whitespace in the names work correctly when passing as include/exclude"""
# Note that, because this only passes items in as a list of options, this test does not test whether duplicity
# would correctly interpret commandline options with spaces. However, bin/duplicity uses sys.argv[1:], which
# should return a list of strings after having correctly processed quotes etc.
@@ -240,12 +240,12 @@
class TestExcludeFilelistTest(IncludeExcludeFunctionalTest):
- """
+ u"""
Test --exclude-filelist using duplicity binary.
"""
def test_exclude_filelist(self):
- """Test that exclude filelist works in the basic case """
+ u"""Test that exclude filelist works in the basic case """
# As this is an exclude filelist any lines with no +/- modifier should be treated as if they have a -.
# Create a filelist
with io.open(u"testfiles/exclude.txt", u"w") as f:
@@ -275,7 +275,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_exclude_filelist_combined_imperfections(self):
- """Test that exclude filelist works with imperfections in the input file"""
+ u"""Test that exclude filelist works with imperfections in the input file"""
# This is a combined test for speed reasons. The individual imperfections are tested as unittests in
# unit/test_selection.
# Imperfections tested are;
@@ -318,7 +318,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_exclude_globbing_filelist_combined_imperfections(self):
- """Test that exclude globbing filelist works with imperfections in the input file"""
+ u"""Test that exclude globbing filelist works with imperfections in the input file"""
# Identical to test_exclude_filelist_combined_imperfections and included to ensure that
# the deprecated --exclude-globbing-filelist function works as expected until it is deliberately removed.
# This is a combined test for speed reasons. The individual imperfections are tested as unittests in
@@ -363,7 +363,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_exclude_filelist_trailing_whitespace_folders_work_with_quotes(self):
- """Test that folders with trailing whitespace in the names work correctly if they are enclosed in quotes"""
+ u"""Test that folders with trailing whitespace in the names work correctly if they are enclosed in quotes"""
# Create a filelist
with io.open(u"testfiles/exclude.txt", u"w") as f:
f.write(u'+ "testfiles/select2/trailing_space /trailing_space sub2/trailing_space sub2_file.txt"\n' # New
@@ -395,7 +395,7 @@
self.assertEqual(restored, self.expected_restored_tree_with_trailing_space)
def test_exclude_filelist_progress_option(self):
- """Test that exclude filelist is unaffected by the --progress option"""
+ u"""Test that exclude filelist is unaffected by the --progress option"""
# Regression test for Bug #1264744 (https://bugs.launchpad.net/duplicity/+bug/1264744)
# Create a filelist identical to that used in test_exclude_filelist
with io.open(u"testfiles/exclude.txt", u"w") as f:
@@ -430,12 +430,12 @@
class TestIncludeFilelistTest(IncludeExcludeFunctionalTest):
- """
+ u"""
Test --include-filelist using duplicity binary.
"""
def test_include_filelist(self):
- """Test that include filelist works in the basic case"""
+ u"""Test that include filelist works in the basic case"""
# See test_exclude_filelist above for explanation of what is expected. As this is an include filelist
# any lines with no +/- modifier should be treated as if they have a +.
# Create a filelist
@@ -466,7 +466,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_include_filelist_combined_imperfections(self):
- """Test that include filelist works with imperfections in the input file"""
+ u"""Test that include filelist works with imperfections in the input file"""
# This is a combined test for speed reasons. The individual imperfections are tested as unittests in
# unit/test_selection.
# Imperfections tested are;
@@ -508,7 +508,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_include_filelist_workaround_combined_imperfections_no_wildcards(self):
- """Test that include filelist works with imperfections in the input file"""
+ u"""Test that include filelist works with imperfections in the input file"""
# This is a modified version of test_include_filelist that passes, despite Bug #1408411
# It is still a valid test, it just does not test as many selection features as the above.
# This is a combined test for speed reasons. The individual imperfections are tested as unittests in
@@ -556,7 +556,7 @@
self.assertEqual(restored, self.expected_restored_tree)
def test_include_globbing_filelist_combined_imperfections(self):
- """Test that include globbing filelist works with imperfections in the input file"""
+ u"""Test that include globbing filelist works with imperfections in the input file"""
# Identical to test_include_filelist_combined_imperfections and included to ensure that
# the deprecated --include-globbing-filelist function works as expected until it is deliberately removed.
# This is a combined test for speed reasons. The individual imperfections are tested as unittests in
@@ -601,11 +601,11 @@
class TestIncludeExcludedForContents(IncludeExcludeFunctionalTest):
- """ Test to check that folders that are excluded are included if they contain includes of higher priority.
+ u""" Test to check that folders that are excluded are included if they contain includes of higher priority.
Exhibits the issue reported in Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411). """
def write_filelist(self, filelist_name):
- """Used by the below tests to write the filelist"""
+ u"""Used by the below tests to write the filelist"""
assert filelist_name is not None
with io.open(filelist_name, u"w") as f:
f.write(u"+ testfiles/select/1/2/1\n"
@@ -614,14 +614,14 @@
u"- testfiles/select/1/3")
def restore_and_check(self):
- """Restores the backup and compares to what was expected (based on the filelist in write_filelist)"""
+ u"""Restores the backup and compares to what was expected (based on the filelist in write_filelist)"""
self.restore()
restore_dir = u"testfiles/restore_out"
restored = self.directory_tree_to_list_of_lists(restore_dir)
self.assertEqual(restored, [[u"2"], [u"1"]])
def test_commandline_include_exclude(self):
- """test an excluded folder is included for included contents when using commandline includes and excludes"""
+ u"""test an excluded folder is included for included contents when using commandline includes and excludes"""
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"testfiles/select/1/2/1",
u"--exclude", u"testfiles/select/1/2",
@@ -630,28 +630,28 @@
self.restore_and_check()
def test_include_globbing_filelist(self):
- """test an excluded folder is included for included contents with an include-globbing-filelist """
+ u"""test an excluded folder is included for included contents with an include-globbing-filelist """
# Deprecated, but include for now to ensure it keeps working until it is deliberately removed.
self.write_filelist(u"testfiles/include.txt")
self.backup(u"full", u"testfiles/select/1", options=[u"--include-globbing-filelist=testfiles/include.txt"])
self.restore_and_check()
def test_exclude_globbing_filelist(self):
- """test an excluded folder is included for included contents with an exclude-globbing-filelist """
+ u"""test an excluded folder is included for included contents with an exclude-globbing-filelist """
# Deprecated, but include for now to ensure it keeps working until it is deliberately removed.
self.write_filelist(u"testfiles/exclude.txt")
self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-globbing-filelist=testfiles/exclude.txt"])
self.restore_and_check()
def test_include_filelist(self):
- """test an excluded folder is included for included contents with an include-filelist (non-globbing) """
+ u"""test an excluded folder is included for included contents with an include-filelist (non-globbing) """
# Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411)
self.write_filelist(u"testfiles/include.txt")
self.backup(u"full", u"testfiles/select/1", options=[u"--include-filelist=testfiles/include.txt"])
self.restore_and_check()
def test_exclude_filelist(self):
- """test an excluded folder is included for included contents with an exclude-filelist (non-globbing) """
+ u"""test an excluded folder is included for included contents with an exclude-filelist (non-globbing) """
# Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411)
self.write_filelist(u"testfiles/exclude.txt")
self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/exclude.txt"])
@@ -659,19 +659,19 @@
class TestAsterisks(IncludeExcludeFunctionalTest):
- """ Test to check that asterisks work as expected
+ u""" Test to check that asterisks work as expected
Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371).
See the unit tests for more granularity on the issue."""
def restore_and_check(self):
- """Restores the backup and compares to what is expected."""
+ u"""Restores the backup and compares to what is expected."""
self.restore()
restore_dir = u"testfiles/restore_out"
restored = self.directory_tree_to_list_of_lists(restore_dir)
self.assertEqual(restored, [[u"2"], [u"1"]])
def test_exclude_filelist_asterisks_none(self):
- """Basic exclude filelist."""
+ u"""Basic exclude filelist."""
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ testfiles/select/1/2/1\n"
u"- testfiles/select/1/2\n"
@@ -681,7 +681,7 @@
self.restore_and_check()
def test_exclude_filelist_asterisks_single(self):
- """Exclude filelist with asterisks replacing folders."""
+ u"""Exclude filelist with asterisks replacing folders."""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ */select/1/2/1\n"
@@ -692,7 +692,7 @@
self.restore_and_check()
def test_exclude_filelist_asterisks_double_asterisks(self):
- """Exclude filelist with double asterisks replacing folders."""
+ u"""Exclude filelist with double asterisks replacing folders."""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ **/1/2/1\n"
@@ -703,7 +703,7 @@
self.restore_and_check()
def test_commandline_asterisks_single_excludes_only(self):
- """test_commandline_include_exclude with single asterisks on exclude lines."""
+ u"""test_commandline_include_exclude with single asterisks on exclude lines."""
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"testfiles/select/1/2/1",
u"--exclude", u"testfiles/*/1/2",
@@ -712,7 +712,7 @@
self.restore_and_check()
def test_commandline_asterisks_single_both(self):
- """test_commandline_include_exclude with single asterisks on both exclude and include lines."""
+ u"""test_commandline_include_exclude with single asterisks on both exclude and include lines."""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"*/select/1/2/1",
@@ -722,7 +722,7 @@
self.restore_and_check()
def test_commandline_asterisks_double_exclude_only(self):
- """test_commandline_include_exclude with double asterisks on exclude lines."""
+ u"""test_commandline_include_exclude with double asterisks on exclude lines."""
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"testfiles/select/1/2/1",
u"--exclude", u"**/1/2",
@@ -731,7 +731,7 @@
self.restore_and_check()
def test_commandline_asterisks_double_both(self):
- """test_commandline_include_exclude with double asterisks on both exclude and include lines."""
+ u"""test_commandline_include_exclude with double asterisks on both exclude and include lines."""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"**/1/2/1",
@@ -741,7 +741,7 @@
self.restore_and_check()
def test_single_and_double_asterisks(self):
- """This compares a backup using --include-globbing-filelist with a single and double *."""
+ u"""This compares a backup using --include-globbing-filelist with a single and double *."""
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ testfiles/select2/*\n"
u"- testfiles/select")
@@ -759,7 +759,7 @@
self.assertEqual(restored, restored2)
def test_single_and_double_asterisks_includes_excludes(self):
- """This compares a backup using --includes/--excludes with a single and double *."""
+ u"""This compares a backup using --includes/--excludes with a single and double *."""
self.backup(u"full", u"testfiles/",
options=[u"--include", u"testfiles/select2/*",
u"--exclude", u"testfiles/select"])
@@ -776,18 +776,18 @@
class TestTrailingSlash(IncludeExcludeFunctionalTest):
- """ Test to check that a trailing slash works as expected
+ u""" Test to check that a trailing slash works as expected
Exhibits the issue reported in Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)."""
def restore_and_check(self):
- """Restores the backup and compares to what is expected."""
+ u"""Restores the backup and compares to what is expected."""
self.restore()
restore_dir = u"testfiles/restore_out"
restored = self.directory_tree_to_list_of_lists(restore_dir)
self.assertEqual(restored, [[u"2"], [u"1"]])
def test_exclude_filelist_trailing_slashes(self):
- """test_exclude_filelist_asterisks_none with trailing slashes."""
+ u"""test_exclude_filelist_asterisks_none with trailing slashes."""
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ testfiles/select/1/2/1/\n"
u"- testfiles/select/1/2/\n"
@@ -797,7 +797,7 @@
self.restore_and_check()
def test_exclude_filelist_trailing_slashes_single_wildcards_excludes(self):
- """test_exclude_filelist_trailing_slashes with single wildcards in excludes."""
+ u"""test_exclude_filelist_trailing_slashes with single wildcards in excludes."""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ testfiles/select/1/2/1/\n"
@@ -808,7 +808,7 @@
self.restore_and_check()
def test_exclude_filelist_trailing_slashes_double_wildcards_excludes(self):
- """test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
+ u"""test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
with io.open(u"testfiles/filelist.txt", u"w") as f:
f.write(u"+ testfiles/select/1/2/1/\n"
@@ -819,7 +819,7 @@
self.restore_and_check()
def test_exclude_filelist_trailing_slashes_double_wildcards_excludes_2(self):
- """second test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
+ u"""second test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
with io.open(u"testfiles/filelist.txt", u"w") as f:
@@ -831,7 +831,7 @@
self.restore_and_check()
def test_exclude_filelist_trailing_slashes_wildcards(self):
- """test_commandline_asterisks_single_excludes_only with trailing slashes."""
+ u"""test_commandline_asterisks_single_excludes_only with trailing slashes."""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
self.backup(u"full", u"testfiles/select/1",
options=[u"--include", u"testfiles/select/1/2/1/",
@@ -842,11 +842,11 @@
class TestTrailingSlash2(IncludeExcludeFunctionalTest):
- """ This tests the behaviour of globbing strings with a trailing slash"""
+ u""" This tests the behaviour of globbing strings with a trailing slash"""
# See Bug #1479545 (https://bugs.launchpad.net/duplicity/+bug/1479545)
def test_no_trailing_slash(self):
- """ Test that including 1.py works as expected"""
+ u""" Test that including 1.py works as expected"""
self.backup(u"full", u"testfiles/select2",
options=[u"--include", u"testfiles/select2/1.py",
u"--exclude", u"**"])
@@ -856,7 +856,7 @@
self.assertEqual(restored, [[u"1.py"]])
def test_trailing_slash(self):
- """ Test that globs with a trailing slash only match directories"""
+ u""" Test that globs with a trailing slash only match directories"""
# Regression test for Bug #1479545
# (https://bugs.launchpad.net/duplicity/+bug/1479545)
self.backup(u"full", u"testfiles/select2",
@@ -868,7 +868,7 @@
self.assertEqual(restored, [])
def test_include_files_not_subdirectories(self):
- """ Test that a trailing slash glob followed by a * glob only matches
+ u""" Test that a trailing slash glob followed by a * glob only matches
files and not subdirectories"""
self.backup(u"full", u"testfiles/select2",
options=[u"--exclude", u"testfiles/select2/*/",
@@ -880,7 +880,7 @@
self.assertEqual(restored, [[u"1.doc", u"1.py"]])
def test_include_subdirectories_not_files(self):
- """ Test that a trailing slash glob only matches directories"""
+ u""" Test that a trailing slash glob only matches directories"""
self.backup(u"full", u"testfiles/select2",
options=[u"--include", u"testfiles/select2/1/1sub1/**/",
u"--exclude", u"testfiles/select2/1/1sub1/**",
@@ -893,7 +893,7 @@
class TestGlobbingReplacement(IncludeExcludeFunctionalTest):
- """ This tests the behaviour of the extended shell globbing pattern replacement functions."""
+ u""" This tests the behaviour of the extended shell globbing pattern replacement functions."""
# See the manual for a description of behaviours, but in summary:
# * can be expanded to any string of characters not containing "/"
# ? expands to any character except "/" and
@@ -903,7 +903,7 @@
# removed and any character in the string can be replaced with an upper- or lowercase version of itself.
def test_globbing_replacement_in_includes(self):
- """ Test behaviour of the extended shell globbing pattern replacement functions in both include and exclude"""
+ u""" Test behaviour of the extended shell globbing pattern replacement functions in both include and exclude"""
# Identical to test_include_exclude_basic with globbing characters added to both include and exclude lines
# Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371).
# See above and the unit tests for more granularity on the issue.
@@ -931,10 +931,10 @@
class TestExcludeIfPresent(IncludeExcludeFunctionalTest):
- """ This tests the behaviour of duplicity's --exclude-if-present option"""
+ u""" This tests the behaviour of duplicity's --exclude-if-present option"""
def test_exclude_if_present_baseline(self):
- """ Test that duplicity normally backs up files"""
+ u""" Test that duplicity normally backs up files"""
with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/.nobackup", u"w") as tag:
tag.write(u"Files in this folder should not be backed up.")
self.backup(u"full", u"testfiles/select2/1/1sub1",
@@ -947,7 +947,7 @@
[u".nobackup", u"1sub1sub1_file.txt"]])
def test_exclude_if_present_excludes(self):
- """ Test that duplicity excludes files with relevant tag"""
+ u""" Test that duplicity excludes files with relevant tag"""
with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/.nobackup", u"w") as tag:
tag.write(u"Files in this folder should not be backed up.")
self.backup(u"full", u"testfiles/select2/1/1sub1",
@@ -960,7 +960,7 @@
self.assertEqual(restored, [])
def test_exclude_if_present_excludes_2(self):
- """ Test that duplicity excludes files with relevant tag"""
+ u""" Test that duplicity excludes files with relevant tag"""
with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", u"w") as tag:
tag.write(u"Files in this folder should also not be backed up.")
self.backup(u"full", u"testfiles/select2/1/1sub1",
@@ -974,12 +974,12 @@
class TestLockedFoldersNoError(IncludeExcludeFunctionalTest):
- """ This tests that inaccessible folders do not cause an error"""
+ u""" This tests that inaccessible folders do not cause an error"""
- @unittest.skipUnless(platform.platform().startswith("Linux"),
+ @unittest.skipUnless(platform.platform().startswith(u"Linux"),
u"Skip on non-Linux systems")
def test_locked_baseline(self):
- """ Test no error if locked in path but excluded"""
+ u""" Test no error if locked in path but excluded"""
folder_to_lock = u"testfiles/select2/1/1sub1/1sub1sub3"
initial_mode = os.stat(folder_to_lock).st_mode
os.chmod(folder_to_lock, 0o0000)
@@ -993,10 +993,10 @@
self.assertEqual(restored, [[u"1sub1sub1"],
[u"1sub1sub1_file.txt"]])
- @unittest.skipUnless(platform.platform().startswith("Linux"),
+ @unittest.skipUnless(platform.platform().startswith(u"Linux"),
u"Skip on non-Linux systems")
def test_locked_excl_if_present(self):
- """ Test no error if excluded locked with --exclude-if-present"""
+ u""" Test no error if excluded locked with --exclude-if-present"""
# Regression test for Bug #1620085
# https://bugs.launchpad.net/duplicity/+bug/1620085
folder_to_lock = u"testfiles/select2/1/1sub1/1sub1sub3"
@@ -1015,11 +1015,11 @@
class TestFolderIncludesFiles(IncludeExcludeFunctionalTest):
- """ This tests that including a folder includes the files within it"""
+ u""" This tests that including a folder includes the files within it"""
# https://bugs.launchpad.net/duplicity/+bug/1624725
def test_includes_files(self):
- """This tests that including a folder includes the files within it"""
+ u"""This tests that including a folder includes the files within it"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1",
u"--exclude", u"**"])
@@ -1030,7 +1030,7 @@
[u"1sub1sub1_file.txt"]])
def test_includes_files_trailing_slash(self):
- """This tests that including a folder includes the files within it"""
+ u"""This tests that including a folder includes the files within it"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/",
u"--exclude", u"**"])
@@ -1041,7 +1041,7 @@
[u"1sub1sub1_file.txt"]])
def test_includes_files_trailing_slash_globbing_chars(self):
- """Tests folder includes with globbing char and /"""
+ u"""Tests folder includes with globbing char and /"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--include", u"testfiles/s?lect2/1/1sub1/1sub1sub1/",
u"--exclude", u"**"])
@@ -1052,7 +1052,7 @@
[u"1sub1sub1_file.txt"]])
def test_excludes_files_no_trailing_slash(self):
- """This tests that excluding a folder excludes the files within it"""
+ u"""This tests that excluding a folder excludes the files within it"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub1",
u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2",
@@ -1065,7 +1065,7 @@
self.assertEqual(restored, [])
def test_excludes_files_trailing_slash(self):
- """Excluding a folder excludes the files within it, if ends with /"""
+ u"""Excluding a folder excludes the files within it, if ends with /"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub1/",
u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2/",
@@ -1078,7 +1078,7 @@
self.assertEqual(restored, [])
def test_excludes_files_trailing_slash_globbing_chars(self):
- """Tests folder excludes with globbing char and /"""
+ u"""Tests folder excludes with globbing char and /"""
self.backup(u"full", u"testfiles/select2/1/1sub1",
options=[u"--exclude", u"testfiles/sel?ct2/1/1sub1/1sub1sub1/",
u"--exclude", u"testfiles/sel[e,f]ct2/1/1sub1/1sub1sub2/",
@@ -1092,10 +1092,10 @@
class TestAbsolutePaths(IncludeExcludeFunctionalTest):
- """ Tests include/exclude options with absolute paths"""
+ u""" Tests include/exclude options with absolute paths"""
def test_absolute_paths_non_globbing(self):
- """ Test --include and --exclude work with absolute paths"""
+ u""" Test --include and --exclude work with absolute paths"""
self.backup(u"full", os.path.abspath(u"testfiles/select2"),
options=[u"--include", os.path.abspath(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"),
u"--exclude", os.path.abspath(u"testfiles/select2/3/3sub3/3sub3sub2"),
@@ -1122,13 +1122,13 @@
self.assertEqual(restored, self.expected_restored_tree)
-@unittest.skipUnless(sys.getfilesystemencoding() == "UTF-8",
+@unittest.skipUnless(sys.getfilesystemencoding() == u"UTF-8",
u"Skipping TestUnicode -- Only tested to work on UTF-8 systems")
class TestUnicode(IncludeExcludeFunctionalTest):
- """ Tests include/exclude options with unicode paths"""
+ u""" Tests include/exclude options with unicode paths"""
def test_unicode_paths_non_globbing(self):
- """ Test --include and --exclude work with unicode paths"""
+ u""" Test --include and --exclude work with unicode paths"""
self.backup(u"full", u"testfiles/select-unicode",
options=[u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/उदाहरण.txt",
u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/דוגמא.txt",
@@ -1145,7 +1145,7 @@
[u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]])
def test_unicode_paths_asterisks(self):
- """ Test --include and --exclude work with unicode paths and globs containing * and **"""
+ u""" Test --include and --exclude work with unicode paths and globs containing * and **"""
p = u"testfiles/select-unicode/"
self.backup(u"full", u"testfiles/select-unicode",
options=[u"--exclude", p + u"прыклад/пример/例/Παρά*ειγμα/उदाहरण.txt", # Note *
@@ -1163,7 +1163,7 @@
[u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]])
def test_unicode_paths_square_brackets(self):
- """ Test --include and --exclude work with unicode paths with character options in []s and [!]s"""
+ u""" Test --include and --exclude work with unicode paths with character options in []s and [!]s"""
p = u"testfiles/select-unicode/"
self.backup(u"full", u"testfiles/select-unicode",
options=[u"--exclude", p + u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt",
@@ -1181,11 +1181,11 @@
[u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]])
def test_unicode_filelist(self):
- """Test that exclude filelist works with unicode filenames"""
+ u"""Test that exclude filelist works with unicode filenames"""
# As this is an exclude filelist any lines with no +/- modifier should be treated as if they have a -.
path = u"testfiles/select-unicode/"
# Create a filelist
- with io.open(u"testfiles/exclude.txt", u"w", encoding="UTF-8") as f:
+ with io.open(u"testfiles/exclude.txt", u"w", encoding=u"UTF-8") as f:
f.write(u"- " + path + u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt\n"
u"- " + path + u"прыклад/пример/例/Παράδειγμα/דוגמא.txt\n"
u"- " + path + u"прыклад/пример/例/მაგალითი/\n"
@@ -1201,5 +1201,5 @@
self.assertEqual(restored, [[u"прыклад", u"օրինակ.txt"],
[u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]])
-if __name__ == "__main__":
+if __name__ == u"__main__":
unittest.main()
=== modified file 'testing/test_code.py'
--- testing/test_code.py 2018-06-08 16:39:57 +0000
+++ testing/test_code.py 2018-07-19 21:12:04 +0000
@@ -161,7 +161,6 @@
os.path.join(_top_dir, u'duplicity', u'file_naming.py'),
os.path.join(_top_dir, u'duplicity', u'filechunkio.py'),
os.path.join(_top_dir, u'duplicity', u'globals.py'),
- os.path.join(_top_dir, u'duplicity', u'globmatch.py'),
os.path.join(_top_dir, u'duplicity', u'gpg.py'),
os.path.join(_top_dir, u'duplicity', u'gpginterface.py'),
os.path.join(_top_dir, u'duplicity', u'lazy.py'),
@@ -172,7 +171,6 @@
os.path.join(_top_dir, u'duplicity', u'path.py'),
os.path.join(_top_dir, u'duplicity', u'progress.py'),
os.path.join(_top_dir, u'duplicity', u'robust.py'),
- os.path.join(_top_dir, u'duplicity', u'selection.py'),
os.path.join(_top_dir, u'duplicity', u'statistics.py'),
os.path.join(_top_dir, u'duplicity', u'tarfile.py'),
os.path.join(_top_dir, u'duplicity', u'tempdir.py'),
@@ -187,7 +185,6 @@
os.path.join(_top_dir, u'testing', u'functional', u'test_rdiffdir.py'),
os.path.join(_top_dir, u'testing', u'functional', u'test_replicate.py'),
os.path.join(_top_dir, u'testing', u'functional', u'test_restart.py'),
- os.path.join(_top_dir, u'testing', u'functional', u'test_selection.py'),
os.path.join(_top_dir, u'testing', u'functional', u'test_verify.py'),
os.path.join(_top_dir, u'testing', u'manual', u'__init__.py'),
os.path.join(_top_dir, u'testing', u'overrides', u'__init__.py'),
@@ -201,14 +198,12 @@
os.path.join(_top_dir, u'testing', u'unit', u'test_dup_temp.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_dup_time.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_file_naming.py'),
- os.path.join(_top_dir, u'testing', u'unit', u'test_globmatch.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_gpg.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_gpginterface.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_lazy.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_manifest.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_patchdir.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_path.py'),
- os.path.join(_top_dir, u'testing', u'unit', u'test_selection.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_statistics.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_tarfile.py'),
os.path.join(_top_dir, u'testing', u'unit', u'test_tempdir.py')]
=== modified file 'testing/unit/test_globmatch.py'
--- testing/unit/test_globmatch.py 2017-07-15 20:31:11 +0000
+++ testing/unit/test_globmatch.py 2018-07-19 21:12:04 +0000
@@ -30,7 +30,7 @@
def sel_file(glob_str, include, file_path):
- """Returns the selection value for file_path, given the include value,
+ u"""Returns the selection value for file_path, given the include value,
returning:
0 - if the file should be excluded
1 - if the file should be included
@@ -45,39 +45,39 @@
def inc_sel_file(glob_str, file_path):
- """Returns result of sel_file with include value set to 1"""
+ u"""Returns result of sel_file with include value set to 1"""
# Aids readability of the testing code to only have one number (the
# result of the select function)
return sel_file(glob_str, 1, file_path)
def exc_sel_file(glob_str, file_path):
- """Returns result of sel_file with include value set to 0"""
+ u"""Returns result of sel_file with include value set to 0"""
return sel_file(glob_str, 0, file_path)
def sel_dir(glob_str, include, file_path):
- """As per sel_file, but mocks file_path to be a directory"""
- with patch('duplicity.path.Path.isdir') as mock_isdir:
+ u"""As per sel_file, but mocks file_path to be a directory"""
+ with patch(u'duplicity.path.Path.isdir') as mock_isdir:
mock_isdir.return_value = True
return sel_file(glob_str, include, file_path)
def inc_sel_dir(glob_str, file_path):
- """Returns result of sel_dir with include value set to 1"""
+ u"""Returns result of sel_dir with include value set to 1"""
return sel_dir(glob_str, 1, file_path)
def exc_sel_dir(glob_str, file_path):
- """Returns result of sel_dir with include value set to 0"""
+ u"""Returns result of sel_dir with include value set to 0"""
return sel_dir(glob_str, 0, file_path)
class TestGlobToRegex(UnitTestCase):
- """Test translation of glob strings into regular expressions"""
+ u"""Test translation of glob strings into regular expressions"""
def test_glob_to_regex(self):
- """test_glob_re - test translation of shell pattern to regular exp"""
+ u"""test_glob_re - test translation of shell pattern to regular exp"""
self.assertEqual(glob_to_regex(u"hello"), u"hello")
self.assertEqual(glob_to_regex(u".e?ll**o"), u"\\.e[^/]ll.*o")
self.assertEqual(glob_to_regex(u"[abc]el[^de][!fg]h"),
@@ -89,22 +89,22 @@
class TestSelectValuesFromGlobs(UnitTestCase):
- """Test the select values returned from various globs"""
+ u"""Test the select values returned from various globs"""
def test_glob_scans_parent_directories(self):
- """Test glob scans parent"""
+ u"""Test glob scans parent"""
self.assertEqual(
inc_sel_dir(u"testfiles/parent/sub", u"testfiles/parent"), 2)
self.assertEqual(
inc_sel_dir(u"testfiles/select2/3/3sub2", u"testfiles/select2/3"), 2)
def test_double_asterisk_include(self):
- """Test a few globbing patterns, including **"""
+ u"""Test a few globbing patterns, including **"""
self.assertEqual(inc_sel_file(u"**", u"foo.txt"), 1)
self.assertEqual(inc_sel_dir(u"**", u"folder"), 1)
def test_double_asterisk_extension_include(self):
- """Test **.py"""
+ u"""Test **.py"""
self.assertEqual(inc_sel_file(u"**.py", u"what/ever.py"), 1)
self.assertEqual(inc_sel_file(u"**.py", u"what/ever.py/foo"), 1)
self.assertEqual(inc_sel_dir(u"**.py", u"foo"), 2)
@@ -113,10 +113,10 @@
class TestTrailingSlash(UnitTestCase):
- """Test glob matching where the glob has a trailing slash"""
+ u"""Test glob matching where the glob has a trailing slash"""
def test_trailing_slash_matches_only_dirs(self):
- """Test matching where glob includes a trailing slash"""
+ u"""Test matching where glob includes a trailing slash"""
# Test the folder named "folder" is included
self.assertEqual(inc_sel_dir(u"fold*/", u"folder"), 1)
@@ -128,24 +128,24 @@
self.assertEqual(inc_sel_file(u"fo*/", u"foo.txt"), None)
def test_included_files_are_matched_no_slash(self):
- """Test that files within an included folder are matched"""
+ u"""Test that files within an included folder are matched"""
self.assertEqual(inc_sel_file(u"fold*", u"folder/file.txt"), 1)
self.assertEqual(inc_sel_file(u"fold*", u"folder/file.txt"), 1)
self.assertEqual(inc_sel_file(u"fold*", u"folder/2/file.txt"), 1)
def test_included_files_are_matched_no_slash_2(self):
- """Test that files within an included folder are matched"""
+ u"""Test that files within an included folder are matched"""
self.assertEqual(inc_sel_file(u"folder", u"folder/file.txt"), 1)
self.assertEqual(inc_sel_file(u"folder/2", u"folder/2/file.txt"), 1)
def test_included_files_are_matched_slash(self):
- """Test that files within an included folder are matched with /"""
+ u"""Test that files within an included folder are matched with /"""
# Bug #1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.assertEqual(inc_sel_file(u"folder/", u"folder/file.txt"), 1)
def test_included_files_are_matched_slash_2(self):
- """Test that files within an included folder are matched with /"""
+ u"""Test that files within an included folder are matched with /"""
# Bug #1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.assertEqual(inc_sel_file(
@@ -153,7 +153,7 @@
u"testfiles/select2/1/1sub1/1sub1sub1/1sub1sub1_file.txt"), 1)
def test_included_files_are_matched_slash_2_parents(self):
- """Test that duplicity will scan parent of glob/"""
+ u"""Test that duplicity will scan parent of glob/"""
# Bug #1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.assertEqual(inc_sel_dir(
@@ -164,13 +164,13 @@
u"testfiles/select2/1/1sub1"), 2)
def test_included_files_are_matched_slash_wildcard(self):
- """Test that files within an included folder are matched with /"""
+ u"""Test that files within an included folder are matched with /"""
# Bug #1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.assertEqual(inc_sel_file(u"fold*/", u"folder/file.txt"), 1)
def test_slash_matches_everything(self):
- """Test / matches everything"""
+ u"""Test / matches everything"""
self.assertEqual(inc_sel_dir(u"/", u"/tmp/testfiles/select/1/2"), 1)
self.assertEqual(inc_sel_dir(u"/", u"/test/random/path"), 1)
self.assertEqual(exc_sel_dir(u"/", u"/test/random/path"), 0)
@@ -179,45 +179,45 @@
self.assertEqual(inc_sel_file(u"/", u"/var/log/log.txt"), 1)
def test_slash_star_scans_folder(self):
- """Test that folder/* scans folder/"""
+ u"""Test that folder/* scans folder/"""
# This behaviour is a bit ambiguous - either include or scan could be
# argued as most appropriate here, but only an empty folder is at stake
# so long as test_slash_star_includes_folder_contents passes.
self.assertEqual(inc_sel_dir(u"folder/*", u"folder"), 2)
def test_slash_star_includes_folder_contents(self):
- """Test that folder/* includes folder contents"""
+ u"""Test that folder/* includes folder contents"""
self.assertEqual(inc_sel_file(u"folder/*", u"folder/file.txt"), 1)
self.assertEqual(inc_sel_file(u"folder/*", u"folder/other_file.log"), 1)
def test_slash_star_star_scans_folder(self):
- """Test that folder/** scans folder/"""
+ u"""Test that folder/** scans folder/"""
self.assertEqual(inc_sel_dir(u"folder/**", u"folder"), 2)
def test_simple_trailing_slash_match(self):
- """Test that a normal folder string ending in / matches that path"""
+ u"""Test that a normal folder string ending in / matches that path"""
self.assertEqual(inc_sel_dir(u"testfiles/select/1/2/1/",
u"testfiles/select/1/2/1"), 1)
def test_double_asterisk_string_slash(self):
- """Test string starting with ** and ending in /"""
+ u"""Test string starting with ** and ending in /"""
self.assertEqual(inc_sel_dir(u"**/1/2/", u"testfiles/select/1/2"), 1)
def test_string_double_asterisk_string_slash(self):
- """Test string ** string /"""
+ u"""Test string ** string /"""
self.assertEqual(inc_sel_dir(u"testfiles**/2/",
u"testfiles/select/1/2"), 1)
class TestDoubleAsterisk(UnitTestCase):
- """Test glob matching where the glob finishes with a **"""
+ u"""Test glob matching where the glob finishes with a **"""
def test_double_asterisk_no_match(self):
- """Test that a folder string ending /** does not match other paths"""
+ u"""Test that a folder string ending /** does not match other paths"""
self.assertEqual(inc_sel_dir(u"/test/folder/**", u"/test/foo"), None)
def test_double_asterisk_match(self):
- """Test that a folder string ending in /** matches that path"""
+ u"""Test that a folder string ending in /** matches that path"""
self.assertEqual(inc_sel_dir(u"/test/folder/**",
u"/test/folder/foo"), 1)
self.assertEqual(inc_sel_file(u"/test/folder/**",
@@ -228,24 +228,24 @@
u"/test/folder/2/foo.txt"), 1)
def test_asterisk_slash_double_asterisk(self):
- """Test folder string ending in */**"""
+ u"""Test folder string ending in */**"""
self.assertEqual(inc_sel_dir(u"fold*/**", u"folder"), 2)
class TestSimpleUnicode(UnitTestCase):
- """Test simple unicode comparison"""
+ u"""Test simple unicode comparison"""
def test_simple_unicode(self):
- """Test simple unicode comparison"""
+ u"""Test simple unicode comparison"""
self.assertEqual(inc_sel_file(u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt",
u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), 1)
class TestSquareBrackets(UnitTestCase):
- """Test glob matching where the glob includes []s and [!]s"""
+ u"""Test glob matching where the glob includes []s and [!]s"""
def test_square_bracket_options(self):
- """Test file including options in []s"""
+ u"""Test file including options in []s"""
self.assertEqual(inc_sel_file(u"/test/f[o,s,p]lder/foo.txt",
u"/test/folder/foo.txt"), 1)
self.assertEqual(inc_sel_file(u"/test/f[i,s,p]lder/foo.txt",
@@ -254,14 +254,14 @@
u"/test/folder/foo.txt"), 1)
def test_square_bracket_options_unicode(self):
- """Test file including options in []s"""
+ u"""Test file including options in []s"""
self.assertEqual(inc_sel_file(u"прыклад/пр[и,j,l]мер/例/Παράδειγμα/उदाहरण.txt",
u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), 1)
self.assertEqual(inc_sel_file(u"прыклад/п[a,b,c]имер/例/Παράδειγμα/उदाहरण.txt",
u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), None)
def test_not_square_bracket_options(self):
- """Test file including options in [!]s"""
+ u"""Test file including options in [!]s"""
self.assertEqual(inc_sel_file(u"/test/f[!o,s,p]lder/foo.txt",
u"/test/folder/foo.txt"), None)
self.assertEqual(inc_sel_file(u"/test/f[!i,s,p]lder/foo.txt",
@@ -270,7 +270,7 @@
u"/test/folder/foo.txt"), None)
def test_square_bracket_range(self):
- """Test file including range in []s"""
+ u"""Test file including range in []s"""
self.assertEqual(inc_sel_file(u"/test/folder[1-5]/foo.txt",
u"/test/folder4/foo.txt"), 1)
self.assertEqual(inc_sel_file(u"/test/folder[5-9]/foo.txt",
@@ -279,7 +279,7 @@
u"/test/folder6/foo.txt"), None)
def test_square_bracket_not_range(self):
- """Test file including range in [!]s"""
+ u"""Test file including range in [!]s"""
self.assertEqual(inc_sel_file(u"/test/folder[!1-5]/foo.txt",
u"/test/folder4/foo.txt"), None)
self.assertEqual(inc_sel_file(u"/test/folder[!5-9]/foo.txt",
=== modified file 'testing/unit/test_selection.py'
--- testing/unit/test_selection.py 2017-07-15 20:31:11 +0000
+++ testing/unit/test_selection.py 2018-07-19 21:12:04 +0000
@@ -33,7 +33,7 @@
class MatchingTest(UnitTestCase):
- """Test matching of file names against various selection functions"""
+ u"""Test matching of file names against various selection functions"""
def setUp(self):
super(MatchingTest, self).setUp()
self.unpack_testfiles()
@@ -44,7 +44,7 @@
return self.root.new_index(tuple(path.split(u"/")))
def testRegexp(self):
- """Test regular expression selection func"""
+ u"""Test regular expression selection func"""
sf1 = self.Select.regexp_get_sf(u".*\.py", 1)
assert sf1(self.makeext(u"1.py")) == 1
assert sf1(self.makeext(u"usr/foo.py")) == 1
@@ -56,7 +56,7 @@
assert sf2(Path(u"foo")) is None
def test_tuple_include(self):
- """Test include selection function made from a regular filename"""
+ u"""Test include selection function made from a regular filename"""
self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf,
u"foo", 1)
@@ -76,7 +76,7 @@
self.assertEqual(sf2(self.makeext(u"usr/local/bingzip")), None)
def test_tuple_exclude(self):
- """Test exclude selection function made from a regular filename"""
+ u"""Test exclude selection function made from a regular filename"""
self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf,
u"foo", 0)
@@ -93,7 +93,7 @@
assert sf2(self.makeext(u"usr/local/bingzip")) is None
def test_glob_star_include(self):
- """Test a few globbing patterns, including **"""
+ u"""Test a few globbing patterns, including **"""
sf1 = self.Select.glob_get_sf(u"**", 1)
assert sf1(self.makeext(u"foo")) == 1
assert sf1(self.makeext(u"")) == 1
@@ -105,7 +105,7 @@
assert sf2(self.makeext(u"what/ever.py/foo")) == 1
def test_glob_star_exclude(self):
- """Test a few glob excludes, including **"""
+ u"""Test a few glob excludes, including **"""
sf1 = self.Select.glob_get_sf(u"**", 0)
assert sf1(self.makeext(u"/usr/local/bin")) == 0
@@ -116,16 +116,16 @@
assert sf2(self.makeext(u"what/ever.py/foo")) == 0
def test_simple_glob_double_asterisk(self):
- """test_simple_glob_double_asterisk - primarily to check that the defaults used by the error tests work"""
+ u"""test_simple_glob_double_asterisk - primarily to check that the defaults used by the error tests work"""
assert self.Select.glob_get_normal_sf(u"**", 1)
def test_glob_sf_exception(self):
- """test_glob_sf_exception - see if globbing errors returned"""
+ u"""test_glob_sf_exception - see if globbing errors returned"""
self.assertRaises(GlobbingError, self.Select.glob_get_normal_sf,
u"testfiles/select/hello//there", 1)
def test_file_prefix_sf_exception(self):
- """test_file_prefix_sf_exception - see if FilePrefix error is returned"""
+ u"""test_file_prefix_sf_exception - see if FilePrefix error is returned"""
# These should raise a FilePrefixError because the root directory for the selection is "testfiles/select"
self.assertRaises(FilePrefixError,
self.Select.glob_get_sf, u"testfiles/whatever", 1)
@@ -133,7 +133,7 @@
self.Select.glob_get_sf, u"testfiles/?hello", 0)
def test_scan(self):
- """Tests what is returned for selection tests regarding directory scanning"""
+ u"""Tests what is returned for selection tests regarding directory scanning"""
select = Select(Path(u"/"))
assert select.glob_get_sf(u"**.py", 1)(Path(u"/")) == 2
@@ -146,7 +146,7 @@
assert select.glob_get_normal_sf(u"/testfiles/select/test.py", 0)(Path(u"/testfiles/select")) is None
def test_ignore_case(self):
- """test_ignore_case - try a few expressions with ignorecase:"""
+ u"""test_ignore_case - try a few expressions with ignorecase:"""
sf = self.Select.glob_get_sf(u"ignorecase:testfiles/SeLect/foo/bar", 1)
assert sf(self.makeext(u"FOO/BAR")) == 1
@@ -155,7 +155,7 @@
self.assertRaises(FilePrefixError, self.Select.glob_get_sf, u"ignorecase:tesfiles/sect/foo/bar", 1)
def test_root(self):
- """test_root - / may be a counterexample to several of these.."""
+ u"""test_root - / may be a counterexample to several of these.."""
root = Path(u"/")
select = Select(root)
@@ -173,7 +173,7 @@
assert select.glob_get_sf(u"/foo/*", 0)(root) is None
def test_other_filesystems(self):
- """Test to see if --exclude-other-filesystems works correctly"""
+ u"""Test to see if --exclude-other-filesystems works correctly"""
root = Path(u"/")
select = Select(root)
sf = select.other_filesystems_get_sf(0)
@@ -199,7 +199,7 @@
class ParseArgsTest(UnitTestCase):
- """Test argument parsing"""
+ u"""Test argument parsing"""
def setUp(self):
super(ParseArgsTest, self).setUp()
self.unpack_testfiles()
@@ -217,12 +217,12 @@
(u"3", u"3sub3", u"3sub3sub3")]
def uc_index_from_path(self, path):
- """Takes a path type and returns path.index, with each element converted into unicode"""
- uindex = tuple([element.decode(sys.getfilesystemencoding(), "strict") for element in path.index])
+ u"""Takes a path type and returns path.index, with each element converted into unicode"""
+ uindex = tuple([element.decode(sys.getfilesystemencoding(), u"strict") for element in path.index])
return uindex
def ParseTest(self, tuplelist, indicies, filelists=[]):
- """No error if running select on tuple goes over indicies"""
+ u"""No error if running select on tuple goes over indicies"""
if not self.root:
self.root = Path(u"testfiles/select")
self.Select = Select(self.root)
@@ -236,7 +236,7 @@
self.assertEqual(indicies, results_as_list)
def remake_filelists(self, filelist):
- """Turn strings in filelist into fileobjs"""
+ u"""Turn strings in filelist into fileobjs"""
new_filelists = []
for f in filelist:
if isinstance(f, unicode):
@@ -246,14 +246,14 @@
return new_filelists
def test_parse(self):
- """Test just one include, all exclude"""
+ u"""Test just one include, all exclude"""
self.ParseTest([(u"--include", u"testfiles/select/1/1"),
(u"--exclude", u"**")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"),
(u"1", u"1", u"2"), (u"1", u"1", u"3")])
def test_parse2(self):
- """Test three level include/exclude"""
+ u"""Test three level include/exclude"""
self.ParseTest([(u"--exclude", u"testfiles/select/1/1/1"),
(u"--include", u"testfiles/select/1/1"),
(u"--exclude", u"testfiles/select/1"),
@@ -262,7 +262,7 @@
(u"1", u"1", u"3")])
def test_filelist(self):
- """Filelist glob test similar to above testParse2"""
+ u"""Filelist glob test similar to above testParse2"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -272,7 +272,7 @@
u"- **"])
def test_include_filelist_1_trailing_whitespace(self):
- """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on include"""
+ u"""Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on include"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -282,7 +282,7 @@
u"- **"])
def test_include_filelist_2_trailing_whitespaces(self):
- """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on include"""
+ u"""Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on include"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -292,7 +292,7 @@
u"- **"])
def test_include_filelist_1_leading_whitespace(self):
- """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on include"""
+ u"""Filelist glob test similar to globbing filelist, but with 1 leading whitespace on include"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -302,7 +302,7 @@
u"- **"])
def test_include_filelist_2_leading_whitespaces(self):
- """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on include"""
+ u"""Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on include"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -312,7 +312,7 @@
u"- **"])
def test_include_filelist_1_trailing_whitespace_exclude(self):
- """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on exclude"""
+ u"""Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on exclude"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -322,7 +322,7 @@
u"- **"])
def test_include_filelist_2_trailing_whitespace_exclude(self):
- """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on exclude"""
+ u"""Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on exclude"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -332,7 +332,7 @@
u"- **"])
def test_include_filelist_1_leading_whitespace_exclude(self):
- """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on exclude"""
+ u"""Filelist glob test similar to globbing filelist, but with 1 leading whitespace on exclude"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -342,7 +342,7 @@
u"- **"])
def test_include_filelist_2_leading_whitespaces_exclude(self):
- """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on exclude"""
+ u"""Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on exclude"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -352,7 +352,7 @@
u"- **"])
def test_include_filelist_check_excluded_folder_included_for_contents(self):
- """Filelist glob test to check excluded folder is included if contents are"""
+ u"""Filelist glob test to check excluded folder is included if contents are"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3"), (u"1", u"2"), (u"1", u"2", u"1"), (u"1", u"3"), (u"1", u"3", u"1"),
@@ -363,7 +363,7 @@
u"- **"])
def test_include_filelist_with_unnecessary_quotes(self):
- """Filelist glob test similar to globbing filelist, but with quotes around one of the paths."""
+ u"""Filelist glob test similar to globbing filelist, but with quotes around one of the paths."""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -373,7 +373,7 @@
u"- **"])
def test_include_filelist_with_unnecessary_double_quotes(self):
- """Filelist glob test similar to globbing filelist, but with double quotes around one of the paths."""
+ u"""Filelist glob test similar to globbing filelist, but with double quotes around one of the paths."""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -383,7 +383,7 @@
u"- **"])
def test_include_filelist_with_full_line_comment(self):
- """Filelist glob test similar to globbing filelist, but with a full-line comment."""
+ u"""Filelist glob test similar to globbing filelist, but with a full-line comment."""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -394,7 +394,7 @@
u"- **"])
def test_include_filelist_with_blank_line(self):
- """Filelist glob test similar to globbing filelist, but with a blank line."""
+ u"""Filelist glob test similar to globbing filelist, but with a blank line."""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -405,7 +405,7 @@
u"- **"])
def test_include_filelist_with_blank_line_and_whitespace(self):
- """Filelist glob test similar to globbing filelist, but with a blank line and whitespace."""
+ u"""Filelist glob test similar to globbing filelist, but with a blank line and whitespace."""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -416,7 +416,7 @@
u"- **"])
def test_include_filelist_asterisk(self):
- """Filelist glob test with * instead of 'testfiles'"""
+ u"""Filelist glob test with * instead of 'testfiles'"""
# Thank you to Elifarley Cruz for this test case
# (https://bugs.launchpad.net/duplicity/+bug/884371).
self.ParseTest([(u"--include-filelist", u"file")],
@@ -426,7 +426,7 @@
u"- **"])
def test_include_filelist_asterisk_2(self):
- """Identical to test_filelist, but with the exclude "select" replaced with '*'"""
+ u"""Identical to test_filelist, but with the exclude "select" replaced with '*'"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -436,7 +436,7 @@
u"- **"])
def test_include_filelist_asterisk_3(self):
- """Identical to test_filelist, but with the auto-include "select" replaced with '*'"""
+ u"""Identical to test_filelist, but with the auto-include "select" replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -447,7 +447,7 @@
u"- **"])
def test_include_filelist_asterisk_4(self):
- """Identical to test_filelist, but with a specific include "select" replaced with '*'"""
+ u"""Identical to test_filelist, but with a specific include "select" replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -458,7 +458,7 @@
u"- **"])
def test_include_filelist_asterisk_5(self):
- """Identical to test_filelist, but with all 'select's replaced with '*'"""
+ u"""Identical to test_filelist, but with all 'select's replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -469,7 +469,7 @@
u"- **"])
def test_include_filelist_asterisk_6(self):
- """Identical to test_filelist, but with numerous excluded folders replaced with '*'"""
+ u"""Identical to test_filelist, but with numerous excluded folders replaced with '*'"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -479,7 +479,7 @@
u"- **"])
def test_include_filelist_asterisk_7(self):
- """Identical to test_filelist, but with numerous included/excluded folders replaced with '*'"""
+ u"""Identical to test_filelist, but with numerous included/excluded folders replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -490,7 +490,7 @@
u"- **"])
def test_include_filelist_double_asterisk_1(self):
- """Identical to test_filelist, but with the exclude "select' replaced with '**'"""
+ u"""Identical to test_filelist, but with the exclude "select' replaced with '**'"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -500,7 +500,7 @@
u"- **"])
def test_include_filelist_double_asterisk_2(self):
- """Identical to test_filelist, but with the include 'select' replaced with '**'"""
+ u"""Identical to test_filelist, but with the include 'select' replaced with '**'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -511,7 +511,7 @@
u"- **"])
def test_include_filelist_double_asterisk_3(self):
- """Identical to test_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
+ u"""Identical to test_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -521,7 +521,7 @@
u"- **"])
def test_include_filelist_double_asterisk_4(self):
- """Identical to test_filelist, but with the include 'testfiles/select' replaced with '**'"""
+ u"""Identical to test_filelist, but with the include 'testfiles/select' replaced with '**'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -532,7 +532,7 @@
u"- **"])
def test_include_filelist_double_asterisk_5(self):
- """Identical to test_filelist, but with all 'testfiles/select's replaced with '**'"""
+ u"""Identical to test_filelist, but with all 'testfiles/select's replaced with '**'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -543,7 +543,7 @@
u"- **"])
def test_include_filelist_trailing_slashes(self):
- """Filelist glob test similar to globbing filelist, but with trailing slashes"""
+ u"""Filelist glob test similar to globbing filelist, but with trailing slashes"""
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -553,7 +553,7 @@
u"- **"])
def test_include_filelist_trailing_slashes_and_single_asterisks(self):
- """Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks"""
+ u"""Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks"""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -564,7 +564,7 @@
u"- **"])
def test_include_filelist_trailing_slashes_and_double_asterisks(self):
- """Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks"""
+ u"""Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks"""
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -575,7 +575,7 @@
u"- **"])
def test_filelist_null_separator(self):
- """test_filelist, but with null_separator set"""
+ u"""test_filelist, but with null_separator set"""
self.set_global(u"null_separator", 1)
self.ParseTest([(u"--include-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -583,7 +583,7 @@
[u"\0- testfiles/select/1/1/1\0testfiles/select/1/1\0- testfiles/select/1\0- **\0"])
def test_exclude_filelist(self):
- """Exclude version of test_filelist"""
+ u"""Exclude version of test_filelist"""
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -593,7 +593,7 @@
u"- **"])
def test_exclude_filelist_asterisk_1(self):
- """Exclude version of test_include_filelist_asterisk"""
+ u"""Exclude version of test_include_filelist_asterisk"""
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"),
(u"1", u"1", u"2"), (u"1", u"1", u"3")],
@@ -601,9 +601,9 @@
u"- **"])
def test_exclude_filelist_asterisk_2(self):
- """Identical to test_exclude_filelist, but with the exclude "select" replaced with '*'"""
+ u"""Identical to test_exclude_filelist, but with the exclude "select" replaced with '*'"""
self.ParseTest([(u"--exclude-filelist", u"file")],
- [(), (u"1",), (u"1", "1"), (u"1", u"1", u"2"),
+ [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
[u"testfiles/*/1/1/1\n"
u"+ testfiles/select/1/1\n"
@@ -611,7 +611,7 @@
u"- **"])
def test_exclude_filelist_asterisk_3(self):
- """Identical to test_exclude_filelist, but with the include "select" replaced with '*'"""
+ u"""Identical to test_exclude_filelist, but with the include "select" replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -622,7 +622,7 @@
u"- **"])
def test_exclude_filelist_asterisk_4(self):
- """Identical to test_exclude_filelist, but with numerous excluded folders replaced with '*'"""
+ u"""Identical to test_exclude_filelist, but with numerous excluded folders replaced with '*'"""
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
(u"1", u"1", u"3")],
@@ -632,7 +632,7 @@
u"- **"])
def test_exclude_filelist_asterisk_5(self):
- """Identical to test_exclude_filelist, but with numerous included/excluded folders replaced with '*'"""
+ u"""Identical to test_exclude_filelist, but with numerous included/excluded folders replaced with '*'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -643,7 +643,7 @@
u"- **"])
def test_exclude_filelist_double_asterisk(self):
- """Identical to test_exclude_filelist, but with all included/excluded folders replaced with '**'"""
+ u"""Identical to test_exclude_filelist, but with all included/excluded folders replaced with '**'"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.ParseTest([(u"--exclude-filelist", u"file")],
[(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"),
@@ -654,7 +654,7 @@
u"- **"])
def test_exclude_filelist_single_asterisk_at_beginning(self):
- """Exclude filelist testing limited functionality of functional test"""
+ u"""Exclude filelist testing limited functionality of functional test"""
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
self.root = Path(u"testfiles/select/1")
self.ParseTest([(u"--exclude-filelist", u"file")],
@@ -665,7 +665,7 @@
u"- testfiles/select/1/3"])
def test_commandline_asterisks_double_both(self):
- """Unit test the functional test TestAsterisks.test_commandline_asterisks_double_both"""
+ u"""Unit test the functional test TestAsterisks.test_commandline_asterisks_double_both"""
self.root = Path(u"testfiles/select/1")
self.ParseTest([(u"--include", u"**/1/2/1"),
(u"--exclude", u"**t/1/2"),
@@ -674,7 +674,7 @@
[(), (u"2",), (u"2", u"1")])
def test_includes_files(self):
- """Unit test the functional test test_includes_files"""
+ u"""Unit test the functional test test_includes_files"""
# Test for Bug 1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.root = Path(u"testfiles/select2/1/1sub1")
@@ -684,7 +684,7 @@
u"1sub1sub1_file.txt")])
def test_includes_files_trailing_slash(self):
- """Unit test the functional test test_includes_files_trailing_slash"""
+ u"""Unit test the functional test test_includes_files_trailing_slash"""
# Test for Bug 1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.root = Path(u"testfiles/select2/1/1sub1")
@@ -694,7 +694,7 @@
u"1sub1sub1_file.txt")])
def test_includes_files_trailing_slash_globbing_chars(self):
- """Unit test functional test_includes_files_trailing_slash_globbing_chars"""
+ u"""Unit test functional test_includes_files_trailing_slash_globbing_chars"""
# Test for Bug 1624725
# https://bugs.launchpad.net/duplicity/+bug/1624725
self.root = Path(u"testfiles/select2/1/1sub1")
@@ -704,7 +704,7 @@
u"1sub1sub1_file.txt")])
def test_glob(self):
- """Test globbing expression"""
+ u"""Test globbing expression"""
self.ParseTest([(u"--exclude", u"**[3-5]"),
(u"--include", u"testfiles/select/1"),
(u"--exclude", u"**")],
@@ -733,7 +733,7 @@
(u"3", u"3", u"2")])
def test_filelist2(self):
- """Filelist glob test similar to above testGlob"""
+ u"""Filelist glob test similar to above testGlob"""
self.ParseTest([(u"--exclude-filelist", u"asoeuth")],
[(), (u"1",), (u"1", u"1"),
(u"1", u"1", u"1"), (u"1", u"1", u"2"),
@@ -768,7 +768,7 @@
"""])
def test_glob2(self):
- """Test more globbing functions"""
+ u"""Test more globbing functions"""
self.ParseTest([(u"--include", u"testfiles/select/*foo*/p*"),
(u"--exclude", u"**")],
[(), (u"efools",), (u"efools", u"ping"),
@@ -781,7 +781,7 @@
[(), (u"1",), (u"1", u"1"), (u"1", u"2")])
def test_glob3(self):
- """ regression test for bug 25230 """
+ u""" regression test for bug 25230 """
self.ParseTest([(u"--include", u"testfiles/select/**1"),
(u"--include", u"testfiles/select/**2"),
(u"--exclude", u"**")],
@@ -805,7 +805,7 @@
(u"3", u"3", u"1"), (u"3", u"3", u"2")])
def test_alternate_root(self):
- """Test select with different root"""
+ u"""Test select with different root"""
self.root = Path(u"testfiles/select/1")
self.ParseTest([(u"--exclude", u"testfiles/select/1/[23]")],
[(), (u"1",), (u"1", u"1"), (u"1", u"2"), (u"1", u"3")])
@@ -817,7 +817,7 @@
[(), (u"tmp",)])
def test_exclude_after_scan(self):
- """Test select with an exclude after a pattern that would return a scan for that file"""
+ u"""Test select with an exclude after a pattern that would return a scan for that file"""
self.root = Path(u"testfiles/select2/3")
self.ParseTest([(u"--include", u"testfiles/select2/3/**file.txt"),
(u"--exclude", u"testfiles/select2/3/3sub2"),
@@ -827,7 +827,7 @@
(u"3sub3",), (u"3sub3", u"3sub3sub2"), (u"3sub3", u"3sub3sub2", u"3sub3sub2_file.txt")])
def test_include_exclude_basic(self):
- """Test functional test test_include_exclude_basic as a unittest"""
+ u"""Test functional test test_include_exclude_basic as a unittest"""
self.root = Path(u"testfiles/select2")
self.ParseTest([(u"--include", u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"),
(u"--exclude", u"testfiles/select2/3/3sub3/3sub3sub2"),
@@ -851,7 +851,7 @@
self.expected_restored_tree)
def test_globbing_replacement(self):
- """Test functional test test_globbing_replacement as a unittest"""
+ u"""Test functional test test_globbing_replacement as a unittest"""
self.root = Path(u"testfiles/select2")
self.ParseTest([(u"--include", u"testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt"),
(u"--exclude", u"testfiles/select2/*/3s*1"),
@@ -871,7 +871,7 @@
self.expected_restored_tree)
def test_unicode_paths_non_globbing(self):
- """Test functional test test_unicode_paths_non_globbing as a unittest"""
+ u"""Test functional test test_unicode_paths_non_globbing as a unittest"""
self.root = Path(u"testfiles/select-unicode")
self.ParseTest([(u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/उदाहरण.txt"),
(u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/דוגמא.txt"),
@@ -888,10 +888,10 @@
class TestGlobGetNormalSf(UnitTestCase):
- """Test glob parsing of the test_glob_get_normal_sf function. Indirectly test behaviour of glob_to_re."""
+ u"""Test glob parsing of the test_glob_get_normal_sf function. Indirectly test behaviour of glob_to_re."""
def glob_tester(self, path, glob_string, include_exclude, root_path):
- """Takes a path, glob string and include_exclude value (1 = include, 0 = exclude) and returns the output
+ u"""Takes a path, glob string and include_exclude value (1 = include, 0 = exclude) and returns the output
of the selection function.
None - means the test has nothing to say about the related file
0 - the file is excluded by the test
@@ -911,17 +911,17 @@
return self.glob_tester(path, glob_string, 0, root_path)
def test_glob_get_normal_sf_exclude(self):
- """Test simple exclude."""
+ u"""Test simple exclude."""
self.assertEqual(self.exclude_glob_tester(u"/testfiles/select2/3", u"/testfiles/select2"), 0)
self.assertEqual(self.exclude_glob_tester(u"/testfiles/.git", u"/testfiles"), 0)
def test_glob_get_normal_sf_exclude_root(self):
- """Test simple exclude with / as the glob."""
+ u"""Test simple exclude with / as the glob."""
self.assertEqual(self.exclude_glob_tester(u"/.git", u"/"), 0)
self.assertEqual(self.exclude_glob_tester(u"/testfile", u"/"), 0)
def test_glob_get_normal_sf_2(self):
- """Test same behaviour as the functional test test_globbing_replacement."""
+ u"""Test same behaviour as the functional test test_globbing_replacement."""
self.assertEqual(self.include_glob_tester(u"/testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt",
u"/testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt"), 1)
self.assertEqual(self.include_glob_tester(u"/testfiles/select2/3/3sub1", u"/testfiles/select2/*/3s*1"), 1)
@@ -945,7 +945,7 @@
self.assertEqual(self.include_glob_tester(u"/testfiles/select2/1", u"**/select2/1"), 1)
def test_glob_get_normal_sf_negative_square_brackets_specified(self):
- """Test negative square bracket (specified) [!a,b,c] replacement in get_normal_sf."""
+ u"""Test negative square bracket (specified) [!a,b,c] replacement in get_normal_sf."""
# As in a normal shell, [!...] expands to any single character but those specified
self.assertEqual(self.include_glob_tester(u"/test/hello1.txt", u"/test/hello[!2,3,4].txt"), 1)
self.assertEqual(self.include_glob_tester(u"/test/hello.txt", u"/t[!w,f,h]st/hello.txt"), 1)
@@ -957,7 +957,7 @@
u"/lon[!w,e,g,f]/e[!p,x]ample/path/hello.txt"), None)
def test_glob_get_normal_sf_negative_square_brackets_range(self):
- """Test negative square bracket (range) [!a,b,c] replacement in get_normal_sf."""
+ u"""Test negative square bracket (range) [!a,b,c] replacement in get_normal_sf."""
# As in a normal shell, [!1-5] or [!a-f] expands to any single character not in the range specified
self.assertEqual(self.include_glob_tester(u"/test/hello1.txt", u"/test/hello[!2-4].txt"), 1)
self.assertEqual(self.include_glob_tester(u"/test/hello.txt", u"/t[!f-h]st/hello.txt"), 1)
@@ -969,7 +969,7 @@
u"/lon[!f-p]/e[!p]ample/path/hello.txt"), None)
def test_glob_get_normal_sf_2_ignorecase(self):
- """Test same behaviour as the functional test test_globbing_replacement, ignorecase tests."""
+ u"""Test same behaviour as the functional test test_globbing_replacement, ignorecase tests."""
self.assertEqual(self.include_glob_tester(u"testfiles/select2/2/2sub1",
u"ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1",
u"testfiles/select2"), 1)
@@ -978,12 +978,12 @@
u"testfiles/select2"), 1)
def test_glob_get_normal_sf_3_double_asterisks_dirs_to_scan(self):
- """Test double asterisk (**) replacement in glob_get_normal_sf with directories that should be scanned"""
+ u"""Test double asterisk (**) replacement in glob_get_normal_sf with directories that should be scanned"""
# The new special pattern, **, expands to any string of characters whether or not it contains "/".
self.assertEqual(self.include_glob_tester(u"/long/example/path", u"/**/hello.txt"), 2)
def test_glob_get_normal_sf_3_ignorecase(self):
- """Test ignorecase in glob_get_normal_sf"""
+ u"""Test ignorecase in glob_get_normal_sf"""
# If the pattern starts with "ignorecase:" (case insensitive), then this prefix will be removed and any
# character in the string can be replaced with an upper- or lowercase version of itself.
self.assertEqual(self.include_glob_tester(u"testfiles/select2/2", u"ignorecase:testfiles/select2/2",
@@ -1002,14 +1002,14 @@
u"testfiles/select2"), 0)
def test_glob_dirs_to_scan(self):
- """Test parent directories are marked as needing to be scanned"""
+ u"""Test parent directories are marked as needing to be scanned"""
with patch(u"duplicity.path.Path.isdir") as mock_isdir:
mock_isdir.return_value = True
self.assertEqual(
self.glob_tester(u"parent", u"parent/hello.txt", 1, u"parent"), 2)
def test_glob_dirs_to_scan_glob(self):
- """Test parent directories are marked as needing to be scanned - globs"""
+ u"""Test parent directories are marked as needing to be scanned - globs"""
with patch(u"duplicity.path.Path.isdir") as mock_isdir:
mock_isdir.return_value = True
self.assertEqual(
@@ -1051,5 +1051,5 @@
self.glob_tester(u"testfiles/select/1",
u"*/select/1/1", 1, u"testfiles"), 2)
-if __name__ == "__main__":
+if __name__ == u"__main__":
unittest.main()
Follow ups