Merge lp:~aaron-whitehouse/duplicity/08-unicode into lp:~duplicity-team/duplicity/0.8-series
- 08-unicode
- Merge into 0.8-series
Status: | Merged |
---|---|
Merged at revision: | 1286 |
Proposed branch: | lp:~aaron-whitehouse/duplicity/08-unicode |
Merge into: | lp:~duplicity-team/duplicity/0.8-series |
Diff against target: |
5231 lines (+1843/-1584) 26 files modified
bin/duplicity.1 (+5/-5) debian/control (+2/-0) duplicity/backend.py (+1/-1) duplicity/commandline.py (+6/-6) duplicity/globals.py (+1/-1) duplicity/globmatch.py (+49/-39) duplicity/path.py (+13/-0) duplicity/selection.py (+54/-49) duplicity/util.py (+34/-3) requirements.txt (+1/-0) setup.py (+1/-1) testing/__init__.py (+6/-4) testing/functional/__init__.py (+54/-26) testing/functional/test_badupload.py (+1/-1) testing/functional/test_cleanup.py (+14/-14) testing/functional/test_final.py (+41/-41) testing/functional/test_replicate.py (+10/-10) testing/functional/test_restart.py (+63/-63) testing/functional/test_selection.py (+660/-578) testing/functional/test_verify.py (+20/-20) testing/unit/test_diffdir.py (+0/-2) testing/unit/test_globmatch.py (+118/-59) testing/unit/test_gpg.py (+6/-6) testing/unit/test_patchdir.py (+0/-1) testing/unit/test_selection.py (+681/-654) tox.ini (+2/-0) |
To merge this branch: | bzr merge lp:~aaron-whitehouse/duplicity/08-unicode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
duplicity-team | Pending | ||
Review via email: mp+334622@code.launchpad.net |
Commit message
Many strings have been changed to unicode for better handling of international characters and to make the transition to Python 3 significantly easier, primarily on the 'local' side of duplicity (selection, commandline arguments etc) rather than any backends etc.
Description of the change
Many strings have been changed to unicode for better handling of international characters and to make the transition to Python 3 significantly easier.
In order to merge the changes back into trunk as soon as possible, this branch focuses on just the strings in the 'local' side of duplicity, i.e. those involved in interpreting the selection functions from the commandline arguments or include/exclude lists and reading each file from the local filesystem to compare to these selection functions.
Note:
* This branch introduces Path.uc_name with the filename in unicode, in addition to Path.name with the filename in bytes (i.e. each Path will have a .name and .uc_name). These are both created for each Path object and code throughout duplicity should move to using .uc_name where it needs the unicode name and .name where it needs the bytes name, rather than converting. Valid filenames on the disk in Linux can be invalid unicode, so for Python 2 support it is important that we keep the original bytes .name and use that rather than converting the unicode version. That said, for all internal purposes (e.g. string comparison) we should be using the unicode version. From Python 3.2, it looks as though this has been solved properly and os.fsencode/
* Path.name may be renamed Path.b_name in the future: http://
Preview Diff
1 | === modified file 'bin/duplicity.1' | |||
2 | --- bin/duplicity.1 2017-09-06 14:57:00 +0000 | |||
3 | +++ bin/duplicity.1 2017-12-01 23:01:42 +0000 | |||
4 | @@ -1498,11 +1498,11 @@ | |||
5 | 1498 | and | 1498 | and |
6 | 1499 | .BI --exclude-filelist , | 1499 | .BI --exclude-filelist , |
7 | 1500 | options also introduce file selection conditions. They direct | 1500 | options also introduce file selection conditions. They direct |
13 | 1501 | duplicity to read in a file, each line of which is a file | 1501 | duplicity to read in a text file (either ASCII or UTF-8), each line |
14 | 1502 | specification, and to include or exclude the matching files. Lines | 1502 | of which is a file specification, and to include or exclude the |
15 | 1503 | are separated by newlines or nulls, depending on whether the | 1503 | matching files. Lines are separated by newlines or nulls, depending |
16 | 1504 | --null-separator switch was given. Each line in the filelist will be | 1504 | on whether the --null-separator switch was given. Each line in the |
17 | 1505 | interpreted as a globbing pattern the way | 1505 | filelist will be interpreted as a globbing pattern the way |
18 | 1506 | .BI --include | 1506 | .BI --include |
19 | 1507 | and | 1507 | and |
20 | 1508 | .BI --exclude | 1508 | .BI --exclude |
21 | 1509 | 1509 | ||
22 | === modified file 'debian/control' | |||
23 | --- debian/control 2017-10-12 19:42:50 +0000 | |||
24 | +++ debian/control 2017-12-01 23:01:42 +0000 | |||
25 | @@ -11,6 +11,7 @@ | |||
26 | 11 | pylint, | 11 | pylint, |
27 | 12 | python-dev, | 12 | python-dev, |
28 | 13 | python-fasteners, | 13 | python-fasteners, |
29 | 14 | python-future, | ||
30 | 14 | python-mock, | 15 | python-mock, |
31 | 15 | python-pexpect, | 16 | python-pexpect, |
32 | 16 | python-setuptools, | 17 | python-setuptools, |
33 | @@ -28,6 +29,7 @@ | |||
34 | 28 | ${shlibs:Depends}, | 29 | ${shlibs:Depends}, |
35 | 29 | gnupg, | 30 | gnupg, |
36 | 30 | python-fasteners, | 31 | python-fasteners, |
37 | 32 | python-future, | ||
38 | 31 | python-pexpect, | 33 | python-pexpect, |
39 | 32 | Suggests: ncftp, | 34 | Suggests: ncftp, |
40 | 33 | python-boto, | 35 | python-boto, |
41 | 34 | 36 | ||
42 | === modified file 'duplicity/backend.py' | |||
43 | --- duplicity/backend.py 2017-11-23 13:02:23 +0000 | |||
44 | +++ duplicity/backend.py 2017-12-01 23:01:42 +0000 | |||
45 | @@ -383,7 +383,7 @@ | |||
46 | 383 | if at_end and fatal: | 383 | if at_end and fatal: |
47 | 384 | def make_filename(f): | 384 | def make_filename(f): |
48 | 385 | if isinstance(f, path.ROPath): | 385 | if isinstance(f, path.ROPath): |
50 | 386 | return util.escape(f.name) | 386 | return util.escape(f.uc_name) |
51 | 387 | else: | 387 | else: |
52 | 388 | return util.escape(f) | 388 | return util.escape(f) |
53 | 389 | extra = ' '.join([operation] + [make_filename(x) for x in args if x]) | 389 | extra = ' '.join([operation] + [make_filename(x) for x in args if x]) |
54 | 390 | 390 | ||
55 | === modified file 'duplicity/commandline.py' | |||
56 | --- duplicity/commandline.py 2017-09-01 11:46:59 +0000 | |||
57 | +++ duplicity/commandline.py 2017-12-01 23:01:42 +0000 | |||
58 | @@ -30,6 +30,7 @@ | |||
59 | 30 | import re | 30 | import re |
60 | 31 | import sys | 31 | import sys |
61 | 32 | import socket | 32 | import socket |
62 | 33 | import io | ||
63 | 33 | 34 | ||
64 | 34 | try: | 35 | try: |
65 | 35 | from hashlib import md5 | 36 | from hashlib import md5 |
66 | @@ -251,14 +252,13 @@ | |||
67 | 251 | globals.time_separator = sep | 252 | globals.time_separator = sep |
68 | 252 | old_fn_deprecation(opt) | 253 | old_fn_deprecation(opt) |
69 | 253 | 254 | ||
72 | 254 | def add_selection(o, s, v, p): | 255 | def add_selection(o, option, additional_arg, p): |
73 | 255 | select_opts.append((s, v)) | 256 | select_opts.append((util.fsdecode(option), util.fsdecode(additional_arg))) |
74 | 256 | 257 | ||
78 | 257 | def add_filelist(o, s, v, p): | 258 | def add_filelist(o, s, filename, p): |
79 | 258 | filename = v | 259 | select_opts.append((util.fsdecode(s), util.fsdecode(filename))) |
77 | 259 | select_opts.append((s, filename)) | ||
80 | 260 | try: | 260 | try: |
82 | 261 | select_files.append(open(filename, "r")) | 261 | select_files.append(io.open(filename, "rt", encoding="UTF-8")) |
83 | 262 | except IOError: | 262 | except IOError: |
84 | 263 | log.FatalError(_("Error opening file %s") % filename, | 263 | log.FatalError(_("Error opening file %s") % filename, |
85 | 264 | log.ErrorCode.cant_open_filelist) | 264 | log.ErrorCode.cant_open_filelist) |
86 | 265 | 265 | ||
87 | === modified file 'duplicity/globals.py' | |||
88 | --- duplicity/globals.py 2017-11-23 13:02:23 +0000 | |||
89 | +++ duplicity/globals.py 2017-12-01 23:01:42 +0000 | |||
90 | @@ -321,4 +321,4 @@ | |||
91 | 321 | # 'utf-8' or some other sane encoding, but will sometimes fail and return | 321 | # 'utf-8' or some other sane encoding, but will sometimes fail and return |
92 | 322 | # either 'ascii' or None. Both are bogus, so default to 'utf-8' if it does. | 322 | # either 'ascii' or None. Both are bogus, so default to 'utf-8' if it does. |
93 | 323 | fsencoding = sys.getfilesystemencoding() | 323 | fsencoding = sys.getfilesystemencoding() |
95 | 324 | fsencoding = fsencoding if fsencoding not in ['ascii', None] else 'utf-8' | 324 | fsencoding = fsencoding if fsencoding not in ['ascii', 'ANSI_X3.4-1968', None] else 'utf-8' |
96 | 325 | 325 | ||
97 | === modified file 'duplicity/globmatch.py' | |||
98 | --- duplicity/globmatch.py 2017-07-11 14:55:38 +0000 | |||
99 | +++ duplicity/globmatch.py 2017-12-01 23:01:42 +0000 | |||
100 | @@ -19,9 +19,15 @@ | |||
101 | 19 | # You should have received a copy of the GNU General Public License | 19 | # You should have received a copy of the GNU General Public License |
102 | 20 | # along with duplicity; if not, write to the Free Software Foundation, | 20 | # along with duplicity; if not, write to the Free Software Foundation, |
103 | 21 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
104 | 22 | # | ||
105 | 23 | # All functions in this module only accept unicode. Any byte strings should | ||
106 | 24 | # be converted to unicode before sending them into this. | ||
107 | 22 | 25 | ||
108 | 23 | import re | 26 | import re |
109 | 24 | 27 | ||
110 | 28 | from builtins import map | ||
111 | 29 | from builtins import range | ||
112 | 30 | |||
113 | 25 | 31 | ||
114 | 26 | class GlobbingError(Exception): | 32 | class GlobbingError(Exception): |
115 | 27 | """Something has gone wrong when parsing a glob string""" | 33 | """Something has gone wrong when parsing a glob string""" |
116 | @@ -36,16 +42,16 @@ | |||
117 | 36 | def _glob_get_prefix_regexs(glob_str): | 42 | def _glob_get_prefix_regexs(glob_str): |
118 | 37 | """Return list of regexps equivalent to prefixes of glob_str""" | 43 | """Return list of regexps equivalent to prefixes of glob_str""" |
119 | 38 | # Internal. Used by glob_get_normal_sf. | 44 | # Internal. Used by glob_get_normal_sf. |
122 | 39 | glob_parts = glob_str.split("/") | 45 | glob_parts = glob_str.split(u"/") |
123 | 40 | if "" in glob_parts[1:-1]: | 46 | if u"" in glob_parts[1:-1]: |
124 | 41 | # "" OK if comes first or last, as in /foo/ | 47 | # "" OK if comes first or last, as in /foo/ |
126 | 42 | raise GlobbingError("Consecutive '/'s found in globbing string " + | 48 | raise GlobbingError(u"Consecutive '/'s found in globbing string " + |
127 | 43 | glob_str) | 49 | glob_str) |
128 | 44 | 50 | ||
130 | 45 | prefixes = ["/".join(glob_parts[:i + 1]) for i in range(len(glob_parts))] | 51 | prefixes = [u"/".join(glob_parts[:i + 1]) for i in range(len(glob_parts))] |
131 | 46 | # we must make exception for root "/", only dir to end in slash | 52 | # we must make exception for root "/", only dir to end in slash |
134 | 47 | if prefixes[0] == "": | 53 | if prefixes[0] == u"": |
135 | 48 | prefixes[0] = "/" | 54 | prefixes[0] = u"/" |
136 | 49 | return list(map(glob_to_regex, prefixes)) | 55 | return list(map(glob_to_regex, prefixes)) |
137 | 50 | 56 | ||
138 | 51 | 57 | ||
139 | @@ -62,12 +68,13 @@ | |||
140 | 62 | 68 | ||
141 | 63 | Note: including a folder implicitly includes everything within it. | 69 | Note: including a folder implicitly includes everything within it. |
142 | 64 | """ | 70 | """ |
143 | 71 | assert isinstance(glob_str, unicode) | ||
144 | 65 | glob_ends_w_slash = False | 72 | glob_ends_w_slash = False |
145 | 66 | 73 | ||
147 | 67 | if glob_str == "/": | 74 | if glob_str == u"/": |
148 | 68 | # If the glob string is '/', it implicitly includes everything | 75 | # If the glob string is '/', it implicitly includes everything |
151 | 69 | glob_str = "/**" | 76 | glob_str = u"/**" |
152 | 70 | elif glob_str[-1] == "/": | 77 | elif glob_str[-1] == u"/": |
153 | 71 | glob_ends_w_slash = True | 78 | glob_ends_w_slash = True |
154 | 72 | # Remove trailing / from directory name (unless that is the entire | 79 | # Remove trailing / from directory name (unless that is the entire |
155 | 73 | # string) | 80 | # string) |
156 | @@ -87,39 +94,39 @@ | |||
157 | 87 | # Note that the "/" at the end of the regex means that it will match | 94 | # Note that the "/" at the end of the regex means that it will match |
158 | 88 | # if the glob matches a parent folders of path, i.e. including a folder | 95 | # if the glob matches a parent folders of path, i.e. including a folder |
159 | 89 | # includes everything within it. | 96 | # includes everything within it. |
161 | 90 | glob_comp_re = re_comp("^%s($|/)" % glob_to_regex(glob_str)) | 97 | glob_comp_re = re_comp(u"^%s($|/)" % glob_to_regex(glob_str)) |
162 | 91 | 98 | ||
163 | 92 | if glob_ends_w_slash: | 99 | if glob_ends_w_slash: |
164 | 93 | # Creates a version of glob_comp_re that does not match folder contents | 100 | # Creates a version of glob_comp_re that does not match folder contents |
165 | 94 | # This can be used later to check that an exact match is actually a | 101 | # This can be used later to check that an exact match is actually a |
166 | 95 | # folder, rather than a file. | 102 | # folder, rather than a file. |
168 | 96 | glob_comp_re_exact = re_comp("^%s($)" % glob_to_regex(glob_str)) | 103 | glob_comp_re_exact = re_comp(u"^%s($)" % glob_to_regex(glob_str)) |
169 | 97 | 104 | ||
171 | 98 | if glob_str.find("**") != -1: | 105 | if glob_str.find(u"**") != -1: |
172 | 99 | # glob_str has a ** in it | 106 | # glob_str has a ** in it |
174 | 100 | glob_str = glob_str[:glob_str.find("**") + 2] # truncate after ** | 107 | glob_str = glob_str[:glob_str.find(u"**") + 2] # truncate after ** |
175 | 101 | 108 | ||
176 | 102 | # Below regex is translates to: | 109 | # Below regex is translates to: |
177 | 103 | # ^ string must be at the beginning of path | 110 | # ^ string must be at the beginning of path |
178 | 104 | # the regexs corresponding to the parent directories of glob_str | 111 | # the regexs corresponding to the parent directories of glob_str |
179 | 105 | # $ nothing must follow except for the end of the string or newline | 112 | # $ nothing must follow except for the end of the string or newline |
182 | 106 | scan_comp_re = re_comp("^(%s)$" % | 113 | scan_comp_re = re_comp(u"^(%s)$" % |
183 | 107 | "|".join(_glob_get_prefix_regexs(glob_str))) | 114 | u"|".join(_glob_get_prefix_regexs(glob_str))) |
184 | 108 | 115 | ||
185 | 109 | def test_fn(path): | 116 | def test_fn(path): |
190 | 110 | assert not path.name[-1] == "/" or path.name == "/", \ | 117 | assert not path.uc_name[-1] == u"/" or path.uc_name == u"/", \ |
191 | 111 | "path.name should never end in '/' during normal operation for " \ | 118 | u"path.name should never end in '/' during normal operation for " \ |
192 | 112 | "normal paths (except '/' alone)\n" \ | 119 | u"normal paths (except '/' alone)\n" \ |
193 | 113 | "path.name here is " + path.name + " and glob is " + glob_str | 120 | u"path.name here is " + path.uc_name + u" and glob is " + glob_str |
194 | 114 | 121 | ||
196 | 115 | if glob_comp_re.match(path.name): | 122 | if glob_comp_re.match(path.uc_name): |
197 | 116 | # Path matches glob, or is contained within a matching folder | 123 | # Path matches glob, or is contained within a matching folder |
198 | 117 | if not glob_ends_w_slash: | 124 | if not glob_ends_w_slash: |
199 | 118 | return include | 125 | return include |
200 | 119 | else: | 126 | else: |
201 | 120 | # Glob ended with a /, so we need to check any exact match was | 127 | # Glob ended with a /, so we need to check any exact match was |
202 | 121 | # a folder | 128 | # a folder |
204 | 122 | if glob_comp_re_exact.match(path.name): | 129 | if glob_comp_re_exact.match(path.uc_name): |
205 | 123 | # Not an included file/folder, so must be a folder to match | 130 | # Not an included file/folder, so must be a folder to match |
206 | 124 | if path.isdir(): | 131 | if path.isdir(): |
207 | 125 | # Is a directory, so all is well | 132 | # Is a directory, so all is well |
208 | @@ -131,7 +138,7 @@ | |||
209 | 131 | # An included file/folder, so normal approach is fine | 138 | # An included file/folder, so normal approach is fine |
210 | 132 | return include | 139 | return include |
211 | 133 | 140 | ||
213 | 134 | elif include == 1 and scan_comp_re.match(path.name): | 141 | elif include == 1 and scan_comp_re.match(path.uc_name): |
214 | 135 | return 2 | 142 | return 2 |
215 | 136 | else: | 143 | else: |
216 | 137 | return None | 144 | return None |
217 | @@ -151,34 +158,37 @@ | |||
218 | 151 | 158 | ||
219 | 152 | """ | 159 | """ |
220 | 153 | # Internal. Used by glob_get_normal_sf, glob_get_prefix_res and unit tests. | 160 | # Internal. Used by glob_get_normal_sf, glob_get_prefix_res and unit tests. |
221 | 161 | |||
222 | 162 | assert isinstance(pat, unicode) | ||
223 | 163 | |||
224 | 154 | i, n, res = 0, len(pat), '' | 164 | i, n, res = 0, len(pat), '' |
225 | 155 | while i < n: | 165 | while i < n: |
226 | 156 | c, s = pat[i], pat[i:i + 2] | 166 | c, s = pat[i], pat[i:i + 2] |
227 | 157 | i = i + 1 | 167 | i = i + 1 |
230 | 158 | if s == '**': | 168 | if s == u'**': |
231 | 159 | res = res + '.*' | 169 | res = res + u'.*' |
232 | 160 | i = i + 1 | 170 | i = i + 1 |
238 | 161 | elif c == '*': | 171 | elif c == u'*': |
239 | 162 | res = res + '[^/]*' | 172 | res = res + u'[^/]*' |
240 | 163 | elif c == '?': | 173 | elif c == u'?': |
241 | 164 | res = res + '[^/]' | 174 | res = res + u'[^/]' |
242 | 165 | elif c == '[': | 175 | elif c == u'[': |
243 | 166 | j = i | 176 | j = i |
249 | 167 | if j < n and pat[j] in '!^': | 177 | if j < n and pat[j] in u'!^': |
250 | 168 | j = j + 1 | 178 | j = j + 1 |
251 | 169 | if j < n and pat[j] == ']': | 179 | if j < n and pat[j] == u']': |
252 | 170 | j = j + 1 | 180 | j = j + 1 |
253 | 171 | while j < n and pat[j] != ']': | 181 | while j < n and pat[j] != u']': |
254 | 172 | j = j + 1 | 182 | j = j + 1 |
255 | 173 | if j >= n: | 183 | if j >= n: |
257 | 174 | res = res + '\\[' # interpret the [ literally | 184 | res = res + u'\\[' # interpret the [ literally |
258 | 175 | else: | 185 | else: |
259 | 176 | # Deal with inside of [..] | 186 | # Deal with inside of [..] |
261 | 177 | stuff = pat[i:j].replace('\\', '\\\\') | 187 | stuff = pat[i:j].replace(u'\\', u'\\\\') |
262 | 178 | i = j + 1 | 188 | i = j + 1 |
266 | 179 | if stuff[0] in '!^': | 189 | if stuff[0] in u'!^': |
267 | 180 | stuff = '^' + stuff[1:] | 190 | stuff = u'^' + stuff[1:] |
268 | 181 | res = res + '[' + stuff + ']' | 191 | res = res + u'[' + stuff + u']' |
269 | 182 | else: | 192 | else: |
270 | 183 | res = res + re.escape(c) | 193 | res = res + re.escape(c) |
271 | 184 | return res | 194 | return res |
272 | 185 | 195 | ||
273 | === modified file 'duplicity/path.py' | |||
274 | --- duplicity/path.py 2017-07-11 14:55:38 +0000 | |||
275 | +++ duplicity/path.py 2017-12-01 23:01:42 +0000 | |||
276 | @@ -35,6 +35,7 @@ | |||
277 | 35 | import re | 35 | import re |
278 | 36 | import gzip | 36 | import gzip |
279 | 37 | import shutil | 37 | import shutil |
280 | 38 | import sys | ||
281 | 38 | 39 | ||
282 | 39 | from duplicity import tarfile | 40 | from duplicity import tarfile |
283 | 40 | from duplicity import file_naming | 41 | from duplicity import file_naming |
284 | @@ -511,9 +512,21 @@ | |||
285 | 511 | # self.opened should be true if the file has been opened, and | 512 | # self.opened should be true if the file has been opened, and |
286 | 512 | # self.fileobj can override returned fileobj | 513 | # self.fileobj can override returned fileobj |
287 | 513 | self.opened, self.fileobj = None, None | 514 | self.opened, self.fileobj = None, None |
288 | 515 | if isinstance(base, unicode): | ||
289 | 516 | # For now (Python 2), it is helpful to know that all paths | ||
290 | 517 | # are starting with bytes -- see note above util.fsencode definition | ||
291 | 518 | base = util.fsencode(base) | ||
292 | 514 | self.base = base | 519 | self.base = base |
293 | 520 | |||
294 | 521 | # Create self.index, which is the path as a tuple | ||
295 | 515 | self.index = self.rename_index(index) | 522 | self.index = self.rename_index(index) |
296 | 523 | |||
297 | 516 | self.name = os.path.join(base, *self.index) | 524 | self.name = os.path.join(base, *self.index) |
298 | 525 | |||
299 | 526 | # We converted any unicode base to filesystem encoding, so self.name should | ||
300 | 527 | # be in filesystem encoding already and does not need to change | ||
301 | 528 | self.uc_name = util.fsdecode(self.name) | ||
302 | 529 | |||
303 | 517 | self.setdata() | 530 | self.setdata() |
304 | 518 | 531 | ||
305 | 519 | def setdata(self): | 532 | def setdata(self): |
306 | 520 | 533 | ||
307 | === modified file 'duplicity/selection.py' | |||
308 | --- duplicity/selection.py 2017-07-11 14:55:38 +0000 | |||
309 | +++ duplicity/selection.py 2017-12-01 23:01:42 +0000 | |||
310 | @@ -90,7 +90,7 @@ | |||
311 | 90 | assert isinstance(path, Path), str(path) | 90 | assert isinstance(path, Path), str(path) |
312 | 91 | self.selection_functions = [] | 91 | self.selection_functions = [] |
313 | 92 | self.rootpath = path | 92 | self.rootpath = path |
315 | 93 | self.prefix = self.rootpath.name | 93 | self.prefix = self.rootpath.uc_name |
316 | 94 | 94 | ||
317 | 95 | def set_iter(self): | 95 | def set_iter(self): |
318 | 96 | """Initialize generator, prepare to iterate.""" | 96 | """Initialize generator, prepare to iterate.""" |
319 | @@ -164,10 +164,10 @@ | |||
320 | 164 | 164 | ||
321 | 165 | if not path.type: | 165 | if not path.type: |
322 | 166 | # base doesn't exist | 166 | # base doesn't exist |
325 | 167 | log.Warn(_("Warning: base %s doesn't exist, continuing") % | 167 | log.Warn(_(u"Warning: base %s doesn't exist, continuing") % |
326 | 168 | util.ufn(path.name)) | 168 | path.uc_name) |
327 | 169 | return | 169 | return |
329 | 170 | log.Debug(_("Selecting %s") % util.ufn(path.name)) | 170 | log.Debug(_(u"Selecting %s") % path.uc_name) |
330 | 171 | yield path | 171 | yield path |
331 | 172 | if not path.isdir(): | 172 | if not path.isdir(): |
332 | 173 | return | 173 | return |
333 | @@ -185,10 +185,10 @@ | |||
334 | 185 | if val == 0: | 185 | if val == 0: |
335 | 186 | if delayed_path_stack: | 186 | if delayed_path_stack: |
336 | 187 | for delayed_path in delayed_path_stack: | 187 | for delayed_path in delayed_path_stack: |
338 | 188 | log.Log(_("Selecting %s") % util.ufn(delayed_path.name), 6) | 188 | log.Log(_(u"Selecting %s") % delayed_path.uc_name, 6) |
339 | 189 | yield delayed_path | 189 | yield delayed_path |
340 | 190 | del delayed_path_stack[:] | 190 | del delayed_path_stack[:] |
342 | 191 | log.Debug(_("Selecting %s") % util.ufn(subpath.name)) | 191 | log.Debug(_(u"Selecting %s") % subpath.uc_name) |
343 | 192 | yield subpath | 192 | yield subpath |
344 | 193 | if subpath.isdir(): | 193 | if subpath.isdir(): |
345 | 194 | diryield_stack.append(diryield(subpath)) | 194 | diryield_stack.append(diryield(subpath)) |
346 | @@ -199,14 +199,14 @@ | |||
347 | 199 | def Select(self, path): | 199 | def Select(self, path): |
348 | 200 | """Run through the selection functions and return dominant val 0/1/2""" | 200 | """Run through the selection functions and return dominant val 0/1/2""" |
349 | 201 | # Only used by diryield and tests. Internal. | 201 | # Only used by diryield and tests. Internal. |
351 | 202 | log.Debug("Selection: examining path %s" % util.ufn(path.name)) | 202 | log.Debug(u"Selection: examining path %s" % path.uc_name) |
352 | 203 | if not self.selection_functions: | 203 | if not self.selection_functions: |
354 | 204 | log.Debug("Selection: + no selection functions found. Including") | 204 | log.Debug(u"Selection: + no selection functions found. Including") |
355 | 205 | return 1 | 205 | return 1 |
356 | 206 | scan_pending = False | 206 | scan_pending = False |
357 | 207 | for sf in self.selection_functions: | 207 | for sf in self.selection_functions: |
358 | 208 | result = sf(path) | 208 | result = sf(path) |
360 | 209 | log.Debug("Selection: result: %4s from function: %s" % | 209 | log.Debug(u"Selection: result: %4s from function: %s" % |
361 | 210 | (str(result), sf.name)) | 210 | (str(result), sf.name)) |
362 | 211 | if result is 2: | 211 | if result is 2: |
363 | 212 | # Selection function says that the path should be scanned for matching files, but keep going | 212 | # Selection function says that the path should be scanned for matching files, but keep going |
364 | @@ -224,12 +224,12 @@ | |||
365 | 224 | result = 1 | 224 | result = 1 |
366 | 225 | 225 | ||
367 | 226 | if result == 0: | 226 | if result == 0: |
369 | 227 | log.Debug("Selection: - excluding file") | 227 | log.Debug(u"Selection: - excluding file") |
370 | 228 | elif result == 1: | 228 | elif result == 1: |
372 | 229 | log.Debug("Selection: + including file") | 229 | log.Debug(u"Selection: + including file") |
373 | 230 | else: | 230 | else: |
374 | 231 | assert result == 2 | 231 | assert result == 2 |
376 | 232 | log.Debug("Selection: ? scanning directory for matches") | 232 | log.Debug(u"Selection: ? scanning directory for matches") |
377 | 233 | 233 | ||
378 | 234 | return result | 234 | return result |
379 | 235 | 235 | ||
380 | @@ -246,36 +246,41 @@ | |||
381 | 246 | filelists_index = 0 | 246 | filelists_index = 0 |
382 | 247 | try: | 247 | try: |
383 | 248 | for opt, arg in argtuples: | 248 | for opt, arg in argtuples: |
385 | 249 | if opt == "--exclude": | 249 | assert isinstance(opt, unicode), u"option " + opt.decode(sys.getfilesystemencoding(), "ignore") + \ |
386 | 250 | u" is not unicode" | ||
387 | 251 | assert isinstance(arg, unicode), u"option " + arg.decode(sys.getfilesystemencoding(), "ignore") + \ | ||
388 | 252 | u" is not unicode" | ||
389 | 253 | |||
390 | 254 | if opt == u"--exclude": | ||
391 | 250 | self.add_selection_func(self.glob_get_sf(arg, 0)) | 255 | self.add_selection_func(self.glob_get_sf(arg, 0)) |
393 | 251 | elif opt == "--exclude-if-present": | 256 | elif opt == u"--exclude-if-present": |
394 | 252 | self.add_selection_func(self.present_get_sf(arg, 0)) | 257 | self.add_selection_func(self.present_get_sf(arg, 0)) |
396 | 253 | elif opt == "--exclude-device-files": | 258 | elif opt == u"--exclude-device-files": |
397 | 254 | self.add_selection_func(self.devfiles_get_sf()) | 259 | self.add_selection_func(self.devfiles_get_sf()) |
399 | 255 | elif (opt == "--exclude-filelist") or (opt == "--exclude-globbing-filelist"): | 260 | elif (opt == u"--exclude-filelist") or (opt == u"--exclude-globbing-filelist"): |
400 | 256 | # --exclude-globbing-filelist is now deprecated, as all filelists are globbing | 261 | # --exclude-globbing-filelist is now deprecated, as all filelists are globbing |
401 | 257 | # but keep this here for the short term for backwards-compatibility | 262 | # but keep this here for the short term for backwards-compatibility |
402 | 258 | for sf in self.filelist_globbing_get_sfs(filelists[filelists_index], 0, arg): | 263 | for sf in self.filelist_globbing_get_sfs(filelists[filelists_index], 0, arg): |
403 | 259 | self.add_selection_func(sf) | 264 | self.add_selection_func(sf) |
404 | 260 | filelists_index += 1 | 265 | filelists_index += 1 |
406 | 261 | elif opt == "--exclude-other-filesystems": | 266 | elif opt == u"--exclude-other-filesystems": |
407 | 262 | self.add_selection_func(self.other_filesystems_get_sf(0)) | 267 | self.add_selection_func(self.other_filesystems_get_sf(0)) |
409 | 263 | elif opt == "--exclude-regexp": | 268 | elif opt == u"--exclude-regexp": |
410 | 264 | self.add_selection_func(self.regexp_get_sf(arg, 0)) | 269 | self.add_selection_func(self.regexp_get_sf(arg, 0)) |
412 | 265 | elif opt == "--exclude-older-than": | 270 | elif opt == u"--exclude-older-than": |
413 | 266 | self.add_selection_func(self.exclude_older_get_sf(arg)) | 271 | self.add_selection_func(self.exclude_older_get_sf(arg)) |
415 | 267 | elif opt == "--include": | 272 | elif opt == u"--include": |
416 | 268 | self.add_selection_func(self.glob_get_sf(arg, 1)) | 273 | self.add_selection_func(self.glob_get_sf(arg, 1)) |
418 | 269 | elif (opt == "--include-filelist") or (opt == "--include-globbing-filelist"): | 274 | elif (opt == u"--include-filelist") or (opt == u"--include-globbing-filelist"): |
419 | 270 | # --include-globbing-filelist is now deprecated, as all filelists are globbing | 275 | # --include-globbing-filelist is now deprecated, as all filelists are globbing |
420 | 271 | # but keep this here for the short term for backwards-compatibility | 276 | # but keep this here for the short term for backwards-compatibility |
421 | 272 | for sf in self.filelist_globbing_get_sfs(filelists[filelists_index], 1, arg): | 277 | for sf in self.filelist_globbing_get_sfs(filelists[filelists_index], 1, arg): |
422 | 273 | self.add_selection_func(sf) | 278 | self.add_selection_func(sf) |
423 | 274 | filelists_index += 1 | 279 | filelists_index += 1 |
425 | 275 | elif opt == "--include-regexp": | 280 | elif opt == u"--include-regexp": |
426 | 276 | self.add_selection_func(self.regexp_get_sf(arg, 1)) | 281 | self.add_selection_func(self.regexp_get_sf(arg, 1)) |
427 | 277 | else: | 282 | else: |
429 | 278 | assert 0, "Bad selection option %s" % opt | 283 | assert 0, u"Bad selection option %s" % opt |
430 | 279 | except SelectError as e: | 284 | except SelectError as e: |
431 | 280 | self.parse_catch_error(e) | 285 | self.parse_catch_error(e) |
432 | 281 | assert filelists_index == len(filelists) | 286 | assert filelists_index == len(filelists) |
433 | @@ -285,16 +290,16 @@ | |||
434 | 285 | """Deal with selection error exc""" | 290 | """Deal with selection error exc""" |
435 | 286 | # Internal, used by ParseArgs. | 291 | # Internal, used by ParseArgs. |
436 | 287 | if isinstance(exc, FilePrefixError): | 292 | if isinstance(exc, FilePrefixError): |
438 | 288 | log.FatalError(_("""\ | 293 | log.FatalError(_(u"""\ |
439 | 289 | Fatal Error: The file specification | 294 | Fatal Error: The file specification |
440 | 290 | %s | 295 | %s |
441 | 291 | cannot match any files in the base directory | 296 | cannot match any files in the base directory |
442 | 292 | %s | 297 | %s |
443 | 293 | Useful file specifications begin with the base directory or some | 298 | Useful file specifications begin with the base directory or some |
444 | 294 | pattern (such as '**') which matches the base directory.""") % | 299 | pattern (such as '**') which matches the base directory.""") % |
446 | 295 | (exc, util.ufn(self.prefix)), log.ErrorCode.file_prefix_error) | 300 | (exc, self.prefix), log.ErrorCode.file_prefix_error) |
447 | 296 | elif isinstance(exc, GlobbingError): | 301 | elif isinstance(exc, GlobbingError): |
449 | 297 | log.FatalError(_("Fatal Error while processing expression\n" | 302 | log.FatalError(_(u"Fatal Error while processing expression\n" |
450 | 298 | "%s") % exc, log.ErrorCode.globbing_error) | 303 | "%s") % exc, log.ErrorCode.globbing_error) |
451 | 299 | else: | 304 | else: |
452 | 300 | raise # pylint: disable=misplaced-bare-raise | 305 | raise # pylint: disable=misplaced-bare-raise |
453 | @@ -304,7 +309,7 @@ | |||
454 | 304 | # Internal. Used by ParseArgs. | 309 | # Internal. Used by ParseArgs. |
455 | 305 | if (self.selection_functions and | 310 | if (self.selection_functions and |
456 | 306 | not self.selection_functions[-1].exclude): | 311 | not self.selection_functions[-1].exclude): |
458 | 307 | log.FatalError(_("""\ | 312 | log.FatalError(_(u"""\ |
459 | 308 | Last selection expression: | 313 | Last selection expression: |
460 | 309 | %s | 314 | %s |
461 | 310 | only specifies that files be included. Because the default is to | 315 | only specifies that files be included. Because the default is to |
462 | @@ -333,19 +338,19 @@ | |||
463 | 333 | line = line.strip() | 338 | line = line.strip() |
464 | 334 | if not line: # skip blanks | 339 | if not line: # skip blanks |
465 | 335 | return None, include_default | 340 | return None, include_default |
467 | 336 | if line[0] == "#": # skip full-line comments | 341 | if line.startswith(u"#"): # skip full-line comments |
468 | 337 | return None, include_default | 342 | return None, include_default |
469 | 338 | 343 | ||
470 | 339 | include = include_default | 344 | include = include_default |
472 | 340 | if line[:2] == "+ ": | 345 | if line.startswith(u"+ "): |
473 | 341 | # Check for "+ " or "- " syntax | 346 | # Check for "+ " or "- " syntax |
474 | 342 | include = 1 | 347 | include = 1 |
475 | 343 | line = line[2:] | 348 | line = line[2:] |
477 | 344 | elif line[:2] == "- ": | 349 | elif line.startswith(u"- "): |
478 | 345 | include = 0 | 350 | include = 0 |
479 | 346 | line = line[2:] | 351 | line = line[2:] |
480 | 347 | 352 | ||
482 | 348 | if (line[:1] == "'" and line[-1:] == "'") or (line[:1] == '"' and line[-1:] == '"'): | 353 | if (line.startswith(u"'") and line.endswith(u"'")) or (line.startswith(u'"') and line.endswith(u'"')): |
483 | 349 | line = line[1:-1] | 354 | line = line[1:-1] |
484 | 350 | 355 | ||
485 | 351 | return line, include | 356 | return line, include |
486 | @@ -360,8 +365,8 @@ | |||
487 | 360 | 365 | ||
488 | 361 | """ | 366 | """ |
489 | 362 | # Internal. Used by ParseArgs. | 367 | # Internal. Used by ParseArgs. |
492 | 363 | log.Notice(_("Reading globbing filelist %s") % list_name) | 368 | log.Notice(_(u"Reading globbing filelist %s") % list_name) |
493 | 364 | separator = globals.null_separator and "\0" or "\n" | 369 | separator = globals.null_separator and u"\0" or u"\n" |
494 | 365 | filelist_fp.seek(0) | 370 | filelist_fp.seek(0) |
495 | 366 | for line in filelist_fp.read().split(separator): | 371 | for line in filelist_fp.read().split(separator): |
496 | 367 | line, include = self.filelist_sanitise_line(line, inc_default) | 372 | line, include = self.filelist_sanitise_line(line, inc_default) |
497 | @@ -383,7 +388,7 @@ | |||
498 | 383 | return None | 388 | return None |
499 | 384 | 389 | ||
500 | 385 | sel_func.exclude = not include | 390 | sel_func.exclude = not include |
502 | 386 | sel_func.name = "Match other filesystems" | 391 | sel_func.name = u"Match other filesystems" |
503 | 387 | return sel_func | 392 | return sel_func |
504 | 388 | 393 | ||
505 | 389 | def regexp_get_sf(self, regexp_string, include): | 394 | def regexp_get_sf(self, regexp_string, include): |
506 | @@ -393,24 +398,24 @@ | |||
507 | 393 | try: | 398 | try: |
508 | 394 | regexp = re.compile(regexp_string) | 399 | regexp = re.compile(regexp_string) |
509 | 395 | except Exception: | 400 | except Exception: |
511 | 396 | log.Warn(_("Error compiling regular expression %s") % regexp_string) | 401 | log.Warn(_(u"Error compiling regular expression %s") % regexp_string) |
512 | 397 | raise | 402 | raise |
513 | 398 | 403 | ||
514 | 399 | def sel_func(path): | 404 | def sel_func(path): |
516 | 400 | if regexp.search(path.name): | 405 | if regexp.search(path.uc_name): |
517 | 401 | return include | 406 | return include |
518 | 402 | else: | 407 | else: |
519 | 403 | return None | 408 | return None |
520 | 404 | 409 | ||
521 | 405 | sel_func.exclude = not include | 410 | sel_func.exclude = not include |
523 | 406 | sel_func.name = "Regular expression: %s" % regexp_string | 411 | sel_func.name = u"Regular expression: %s" % regexp_string |
524 | 407 | return sel_func | 412 | return sel_func |
525 | 408 | 413 | ||
526 | 409 | def devfiles_get_sf(self): | 414 | def devfiles_get_sf(self): |
527 | 410 | """Return a selection function to exclude all dev files""" | 415 | """Return a selection function to exclude all dev files""" |
528 | 411 | # Internal. Used by ParseArgs. | 416 | # Internal. Used by ParseArgs. |
529 | 412 | if self.selection_functions: | 417 | if self.selection_functions: |
531 | 413 | log.Warn(_("Warning: exclude-device-files is not the first " | 418 | log.Warn(_(u"Warning: exclude-device-files is not the first " |
532 | 414 | "selector.\nThis may not be what you intended")) | 419 | "selector.\nThis may not be what you intended")) |
533 | 415 | 420 | ||
534 | 416 | def sel_func(path): | 421 | def sel_func(path): |
535 | @@ -420,21 +425,22 @@ | |||
536 | 420 | return None | 425 | return None |
537 | 421 | 426 | ||
538 | 422 | sel_func.exclude = 1 | 427 | sel_func.exclude = 1 |
540 | 423 | sel_func.name = "Exclude device files" | 428 | sel_func.name = u"Exclude device files" |
541 | 424 | return sel_func | 429 | return sel_func |
542 | 425 | 430 | ||
543 | 426 | def glob_get_sf(self, glob_str, include): | 431 | def glob_get_sf(self, glob_str, include): |
544 | 427 | """Return selection function given by glob string""" | 432 | """Return selection function given by glob string""" |
545 | 428 | # Internal. Used by ParseArgs, filelist_globbing_get_sfs and unit tests. | 433 | # Internal. Used by ParseArgs, filelist_globbing_get_sfs and unit tests. |
546 | 429 | assert include == 0 or include == 1 | 434 | assert include == 0 or include == 1 |
548 | 430 | if glob_str == "**": | 435 | assert isinstance(glob_str, unicode) |
549 | 436 | if glob_str == u"**": | ||
550 | 431 | sel_func = lambda path: include | 437 | sel_func = lambda path: include |
551 | 432 | else: | 438 | else: |
552 | 433 | sel_func = self.glob_get_normal_sf(glob_str, include) | 439 | sel_func = self.glob_get_normal_sf(glob_str, include) |
553 | 434 | 440 | ||
554 | 435 | sel_func.exclude = not include | 441 | sel_func.exclude = not include |
557 | 436 | sel_func.name = "Command-line %s glob: %s" % \ | 442 | sel_func.name = u"Command-line %s glob: %s" % \ |
558 | 437 | (include and "include" or "exclude", glob_str) | 443 | (include and u"include" or u"exclude", glob_str) |
559 | 438 | return sel_func | 444 | return sel_func |
560 | 439 | 445 | ||
561 | 440 | def present_get_sf(self, filename, include): | 446 | def present_get_sf(self, filename, include): |
562 | @@ -453,9 +459,8 @@ | |||
563 | 453 | # functions. Currently this will give an error for any | 459 | # functions. Currently this will give an error for any |
564 | 454 | # locked directory within the folder being backed up. | 460 | # locked directory within the folder being backed up. |
565 | 455 | log.Warn(_( | 461 | log.Warn(_( |
569 | 456 | "Error accessing possibly locked file %s") % util.ufn( | 462 | u"Error accessing possibly locked file %s") % path.uc_name, |
570 | 457 | path.name), | 463 | log.WarningCode.cannot_read, util.escape(path.uc_name)) |
568 | 458 | log.WarningCode.cannot_read, util.escape(path.name)) | ||
571 | 459 | if diffdir.stats: | 464 | if diffdir.stats: |
572 | 460 | diffdir.stats.Errors += 1 | 465 | diffdir.stats.Errors += 1 |
573 | 461 | elif path.append(filename).exists(): | 466 | elif path.append(filename).exists(): |
574 | @@ -470,8 +475,8 @@ | |||
575 | 470 | log.ErrorCode.not_implemented) | 475 | log.ErrorCode.not_implemented) |
576 | 471 | 476 | ||
577 | 472 | sel_func.exclude = not include | 477 | sel_func.exclude = not include |
580 | 473 | sel_func.name = "Command-line %s filename: %s" % \ | 478 | sel_func.name = u"Command-line %s filename: %s" % \ |
581 | 474 | (include and "include-if-present" or "exclude-if-present", filename) | 479 | (include and u"include-if-present" or u"exclude-if-present", filename) |
582 | 475 | return sel_func | 480 | return sel_func |
583 | 476 | 481 | ||
584 | 477 | def glob_get_normal_sf(self, glob_str, include): | 482 | def glob_get_normal_sf(self, glob_str, include): |
585 | @@ -489,8 +494,8 @@ | |||
586 | 489 | things similar to this. | 494 | things similar to this. |
587 | 490 | 495 | ||
588 | 491 | """ | 496 | """ |
591 | 492 | # Internal. Used by glob_get_sf and unit tests. | 497 | assert isinstance(glob_str, unicode), \ |
592 | 493 | 498 | u"The glob string " + glob_str.decode(sys.getfilesystemencoding(), "ignore") + u" is not unicode" | |
593 | 494 | ignore_case = False | 499 | ignore_case = False |
594 | 495 | 500 | ||
595 | 496 | if glob_str.lower().startswith("ignorecase:"): | 501 | if glob_str.lower().startswith("ignorecase:"): |
596 | 497 | 502 | ||
597 | === modified file 'duplicity/util.py' | |||
598 | --- duplicity/util.py 2017-11-23 13:02:23 +0000 | |||
599 | +++ duplicity/util.py 2017-12-01 23:01:42 +0000 | |||
600 | @@ -34,6 +34,37 @@ | |||
601 | 34 | import duplicity.globals as globals | 34 | import duplicity.globals as globals |
602 | 35 | import duplicity.log as log | 35 | import duplicity.log as log |
603 | 36 | 36 | ||
604 | 37 | try: | ||
605 | 38 | # For paths, just use path.name/uname rather than converting with these | ||
606 | 39 | from os import fsencode, fsdecode | ||
607 | 40 | except ImportError: | ||
608 | 41 | # Most likely Python version < 3.2, so define our own fsencode/fsdecode. | ||
609 | 42 | # These are functions that encode/decode unicode paths to filesystem encoding, | ||
610 | 43 | # but the cleverness is that they handle non-unicode characters on Linux | ||
611 | 44 | # There is a *partial* backport to Python2 available here: | ||
612 | 45 | # https://github.com/pjdelport/backports.os/blob/master/src/backports/os.py | ||
613 | 46 | # but if it cannot be trusted for full-circle translation, then we may as well | ||
614 | 47 | # just read and store the bytes version of the path as path.name before | ||
615 | 48 | # creating the unicode version (for path matching etc) and ensure that in | ||
616 | 49 | # real-world usage (as opposed to testing) we create the path objects from a | ||
617 | 50 | # bytes string. | ||
618 | 51 | # ToDo: Revisit this once we drop Python 2 support/the backport is complete | ||
619 | 52 | |||
620 | 53 | def fsencode(unicode_filename): | ||
621 | 54 | """Convert a unicode filename to a filename encoded in the system encoding""" | ||
622 | 55 | # For paths, just use path.name rather than converting with this | ||
623 | 56 | # If we are not doing any cleverness with non-unicode filename bytes, | ||
624 | 57 | # encoding to system encoding is good enough | ||
625 | 58 | return unicode_filename.encode(sys.getfilesystemencoding(), "replace") | ||
626 | 59 | |||
627 | 60 | def fsdecode(bytes_filename): | ||
628 | 61 | """Convert a filename encoded in the system encoding to unicode""" | ||
629 | 62 | # For paths, just use path.uname rather than converting with this | ||
630 | 63 | # If we are not doing any cleverness with non-unicode filename bytes, | ||
631 | 64 | # decoding using system encoding is good enough. Use "ignore" as | ||
632 | 65 | # Linux paths can contain non-Unicode characters | ||
633 | 66 | return bytes_filename.decode(globals.fsencoding, "ignore") | ||
634 | 67 | |||
635 | 37 | 68 | ||
636 | 38 | def exception_traceback(limit=50): | 69 | def exception_traceback(limit=50): |
637 | 39 | """ | 70 | """ |
638 | @@ -58,9 +89,9 @@ | |||
639 | 58 | 89 | ||
640 | 59 | 90 | ||
641 | 60 | def ufn(filename): | 91 | def ufn(filename): |
645 | 61 | "Convert a (bytes) filename to unicode for printing" | 92 | """Convert a (bytes) filename to unicode for printing""" |
646 | 62 | assert not isinstance(filename, unicode) | 93 | # Note: path.uc_name is preferable for paths |
647 | 63 | return filename.decode(globals.fsencoding, 'replace') | 94 | return filename.decode(globals.fsencoding, "replace") |
648 | 64 | 95 | ||
649 | 65 | 96 | ||
650 | 66 | def uindex(index): | 97 | def uindex(index): |
651 | 67 | 98 | ||
652 | === modified file 'requirements.txt' | |||
653 | --- requirements.txt 2017-05-20 15:07:38 +0000 | |||
654 | +++ requirements.txt 2017-12-01 23:01:42 +0000 | |||
655 | @@ -2,6 +2,7 @@ | |||
656 | 2 | coverage | 2 | coverage |
657 | 3 | dropbox==6.9.0 | 3 | dropbox==6.9.0 |
658 | 4 | fasteners | 4 | fasteners |
659 | 5 | future | ||
660 | 5 | paramiko | 6 | paramiko |
661 | 6 | pexpect | 7 | pexpect |
662 | 7 | pycodestyle | 8 | pycodestyle |
663 | 8 | 9 | ||
664 | === modified file 'setup.py' | |||
665 | --- setup.py 2017-07-11 14:55:38 +0000 | |||
666 | +++ setup.py 2017-12-01 23:01:42 +0000 | |||
667 | @@ -196,7 +196,7 @@ | |||
668 | 196 | ext_modules=ext_modules, | 196 | ext_modules=ext_modules, |
669 | 197 | scripts=['bin/rdiffdir', 'bin/duplicity'], | 197 | scripts=['bin/rdiffdir', 'bin/duplicity'], |
670 | 198 | data_files=data_files, | 198 | data_files=data_files, |
672 | 199 | install_requires=['fasteners'], | 199 | install_requires=['fasteners', 'future'], |
673 | 200 | tests_require=['fasteners', 'mock', 'pexpect'], | 200 | tests_require=['fasteners', 'mock', 'pexpect'], |
674 | 201 | test_suite='testing', | 201 | test_suite='testing', |
675 | 202 | cmdclass={'test': TestCommand, | 202 | cmdclass={'test': TestCommand, |
676 | 203 | 203 | ||
677 | === modified file 'testing/__init__.py' | |||
678 | --- testing/__init__.py 2017-07-11 14:55:38 +0000 | |||
679 | +++ testing/__init__.py 2017-12-01 23:01:42 +0000 | |||
680 | @@ -55,10 +55,12 @@ | |||
681 | 55 | 55 | ||
682 | 56 | class DuplicityTestCase(unittest.TestCase): | 56 | class DuplicityTestCase(unittest.TestCase): |
683 | 57 | 57 | ||
688 | 58 | sign_key = '839E6A2856538CCF' | 58 | sign_key = u'839E6A2856538CCF' |
689 | 59 | sign_passphrase = 'test' | 59 | sign_passphrase = u'test' |
690 | 60 | encrypt_key1 = '839E6A2856538CCF' | 60 | # ToDo: remove the below when gpg code (and test_gpg) is converted to unicode |
691 | 61 | encrypt_key2 = '453005CE9B736B2A' | 61 | sign_passphrase_bytes = b'test' |
692 | 62 | encrypt_key1 = u'839E6A2856538CCF' | ||
693 | 63 | encrypt_key2 = u'453005CE9B736B2A' | ||
694 | 62 | 64 | ||
695 | 63 | def setUp(self): | 65 | def setUp(self): |
696 | 64 | super(DuplicityTestCase, self).setUp() | 66 | super(DuplicityTestCase, self).setUp() |
697 | 65 | 67 | ||
698 | === modified file 'testing/functional/__init__.py' | |||
699 | --- testing/functional/__init__.py 2017-07-11 14:55:38 +0000 | |||
700 | +++ testing/functional/__init__.py 2017-12-01 23:01:42 +0000 | |||
701 | @@ -25,10 +25,11 @@ | |||
702 | 25 | import platform | 25 | import platform |
703 | 26 | import sys | 26 | import sys |
704 | 27 | import time | 27 | import time |
705 | 28 | import unittest | ||
706 | 29 | 28 | ||
707 | 30 | from duplicity import backend | 29 | from duplicity import backend |
708 | 30 | from duplicity import util | ||
709 | 31 | from .. import DuplicityTestCase | 31 | from .. import DuplicityTestCase |
710 | 32 | from pkg_resources import parse_version | ||
711 | 32 | 33 | ||
712 | 33 | 34 | ||
713 | 34 | class CmdError(Exception): | 35 | class CmdError(Exception): |
714 | @@ -64,7 +65,7 @@ | |||
715 | 64 | self.unpack_testfiles() | 65 | self.unpack_testfiles() |
716 | 65 | 66 | ||
717 | 66 | self.class_args = [] | 67 | self.class_args = [] |
719 | 67 | self.backend_url = "file://testfiles/output" | 68 | self.backend_url = u"file://testfiles/output" |
720 | 68 | self.last_backup = None | 69 | self.last_backup = None |
721 | 69 | self.set_environ('PASSPHRASE', self.sign_passphrase) | 70 | self.set_environ('PASSPHRASE', self.sign_passphrase) |
722 | 70 | self.set_environ("SIGN_PASSPHRASE", self.sign_passphrase) | 71 | self.set_environ("SIGN_PASSPHRASE", self.sign_passphrase) |
723 | @@ -84,30 +85,57 @@ | |||
724 | 84 | # We run under setsid and take input from /dev/null (below) because | 85 | # We run under setsid and take input from /dev/null (below) because |
725 | 85 | # this way we force a failure if duplicity tries to read from the | 86 | # this way we force a failure if duplicity tries to read from the |
726 | 86 | # console unexpectedly (like for gpg password or such). | 87 | # console unexpectedly (like for gpg password or such). |
729 | 87 | if platform.platform().startswith('Linux'): | 88 | |
730 | 88 | cmd_list = ['setsid'] | 89 | # Check all string inputs are unicode -- we will convert to system encoding before running the command |
731 | 90 | for item in options: | ||
732 | 91 | assert not isinstance(item, str), "item " + unicode(item) + " in options is not unicode" | ||
733 | 92 | |||
734 | 93 | for item in passphrase_input: | ||
735 | 94 | assert isinstance(item, unicode), "item " + unicode(item) + " in passphrase_input is not unicode" | ||
736 | 95 | |||
737 | 96 | if platform.platform().startswith(u'Linux'): | ||
738 | 97 | cmd_list = [u'setsid'] | ||
739 | 89 | if self._setsid_w: | 98 | if self._setsid_w: |
741 | 90 | cmd_list.extend(["-w"]) | 99 | cmd_list.extend([u"-w"]) |
742 | 91 | else: | 100 | else: |
743 | 92 | cmd_list = [] | 101 | cmd_list = [] |
745 | 93 | cmd_list.extend(["duplicity"]) | 102 | cmd_list.extend([u"duplicity"]) |
746 | 94 | cmd_list.extend(options) | 103 | cmd_list.extend(options) |
751 | 95 | cmd_list.extend(["-v0"]) | 104 | cmd_list.extend([u"-v0"]) |
752 | 96 | cmd_list.extend(["--no-print-statistics"]) | 105 | cmd_list.extend([u"--no-print-statistics"]) |
753 | 97 | cmd_list.extend(["--allow-source-mismatch"]) | 106 | cmd_list.extend([u"--allow-source-mismatch"]) |
754 | 98 | cmd_list.extend(["--archive-dir=testfiles/cache"]) | 107 | cmd_list.extend([u"--archive-dir=testfiles/cache"]) |
755 | 99 | if current_time: | 108 | if current_time: |
757 | 100 | cmd_list.extend(["--current-time", current_time]) | 109 | cmd_list.extend([u"--current-time", current_time]) |
758 | 101 | cmd_list.extend(self.class_args) | 110 | cmd_list.extend(self.class_args) |
759 | 102 | if fail: | 111 | if fail: |
762 | 103 | cmd_list.extend(["--fail", str(fail)]) | 112 | cmd_list.extend([u"--fail", unicode(fail)]) |
763 | 104 | cmdline = " ".join(map(lambda x: '"%s"' % x, cmd_list)) | 113 | cmdline = u" ".join(map(lambda x: u'"%s"' % x, cmd_list)) |
764 | 105 | 114 | ||
765 | 106 | if not passphrase_input: | 115 | if not passphrase_input: |
768 | 107 | cmdline += " < /dev/null" | 116 | cmdline += u" < /dev/null" |
769 | 108 | child = pexpect.spawn('/bin/sh', ['-c', cmdline], timeout=None) | 117 | |
770 | 118 | # The immediately following block is the nicer way to execute pexpect with | ||
771 | 119 | # unicode strings, but we need to have the pre-4.0 version for some time yet, | ||
772 | 120 | # so for now this is commented out so tests execute the same way on all systems. | ||
773 | 121 | |||
774 | 122 | # if parse_version(pexpect.__version__) >= parse_version("4.0"): | ||
775 | 123 | # # pexpect.spawn only supports unicode from version 4.0 | ||
776 | 124 | # # there was a separate pexpect.spawnu in 3.x, but it has an error on readline | ||
777 | 125 | # child = pexpect.spawn(u'/bin/sh', [u'-c', cmdline], timeout=None, encoding=sys.getfilesystemencoding()) | ||
778 | 126 | # | ||
779 | 127 | # for passphrase in passphrase_input: | ||
780 | 128 | # child.expect(u'passphrase.*:') | ||
781 | 129 | # child.sendline(passphrase) | ||
782 | 130 | # else: | ||
783 | 131 | |||
784 | 132 | # Manually encode to filesystem encoding and send to spawn as bytes | ||
785 | 133 | # ToDo: Remove this once we no longer have to support systems with pexpect < 4.0 | ||
786 | 134 | child = pexpect.spawn(b'/bin/sh', [b'-c', cmdline.encode(sys.getfilesystemencoding(), | ||
787 | 135 | 'replace')], timeout=None) | ||
788 | 136 | |||
789 | 109 | for passphrase in passphrase_input: | 137 | for passphrase in passphrase_input: |
791 | 110 | child.expect('passphrase.*:') | 138 | child.expect(b'passphrase.*:') |
792 | 111 | child.sendline(passphrase) | 139 | child.sendline(passphrase) |
793 | 112 | 140 | ||
794 | 113 | # if the command fails, we need to clear its output | 141 | # if the command fails, we need to clear its output |
795 | @@ -132,7 +160,7 @@ | |||
796 | 132 | 160 | ||
797 | 133 | def backup(self, type, input_dir, options=[], **kwargs): | 161 | def backup(self, type, input_dir, options=[], **kwargs): |
798 | 134 | """Run duplicity backup to default directory""" | 162 | """Run duplicity backup to default directory""" |
800 | 135 | options = [type, input_dir, self.backend_url, "--volsize", "1"] + options | 163 | options = [type, input_dir, self.backend_url, u"--volsize", u"1"] + options |
801 | 136 | before_files = self.get_backend_files() | 164 | before_files = self.get_backend_files() |
802 | 137 | 165 | ||
803 | 138 | # If a chain ends with time X and the next full chain begins at time X, | 166 | # If a chain ends with time X and the next full chain begins at time X, |
804 | @@ -149,27 +177,27 @@ | |||
805 | 149 | 177 | ||
806 | 150 | def restore(self, file_to_restore=None, time=None, options=[], **kwargs): | 178 | def restore(self, file_to_restore=None, time=None, options=[], **kwargs): |
807 | 151 | assert not os.system("rm -rf testfiles/restore_out") | 179 | assert not os.system("rm -rf testfiles/restore_out") |
809 | 152 | options = [self.backend_url, "testfiles/restore_out"] + options | 180 | options = [self.backend_url, u"testfiles/restore_out"] + options |
810 | 153 | if file_to_restore: | 181 | if file_to_restore: |
812 | 154 | options.extend(['--file-to-restore', file_to_restore]) | 182 | options.extend([u'--file-to-restore', file_to_restore]) |
813 | 155 | if time: | 183 | if time: |
815 | 156 | options.extend(['--restore-time', str(time)]) | 184 | options.extend([u'--restore-time', unicode(time)]) |
816 | 157 | self.run_duplicity(options=options, **kwargs) | 185 | self.run_duplicity(options=options, **kwargs) |
817 | 158 | 186 | ||
818 | 159 | def verify(self, dirname, file_to_verify=None, time=None, options=[], | 187 | def verify(self, dirname, file_to_verify=None, time=None, options=[], |
819 | 160 | **kwargs): | 188 | **kwargs): |
821 | 161 | options = ["verify", self.backend_url, dirname] + options | 189 | options = [u"verify", self.backend_url, dirname] + options |
822 | 162 | if file_to_verify: | 190 | if file_to_verify: |
824 | 163 | options.extend(['--file-to-restore', file_to_verify]) | 191 | options.extend([u'--file-to-restore', file_to_verify]) |
825 | 164 | if time: | 192 | if time: |
827 | 165 | options.extend(['--restore-time', str(time)]) | 193 | options.extend([u'--restore-time', unicode(time)]) |
828 | 166 | self.run_duplicity(options=options, **kwargs) | 194 | self.run_duplicity(options=options, **kwargs) |
829 | 167 | 195 | ||
830 | 168 | def cleanup(self, options=[]): | 196 | def cleanup(self, options=[]): |
831 | 169 | """ | 197 | """ |
832 | 170 | Run duplicity cleanup to default directory | 198 | Run duplicity cleanup to default directory |
833 | 171 | """ | 199 | """ |
835 | 172 | options = ["cleanup", self.backend_url, "--force"] + options | 200 | options = [u"cleanup", self.backend_url, u"--force"] + options |
836 | 173 | self.run_duplicity(options=options) | 201 | self.run_duplicity(options=options) |
837 | 174 | 202 | ||
838 | 175 | def get_backend_files(self): | 203 | def get_backend_files(self): |
839 | @@ -183,6 +211,6 @@ | |||
840 | 183 | Makes a number of large files in testfiles/largefiles that each are | 211 | Makes a number of large files in testfiles/largefiles that each are |
841 | 184 | the specified number of megabytes. | 212 | the specified number of megabytes. |
842 | 185 | """ | 213 | """ |
844 | 186 | assert not os.system("mkdir testfiles/largefiles") | 214 | assert not os.system(u"mkdir testfiles/largefiles") |
845 | 187 | for n in range(count): | 215 | for n in range(count): |
847 | 188 | assert not os.system("dd if=/dev/urandom of=testfiles/largefiles/file%d bs=1024 count=%d > /dev/null 2>&1" % (n + 1, size * 1024)) | 216 | assert not os.system(u"dd if=/dev/urandom of=testfiles/largefiles/file%d bs=1024 count=%d > /dev/null 2>&1" % (n + 1, size * 1024)) |
848 | 189 | 217 | ||
849 | === modified file 'testing/functional/test_badupload.py' | |||
850 | --- testing/functional/test_badupload.py 2014-12-27 15:16:06 +0000 | |||
851 | +++ testing/functional/test_badupload.py 2017-12-01 23:01:42 +0000 | |||
852 | @@ -34,7 +34,7 @@ | |||
853 | 34 | Test basic lost file | 34 | Test basic lost file |
854 | 35 | """ | 35 | """ |
855 | 36 | try: | 36 | try: |
857 | 37 | self.backup("full", "testfiles/dir1", options=["--skip-volume=1"]) | 37 | self.backup(u"full", u"testfiles/dir1", options=[u"--skip-volume=1"]) |
858 | 38 | self.fail() | 38 | self.fail() |
859 | 39 | except CmdError as e: | 39 | except CmdError as e: |
860 | 40 | self.assertEqual(e.exit_status, 44, str(e)) | 40 | self.assertEqual(e.exit_status, 44, str(e)) |
861 | 41 | 41 | ||
862 | === modified file 'testing/functional/test_cleanup.py' | |||
863 | --- testing/functional/test_cleanup.py 2014-04-20 05:58:47 +0000 | |||
864 | +++ testing/functional/test_cleanup.py 2017-12-01 23:01:42 +0000 | |||
865 | @@ -35,27 +35,27 @@ | |||
866 | 35 | after a failed backup. | 35 | after a failed backup. |
867 | 36 | """ | 36 | """ |
868 | 37 | self.make_largefiles() | 37 | self.make_largefiles() |
873 | 38 | good_files = self.backup("full", "testfiles/largefiles") | 38 | good_files = self.backup(u"full", u"testfiles/largefiles") |
874 | 39 | good_files |= self.backup("inc", "testfiles/largefiles") | 39 | good_files |= self.backup(u"inc", u"testfiles/largefiles") |
875 | 40 | good_files |= self.backup("inc", "testfiles/largefiles") | 40 | good_files |= self.backup(u"inc", u"testfiles/largefiles") |
876 | 41 | self.backup("full", "testfiles/largefiles", fail=1) | 41 | self.backup(u"full", u"testfiles/largefiles", fail=1) |
877 | 42 | bad_files = self.get_backend_files() | 42 | bad_files = self.get_backend_files() |
878 | 43 | bad_files -= good_files | 43 | bad_files -= good_files |
879 | 44 | self.assertNotEqual(bad_files, set()) | 44 | self.assertNotEqual(bad_files, set()) |
880 | 45 | # the cleanup should go OK | 45 | # the cleanup should go OK |
882 | 46 | self.run_duplicity(options=["cleanup", self.backend_url, "--force"]) | 46 | self.run_duplicity(options=[u"cleanup", self.backend_url, u"--force"]) |
883 | 47 | leftovers = self.get_backend_files() | 47 | leftovers = self.get_backend_files() |
884 | 48 | self.assertEqual(good_files, leftovers) | 48 | self.assertEqual(good_files, leftovers) |
887 | 49 | self.backup("inc", "testfiles/largefiles") | 49 | self.backup(u"inc", u"testfiles/largefiles") |
888 | 50 | self.verify("testfiles/largefiles") | 50 | self.verify(u"testfiles/largefiles") |
889 | 51 | 51 | ||
890 | 52 | def test_remove_all_but_n(self): | 52 | def test_remove_all_but_n(self): |
891 | 53 | """ | 53 | """ |
892 | 54 | Test that remove-all-but-n works in the simple case. | 54 | Test that remove-all-but-n works in the simple case. |
893 | 55 | """ | 55 | """ |
897 | 56 | full1_files = self.backup("full", "testfiles/empty_dir") | 56 | full1_files = self.backup(u"full", u"testfiles/empty_dir") |
898 | 57 | full2_files = self.backup("full", "testfiles/empty_dir") | 57 | full2_files = self.backup(u"full", u"testfiles/empty_dir") |
899 | 58 | self.run_duplicity(options=["remove-all-but-n", "1", self.backend_url, "--force"]) | 58 | self.run_duplicity(options=[u"remove-all-but-n", u"1", self.backend_url, u"--force"]) |
900 | 59 | leftovers = self.get_backend_files() | 59 | leftovers = self.get_backend_files() |
901 | 60 | self.assertEqual(full2_files, leftovers) | 60 | self.assertEqual(full2_files, leftovers) |
902 | 61 | 61 | ||
903 | @@ -63,10 +63,10 @@ | |||
904 | 63 | """ | 63 | """ |
905 | 64 | Test that remove-all-inc-of-but-n-full works in the simple case. | 64 | Test that remove-all-inc-of-but-n-full works in the simple case. |
906 | 65 | """ | 65 | """ |
911 | 66 | full1_files = self.backup("full", "testfiles/empty_dir") | 66 | full1_files = self.backup(u"full", u"testfiles/empty_dir") |
912 | 67 | inc1_files = self.backup("inc", "testfiles/empty_dir") | 67 | inc1_files = self.backup(u"inc", u"testfiles/empty_dir") |
913 | 68 | full2_files = self.backup("full", "testfiles/empty_dir") | 68 | full2_files = self.backup(u"full", u"testfiles/empty_dir") |
914 | 69 | self.run_duplicity(options=["remove-all-inc-of-but-n-full", "1", self.backend_url, "--force"]) | 69 | self.run_duplicity(options=[u"remove-all-inc-of-but-n-full", u"1", self.backend_url, u"--force"]) |
915 | 70 | leftovers = self.get_backend_files() | 70 | leftovers = self.get_backend_files() |
916 | 71 | self.assertEqual(full1_files | full2_files, leftovers) | 71 | self.assertEqual(full1_files | full2_files, leftovers) |
917 | 72 | 72 | ||
918 | 73 | 73 | ||
919 | === modified file 'testing/functional/test_final.py' | |||
920 | --- testing/functional/test_final.py 2017-04-22 19:30:28 +0000 | |||
921 | +++ testing/functional/test_final.py 2017-12-01 23:01:42 +0000 | |||
922 | @@ -36,11 +36,11 @@ | |||
923 | 36 | 36 | ||
924 | 37 | # Back up directories to local backend | 37 | # Back up directories to local backend |
925 | 38 | current_time = 100000 | 38 | current_time = 100000 |
927 | 39 | self.backup("full", dirlist[0], current_time=current_time, | 39 | self.backup(u"full", dirlist[0], current_time=current_time, |
928 | 40 | options=backup_options) | 40 | options=backup_options) |
929 | 41 | for new_dir in dirlist[1:]: | 41 | for new_dir in dirlist[1:]: |
930 | 42 | current_time += 100000 | 42 | current_time += 100000 |
932 | 43 | self.backup("inc", new_dir, current_time=current_time, | 43 | self.backup(u"inc", new_dir, current_time=current_time, |
933 | 44 | options=backup_options) | 44 | options=backup_options) |
934 | 45 | 45 | ||
935 | 46 | # Restore each and compare them | 46 | # Restore each and compare them |
936 | @@ -48,7 +48,7 @@ | |||
937 | 48 | dirname = dirlist[i] | 48 | dirname = dirlist[i] |
938 | 49 | current_time = 100000 * (i + 1) | 49 | current_time = 100000 * (i + 1) |
939 | 50 | self.restore(time=current_time, options=restore_options) | 50 | self.restore(time=current_time, options=restore_options) |
941 | 51 | self.check_same(dirname, "testfiles/restore_out") | 51 | self.check_same(dirname, u"testfiles/restore_out") |
942 | 52 | self.verify(dirname, | 52 | self.verify(dirname, |
943 | 53 | time=current_time, options=restore_options) | 53 | time=current_time, options=restore_options) |
944 | 54 | 54 | ||
945 | @@ -59,57 +59,57 @@ | |||
946 | 59 | 59 | ||
947 | 60 | def test_basic_cycle(self, backup_options=[], restore_options=[]): | 60 | def test_basic_cycle(self, backup_options=[], restore_options=[]): |
948 | 61 | """Run backup/restore test on basic directories""" | 61 | """Run backup/restore test on basic directories""" |
952 | 62 | self.runtest(["testfiles/dir1", | 62 | self.runtest([u"testfiles/dir1", |
953 | 63 | "testfiles/dir2", | 63 | u"testfiles/dir2", |
954 | 64 | "testfiles/dir3"], | 64 | u"testfiles/dir3"], |
955 | 65 | backup_options=backup_options, | 65 | backup_options=backup_options, |
956 | 66 | restore_options=restore_options) | 66 | restore_options=restore_options) |
957 | 67 | 67 | ||
958 | 68 | # Test restoring various sub files | 68 | # Test restoring various sub files |
963 | 69 | for filename, time, dir in [('symbolic_link', 99999, 'dir1'), | 69 | for filename, time, dir in [(u'symbolic_link', 99999, u'dir1'), |
964 | 70 | ('directory_to_file', 100100, 'dir1'), | 70 | (u'directory_to_file', 100100, u'dir1'), |
965 | 71 | ('directory_to_file', 200100, 'dir2'), | 71 | (u'directory_to_file', 200100, u'dir2'), |
966 | 72 | ('largefile', 300000, 'dir3')]: | 72 | (u'largefile', 300000, u'dir3')]: |
967 | 73 | self.restore(filename, time, options=restore_options) | 73 | self.restore(filename, time, options=restore_options) |
971 | 74 | self.check_same('testfiles/%s/%s' % (dir, filename), | 74 | self.check_same(u'testfiles/%s/%s' % (dir, filename), |
972 | 75 | 'testfiles/restore_out') | 75 | u'testfiles/restore_out') |
973 | 76 | self.verify('testfiles/%s/%s' % (dir, filename), | 76 | self.verify(u'testfiles/%s/%s' % (dir, filename), |
974 | 77 | file_to_verify=filename, time=time, | 77 | file_to_verify=filename, time=time, |
975 | 78 | options=restore_options) | 78 | options=restore_options) |
976 | 79 | 79 | ||
977 | 80 | def test_asym_cycle(self): | 80 | def test_asym_cycle(self): |
978 | 81 | """Like test_basic_cycle but use asymmetric encryption and signing""" | 81 | """Like test_basic_cycle but use asymmetric encryption and signing""" |
983 | 82 | backup_options = ["--encrypt-key", self.encrypt_key1, | 82 | backup_options = [u"--encrypt-key", self.encrypt_key1, |
984 | 83 | "--sign-key", self.sign_key] | 83 | u"--sign-key", self.sign_key] |
985 | 84 | restore_options = ["--encrypt-key", self.encrypt_key1, | 84 | restore_options = [u"--encrypt-key", self.encrypt_key1, |
986 | 85 | "--sign-key", self.sign_key] | 85 | u"--sign-key", self.sign_key] |
987 | 86 | self.test_basic_cycle(backup_options=backup_options, | 86 | self.test_basic_cycle(backup_options=backup_options, |
988 | 87 | restore_options=restore_options) | 87 | restore_options=restore_options) |
989 | 88 | 88 | ||
990 | 89 | def test_asym_with_hidden_recipient_cycle(self): | 89 | def test_asym_with_hidden_recipient_cycle(self): |
991 | 90 | """Like test_basic_cycle but use asymmetric encryption (hiding key id) and signing""" | 90 | """Like test_basic_cycle but use asymmetric encryption (hiding key id) and signing""" |
996 | 91 | backup_options = ["--hidden-encrypt-key", self.encrypt_key1, | 91 | backup_options = [u"--hidden-encrypt-key", self.encrypt_key1, |
997 | 92 | "--sign-key", self.sign_key] | 92 | u"--sign-key", self.sign_key] |
998 | 93 | restore_options = ["--hidden-encrypt-key", self.encrypt_key1, | 93 | restore_options = [u"--hidden-encrypt-key", self.encrypt_key1, |
999 | 94 | "--sign-key", self.sign_key] | 94 | u"--sign-key", self.sign_key] |
1000 | 95 | self.test_basic_cycle(backup_options=backup_options, | 95 | self.test_basic_cycle(backup_options=backup_options, |
1001 | 96 | restore_options=restore_options) | 96 | restore_options=restore_options) |
1002 | 97 | 97 | ||
1003 | 98 | def test_single_regfile(self): | 98 | def test_single_regfile(self): |
1004 | 99 | """Test backing and restoring up a single regular file""" | 99 | """Test backing and restoring up a single regular file""" |
1006 | 100 | self.runtest(["testfiles/various_file_types/regular_file"]) | 100 | self.runtest([u"testfiles/various_file_types/regular_file"]) |
1007 | 101 | 101 | ||
1008 | 102 | def test_empty_backup(self): | 102 | def test_empty_backup(self): |
1009 | 103 | """Make sure backup works when no files change""" | 103 | """Make sure backup works when no files change""" |
1012 | 104 | self.backup("full", "testfiles/empty_dir") | 104 | self.backup(u"full", u"testfiles/empty_dir") |
1013 | 105 | self.backup("inc", "testfiles/empty_dir") | 105 | self.backup(u"inc", u"testfiles/empty_dir") |
1014 | 106 | 106 | ||
1015 | 107 | def test_long_filenames(self): | 107 | def test_long_filenames(self): |
1016 | 108 | """Test backing up a directory with long filenames in it""" | 108 | """Test backing up a directory with long filenames in it""" |
1017 | 109 | # Note that some versions of ecryptfs (at least through Ubuntu 11.10) | 109 | # Note that some versions of ecryptfs (at least through Ubuntu 11.10) |
1018 | 110 | # have a bug where they treat the max path segment length as 143 | 110 | # have a bug where they treat the max path segment length as 143 |
1019 | 111 | # instead of 255. So make sure that these segments don't break that. | 111 | # instead of 255. So make sure that these segments don't break that. |
1021 | 112 | lf_dir = path.Path("testfiles/long_filenames") | 112 | lf_dir = path.Path(u"testfiles/long_filenames") |
1022 | 113 | if lf_dir.exists(): | 113 | if lf_dir.exists(): |
1023 | 114 | lf_dir.deltree() | 114 | lf_dir.deltree() |
1024 | 115 | lf_dir.mkdir() | 115 | lf_dir.mkdir() |
1025 | @@ -130,36 +130,36 @@ | |||
1026 | 130 | fp.write("hello" * 1000) | 130 | fp.write("hello" * 1000) |
1027 | 131 | assert not fp.close() | 131 | assert not fp.close() |
1028 | 132 | 132 | ||
1031 | 133 | self.runtest(["testfiles/empty_dir", lf_dir.name, | 133 | self.runtest([u"testfiles/empty_dir", lf_dir.uc_name, |
1032 | 134 | "testfiles/empty_dir", lf_dir.name]) | 134 | u"testfiles/empty_dir", lf_dir.uc_name]) |
1033 | 135 | 135 | ||
1034 | 136 | def test_empty_restore(self): | 136 | def test_empty_restore(self): |
1035 | 137 | """Make sure error raised when restore doesn't match anything""" | 137 | """Make sure error raised when restore doesn't match anything""" |
1040 | 138 | self.backup("full", "testfiles/dir1") | 138 | self.backup(u"full", u"testfiles/dir1") |
1041 | 139 | self.assertRaises(CmdError, self.restore, "this_file_does_not_exist") | 139 | self.assertRaises(CmdError, self.restore, u"this_file_does_not_exist") |
1042 | 140 | self.backup("inc", "testfiles/empty_dir") | 140 | self.backup(u"inc", u"testfiles/empty_dir") |
1043 | 141 | self.assertRaises(CmdError, self.restore, "this_file_does_not_exist") | 141 | self.assertRaises(CmdError, self.restore, u"this_file_does_not_exist") |
1044 | 142 | 142 | ||
1045 | 143 | def test_remove_older_than(self): | 143 | def test_remove_older_than(self): |
1046 | 144 | """Test removing old backup chains""" | 144 | """Test removing old backup chains""" |
1051 | 145 | first_chain = self.backup("full", "testfiles/dir1", current_time=10000) | 145 | first_chain = self.backup(u"full", u"testfiles/dir1", current_time=10000) |
1052 | 146 | first_chain |= self.backup("inc", "testfiles/dir2", current_time=20000) | 146 | first_chain |= self.backup(u"inc", u"testfiles/dir2", current_time=20000) |
1053 | 147 | second_chain = self.backup("full", "testfiles/dir1", current_time=30000) | 147 | second_chain = self.backup(u"full", u"testfiles/dir1", current_time=30000) |
1054 | 148 | second_chain |= self.backup("inc", "testfiles/dir3", current_time=40000) | 148 | second_chain |= self.backup(u"inc", u"testfiles/dir3", current_time=40000) |
1055 | 149 | 149 | ||
1056 | 150 | self.assertEqual(self.get_backend_files(), first_chain | second_chain) | 150 | self.assertEqual(self.get_backend_files(), first_chain | second_chain) |
1057 | 151 | 151 | ||
1059 | 152 | self.run_duplicity(options=["remove-older-than", "35000", "--force", self.backend_url]) | 152 | self.run_duplicity(options=[u"remove-older-than", u"35000", u"--force", self.backend_url]) |
1060 | 153 | self.assertEqual(self.get_backend_files(), second_chain) | 153 | self.assertEqual(self.get_backend_files(), second_chain) |
1061 | 154 | 154 | ||
1062 | 155 | # Now check to make sure we can't delete only chain | 155 | # Now check to make sure we can't delete only chain |
1064 | 156 | self.run_duplicity(options=["remove-older-than", "50000", "--force", self.backend_url]) | 156 | self.run_duplicity(options=[u"remove-older-than", u"50000", u"--force", self.backend_url]) |
1065 | 157 | self.assertEqual(self.get_backend_files(), second_chain) | 157 | self.assertEqual(self.get_backend_files(), second_chain) |
1066 | 158 | 158 | ||
1067 | 159 | def test_piped_password(self): | 159 | def test_piped_password(self): |
1068 | 160 | """Make sure that prompting for a password works""" | 160 | """Make sure that prompting for a password works""" |
1071 | 161 | self.set_environ("PASSPHRASE", None) | 161 | self.set_environ(u"PASSPHRASE", None) |
1072 | 162 | self.backup("full", "testfiles/empty_dir", | 162 | self.backup(u"full", u"testfiles/empty_dir", |
1073 | 163 | passphrase_input=[self.sign_passphrase, self.sign_passphrase]) | 163 | passphrase_input=[self.sign_passphrase, self.sign_passphrase]) |
1074 | 164 | self.restore(passphrase_input=[self.sign_passphrase]) | 164 | self.restore(passphrase_input=[self.sign_passphrase]) |
1075 | 165 | 165 | ||
1076 | @@ -168,14 +168,14 @@ | |||
1077 | 168 | 168 | ||
1078 | 169 | def setUp(self): | 169 | def setUp(self): |
1079 | 170 | super(OldFilenamesFinalTest, self).setUp() | 170 | super(OldFilenamesFinalTest, self).setUp() |
1081 | 171 | self.class_args.extend(["--old-filenames"]) | 171 | self.class_args.extend([u"--old-filenames"]) |
1082 | 172 | 172 | ||
1083 | 173 | 173 | ||
1084 | 174 | class ShortFilenamesFinalTest(FinalTest): | 174 | class ShortFilenamesFinalTest(FinalTest): |
1085 | 175 | 175 | ||
1086 | 176 | def setUp(self): | 176 | def setUp(self): |
1087 | 177 | super(ShortFilenamesFinalTest, self).setUp() | 177 | super(ShortFilenamesFinalTest, self).setUp() |
1089 | 178 | self.class_args.extend(["--short-filenames"]) | 178 | self.class_args.extend([u"--short-filenames"]) |
1090 | 179 | 179 | ||
1091 | 180 | if __name__ == "__main__": | 180 | if __name__ == "__main__": |
1092 | 181 | unittest.main() | 181 | unittest.main() |
1093 | 182 | 182 | ||
1094 | === modified file 'testing/functional/test_replicate.py' | |||
1095 | --- testing/functional/test_replicate.py 2017-06-20 15:20:35 +0000 | |||
1096 | +++ testing/functional/test_replicate.py 2017-12-01 23:01:42 +0000 | |||
1097 | @@ -34,17 +34,17 @@ | |||
1098 | 34 | def runtest(self, dirlist, backup_options=[], replicate_options=[], restore_options=[]): | 34 | def runtest(self, dirlist, backup_options=[], replicate_options=[], restore_options=[]): |
1099 | 35 | # Back up directories to local backend | 35 | # Back up directories to local backend |
1100 | 36 | current_time = 100000 | 36 | current_time = 100000 |
1102 | 37 | self.backup("full", dirlist[0], current_time=current_time, | 37 | self.backup(u"full", dirlist[0], current_time=current_time, |
1103 | 38 | options=backup_options) | 38 | options=backup_options) |
1104 | 39 | for new_dir in dirlist[1:]: | 39 | for new_dir in dirlist[1:]: |
1105 | 40 | current_time += 100000 | 40 | current_time += 100000 |
1107 | 41 | self.backup("inc", new_dir, current_time=current_time, | 41 | self.backup(u"inc", new_dir, current_time=current_time, |
1108 | 42 | options=backup_options) | 42 | options=backup_options) |
1109 | 43 | 43 | ||
1110 | 44 | # Replicate to other backend | 44 | # Replicate to other backend |
1111 | 45 | source_url = self.backend_url | 45 | source_url = self.backend_url |
1114 | 46 | target_url = "file://testfiles/replicate_out" | 46 | target_url = u"file://testfiles/replicate_out" |
1115 | 47 | self.run_duplicity(options=["replicate"] + | 47 | self.run_duplicity(options=[u"replicate"] + |
1116 | 48 | replicate_options + [source_url, target_url]) | 48 | replicate_options + [source_url, target_url]) |
1117 | 49 | 49 | ||
1118 | 50 | self.backend_url = target_url | 50 | self.backend_url = target_url |
1119 | @@ -54,7 +54,7 @@ | |||
1120 | 54 | dirname = dirlist[i] | 54 | dirname = dirlist[i] |
1121 | 55 | current_time = 100000 * (i + 1) | 55 | current_time = 100000 * (i + 1) |
1122 | 56 | self.restore(time=current_time, options=restore_options) | 56 | self.restore(time=current_time, options=restore_options) |
1124 | 57 | self.check_same(dirname, "testfiles/restore_out") | 57 | self.check_same(dirname, u"testfiles/restore_out") |
1125 | 58 | self.verify(dirname, | 58 | self.verify(dirname, |
1126 | 59 | time=current_time, options=restore_options) | 59 | time=current_time, options=restore_options) |
1127 | 60 | 60 | ||
1128 | @@ -65,15 +65,15 @@ | |||
1129 | 65 | 65 | ||
1130 | 66 | def test_replicate(self): | 66 | def test_replicate(self): |
1131 | 67 | """Test replication""" | 67 | """Test replication""" |
1133 | 68 | self.runtest(["testfiles/dir1", "testfiles/dir2"]) | 68 | self.runtest([u"testfiles/dir1", u"testfiles/dir2"]) |
1134 | 69 | 69 | ||
1135 | 70 | def test_replicate_noencryption(self): | 70 | def test_replicate_noencryption(self): |
1136 | 71 | """Test replication with decryption""" | 71 | """Test replication with decryption""" |
1139 | 72 | self.runtest(["testfiles/dir1", "testfiles/dir2"], | 72 | self.runtest([u"testfiles/dir1", u"testfiles/dir2"], |
1140 | 73 | replicate_options=["--no-encryption"]) | 73 | replicate_options=[u"--no-encryption"]) |
1141 | 74 | 74 | ||
1142 | 75 | def test_replicate_asym(self): | 75 | def test_replicate_asym(self): |
1143 | 76 | """Test replication with reencryption""" | 76 | """Test replication with reencryption""" |
1146 | 77 | asym_options = ["--encrypt-key", self.encrypt_key1] | 77 | asym_options = [u"--encrypt-key", self.encrypt_key1] |
1147 | 78 | self.runtest(["testfiles/dir1", "testfiles/dir2"], | 78 | self.runtest([u"testfiles/dir1", u"testfiles/dir2"], |
1148 | 79 | replicate_options=asym_options, restore_options=asym_options) | 79 | replicate_options=asym_options, restore_options=asym_options) |
1149 | 80 | 80 | ||
1150 | === modified file 'testing/functional/test_restart.py' | |||
1151 | --- testing/functional/test_restart.py 2017-07-11 14:55:38 +0000 | |||
1152 | +++ testing/functional/test_restart.py 2017-12-01 23:01:42 +0000 | |||
1153 | @@ -37,20 +37,20 @@ | |||
1154 | 37 | Test basic Checkpoint/Restart | 37 | Test basic Checkpoint/Restart |
1155 | 38 | """ | 38 | """ |
1156 | 39 | self.make_largefiles() | 39 | self.make_largefiles() |
1160 | 40 | self.backup("full", "testfiles/largefiles", fail=1) | 40 | self.backup(u"full", u"testfiles/largefiles", fail=1) |
1161 | 41 | self.backup("full", "testfiles/largefiles") | 41 | self.backup(u"full", u"testfiles/largefiles") |
1162 | 42 | self.verify("testfiles/largefiles") | 42 | self.verify(u"testfiles/largefiles") |
1163 | 43 | 43 | ||
1164 | 44 | def test_multiple_checkpoint_restart(self): | 44 | def test_multiple_checkpoint_restart(self): |
1165 | 45 | """ | 45 | """ |
1166 | 46 | Test multiple Checkpoint/Restart | 46 | Test multiple Checkpoint/Restart |
1167 | 47 | """ | 47 | """ |
1168 | 48 | self.make_largefiles() | 48 | self.make_largefiles() |
1174 | 49 | self.backup("full", "testfiles/largefiles", fail=1) | 49 | self.backup(u"full", u"testfiles/largefiles", fail=1) |
1175 | 50 | self.backup("full", "testfiles/largefiles", fail=2) | 50 | self.backup(u"full", u"testfiles/largefiles", fail=2) |
1176 | 51 | self.backup("full", "testfiles/largefiles", fail=3) | 51 | self.backup(u"full", u"testfiles/largefiles", fail=3) |
1177 | 52 | self.backup("full", "testfiles/largefiles") | 52 | self.backup(u"full", u"testfiles/largefiles") |
1178 | 53 | self.verify("testfiles/largefiles") | 53 | self.verify(u"testfiles/largefiles") |
1179 | 54 | 54 | ||
1180 | 55 | def test_first_volume_failure(self): | 55 | def test_first_volume_failure(self): |
1181 | 56 | """ | 56 | """ |
1182 | @@ -58,10 +58,10 @@ | |||
1183 | 58 | Caused when duplicity fails before the first transfer. | 58 | Caused when duplicity fails before the first transfer. |
1184 | 59 | """ | 59 | """ |
1185 | 60 | self.make_largefiles() | 60 | self.make_largefiles() |
1190 | 61 | self.backup("full", "testfiles/largefiles", fail=1) | 61 | self.backup(u"full", u"testfiles/largefiles", fail=1) |
1191 | 62 | assert not os.system("rm testfiles/output/duplicity-full*difftar*") | 62 | assert not os.system(u"rm testfiles/output/duplicity-full*difftar*") |
1192 | 63 | self.backup("full", "testfiles/largefiles") | 63 | self.backup(u"full", u"testfiles/largefiles") |
1193 | 64 | self.verify("testfiles/largefiles") | 64 | self.verify(u"testfiles/largefiles") |
1194 | 65 | 65 | ||
1195 | 66 | def test_multi_volume_failure(self): | 66 | def test_multi_volume_failure(self): |
1196 | 67 | """ | 67 | """ |
1197 | @@ -70,10 +70,10 @@ | |||
1198 | 70 | fails the last queued transfer(s). | 70 | fails the last queued transfer(s). |
1199 | 71 | """ | 71 | """ |
1200 | 72 | self.make_largefiles() | 72 | self.make_largefiles() |
1205 | 73 | self.backup("full", "testfiles/largefiles", fail=3) | 73 | self.backup(u"full", u"testfiles/largefiles", fail=3) |
1206 | 74 | assert not os.system("rm testfiles/output/duplicity-full*vol[23].difftar*") | 74 | assert not os.system(u"rm testfiles/output/duplicity-full*vol[23].difftar*") |
1207 | 75 | self.backup("full", "testfiles/largefiles") | 75 | self.backup(u"full", u"testfiles/largefiles") |
1208 | 76 | self.verify("testfiles/largefiles") | 76 | self.verify(u"testfiles/largefiles") |
1209 | 77 | 77 | ||
1210 | 78 | def test_restart_sign_and_encrypt(self): | 78 | def test_restart_sign_and_encrypt(self): |
1211 | 79 | """ | 79 | """ |
1212 | @@ -81,10 +81,10 @@ | |||
1213 | 81 | https://bugs.launchpad.net/duplicity/+bug/946988 | 81 | https://bugs.launchpad.net/duplicity/+bug/946988 |
1214 | 82 | """ | 82 | """ |
1215 | 83 | self.make_largefiles() | 83 | self.make_largefiles() |
1220 | 84 | enc_opts = ["--sign-key", self.sign_key, "--encrypt-key", self.sign_key] | 84 | enc_opts = [u"--sign-key", self.sign_key, u"--encrypt-key", self.sign_key] |
1221 | 85 | self.backup("full", "testfiles/largefiles", options=enc_opts, fail=2) | 85 | self.backup(u"full", u"testfiles/largefiles", options=enc_opts, fail=2) |
1222 | 86 | self.backup("full", "testfiles/largefiles", options=enc_opts) | 86 | self.backup(u"full", u"testfiles/largefiles", options=enc_opts) |
1223 | 87 | self.verify("testfiles/largefiles") | 87 | self.verify(u"testfiles/largefiles") |
1224 | 88 | 88 | ||
1225 | 89 | def test_restart_sign_and_hidden_encrypt(self): | 89 | def test_restart_sign_and_hidden_encrypt(self): |
1226 | 90 | """ | 90 | """ |
1227 | @@ -92,10 +92,10 @@ | |||
1228 | 92 | https://bugs.launchpad.net/duplicity/+bug/946988 | 92 | https://bugs.launchpad.net/duplicity/+bug/946988 |
1229 | 93 | """ | 93 | """ |
1230 | 94 | self.make_largefiles() | 94 | self.make_largefiles() |
1235 | 95 | enc_opts = ["--sign-key", self.sign_key, "--hidden-encrypt-key", self.sign_key] | 95 | enc_opts = [u"--sign-key", self.sign_key, u"--hidden-encrypt-key", self.sign_key] |
1236 | 96 | self.backup("full", "testfiles/largefiles", options=enc_opts, fail=2) | 96 | self.backup(u"full", u"testfiles/largefiles", options=enc_opts, fail=2) |
1237 | 97 | self.backup("full", "testfiles/largefiles", options=enc_opts) | 97 | self.backup(u"full", u"testfiles/largefiles", options=enc_opts) |
1238 | 98 | self.verify("testfiles/largefiles") | 98 | self.verify(u"testfiles/largefiles") |
1239 | 99 | 99 | ||
1240 | 100 | def test_last_file_missing_in_middle(self): | 100 | def test_last_file_missing_in_middle(self): |
1241 | 101 | """ | 101 | """ |
1242 | @@ -104,12 +104,12 @@ | |||
1243 | 104 | the file in the middle of the backup, with files following. | 104 | the file in the middle of the backup, with files following. |
1244 | 105 | """ | 105 | """ |
1245 | 106 | self.make_largefiles() | 106 | self.make_largefiles() |
1249 | 107 | self.backup("full", "testfiles/largefiles", fail=3) | 107 | self.backup(u"full", u"testfiles/largefiles", fail=3) |
1250 | 108 | assert not os.system("rm testfiles/largefiles/file2") | 108 | assert not os.system(u"rm testfiles/largefiles/file2") |
1251 | 109 | self.backup("full", "testfiles/largefiles") | 109 | self.backup(u"full", u"testfiles/largefiles") |
1252 | 110 | # TODO: we can't verify but we need to to check for other errors that might show up | 110 | # TODO: we can't verify but we need to to check for other errors that might show up |
1253 | 111 | # there should be 2 differences found, one missing file, one mtime change | 111 | # there should be 2 differences found, one missing file, one mtime change |
1255 | 112 | # self.verify("testfiles/largefiles") | 112 | # self.verify(u"testfiles/largefiles") |
1256 | 113 | 113 | ||
1257 | 114 | def test_last_file_missing_at_end(self): | 114 | def test_last_file_missing_at_end(self): |
1258 | 115 | """ | 115 | """ |
1259 | @@ -118,22 +118,22 @@ | |||
1260 | 118 | the file at the end of the backup, with no files following. | 118 | the file at the end of the backup, with no files following. |
1261 | 119 | """ | 119 | """ |
1262 | 120 | self.make_largefiles() | 120 | self.make_largefiles() |
1266 | 121 | self.backup("full", "testfiles/largefiles", fail=6) | 121 | self.backup(u"full", u"testfiles/largefiles", fail=6) |
1267 | 122 | assert not os.system("rm testfiles/largefiles/file3") | 122 | assert not os.system(u"rm testfiles/largefiles/file3") |
1268 | 123 | self.backup("full", "testfiles/largefiles") | 123 | self.backup(u"full", u"testfiles/largefiles") |
1269 | 124 | # TODO: we can't verify but we need to to check for other errors that might show up | 124 | # TODO: we can't verify but we need to to check for other errors that might show up |
1270 | 125 | # there should be 2 differences found, one missing file, one mtime change | 125 | # there should be 2 differences found, one missing file, one mtime change |
1272 | 126 | # self.verify("testfiles/largefiles") | 126 | # self.verify(u"testfiles/largefiles") |
1273 | 127 | 127 | ||
1274 | 128 | def test_restart_incremental(self): | 128 | def test_restart_incremental(self): |
1275 | 129 | """ | 129 | """ |
1276 | 130 | Test restarting an incremental backup | 130 | Test restarting an incremental backup |
1277 | 131 | """ | 131 | """ |
1278 | 132 | self.make_largefiles() | 132 | self.make_largefiles() |
1283 | 133 | self.backup("full", "testfiles/dir1") | 133 | self.backup(u"full", u"testfiles/dir1") |
1284 | 134 | self.backup("inc", "testfiles/largefiles", fail=2) | 134 | self.backup(u"inc", u"testfiles/largefiles", fail=2) |
1285 | 135 | self.backup("inc", "testfiles/largefiles") | 135 | self.backup(u"inc", u"testfiles/largefiles") |
1286 | 136 | self.verify("testfiles/largefiles") | 136 | self.verify(u"testfiles/largefiles") |
1287 | 137 | 137 | ||
1288 | 138 | def make_fake_second_volume(self, name): | 138 | def make_fake_second_volume(self, name): |
1289 | 139 | """ | 139 | """ |
1290 | @@ -175,16 +175,16 @@ | |||
1291 | 175 | If we restart right after a volume that ended with a small | 175 | If we restart right after a volume that ended with a small |
1292 | 176 | (one-block) file, make sure we restart in the right place. | 176 | (one-block) file, make sure we restart in the right place. |
1293 | 177 | """ | 177 | """ |
1295 | 178 | source = 'testfiles/largefiles' | 178 | source = u'testfiles/largefiles' |
1296 | 179 | assert not os.system("mkdir -p %s" % source) | 179 | assert not os.system("mkdir -p %s" % source) |
1297 | 180 | assert not os.system("echo hello > %s/file1" % source) | 180 | assert not os.system("echo hello > %s/file1" % source) |
1299 | 181 | self.backup("full", source, options=["--name=backup1"]) | 181 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1300 | 182 | # Fake an interruption | 182 | # Fake an interruption |
1302 | 183 | self.make_fake_second_volume("backup1") | 183 | self.make_fake_second_volume(u"backup1") |
1303 | 184 | # Add new file | 184 | # Add new file |
1304 | 185 | assert not os.system("cp %s/file1 %s/newfile" % (source, source)) | 185 | assert not os.system("cp %s/file1 %s/newfile" % (source, source)) |
1305 | 186 | # 'restart' the backup | 186 | # 'restart' the backup |
1307 | 187 | self.backup("full", source, options=["--name=backup1"]) | 187 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1308 | 188 | # Confirm we actually resumed the previous backup | 188 | # Confirm we actually resumed the previous backup |
1309 | 189 | self.assertEqual(len(os.listdir("testfiles/output")), 4) | 189 | self.assertEqual(len(os.listdir("testfiles/output")), 4) |
1310 | 190 | # Now make sure everything is byte-for-byte the same once restored | 190 | # Now make sure everything is byte-for-byte the same once restored |
1311 | @@ -196,15 +196,15 @@ | |||
1312 | 196 | If we restart right after a volume that ended with a large | 196 | If we restart right after a volume that ended with a large |
1313 | 197 | (multi-block) file, make sure we restart in the right place. | 197 | (multi-block) file, make sure we restart in the right place. |
1314 | 198 | """ | 198 | """ |
1316 | 199 | source = 'testfiles/largefiles' | 199 | source = u'testfiles/largefiles' |
1317 | 200 | self.make_largefiles(count=1, size=1) | 200 | self.make_largefiles(count=1, size=1) |
1319 | 201 | self.backup("full", source, options=["--volsize=5", "--name=backup1"]) | 201 | self.backup(u"full", source, options=[u"--volsize=5", u"--name=backup1"]) |
1320 | 202 | # Fake an interruption | 202 | # Fake an interruption |
1322 | 203 | self.make_fake_second_volume("backup1") | 203 | self.make_fake_second_volume(u"backup1") |
1323 | 204 | # Add new file | 204 | # Add new file |
1324 | 205 | assert not os.system("cp %s/file1 %s/newfile" % (source, source)) | 205 | assert not os.system("cp %s/file1 %s/newfile" % (source, source)) |
1325 | 206 | # 'restart' the backup | 206 | # 'restart' the backup |
1327 | 207 | self.backup("full", source, options=["--volsize=5", "--name=backup1"]) | 207 | self.backup(u"full", source, options=[u"--volsize=5", u"--name=backup1"]) |
1328 | 208 | # Confirm we actually resumed the previous backup | 208 | # Confirm we actually resumed the previous backup |
1329 | 209 | self.assertEqual(len(os.listdir("testfiles/output")), 4) | 209 | self.assertEqual(len(os.listdir("testfiles/output")), 4) |
1330 | 210 | # Now make sure everything is byte-for-byte the same once restored | 210 | # Now make sure everything is byte-for-byte the same once restored |
1331 | @@ -216,13 +216,13 @@ | |||
1332 | 216 | If we restart right after a volume that ended inside of a large | 216 | If we restart right after a volume that ended inside of a large |
1333 | 217 | (multi-block) file, make sure we restart in the right place. | 217 | (multi-block) file, make sure we restart in the right place. |
1334 | 218 | """ | 218 | """ |
1336 | 219 | source = 'testfiles/largefiles' | 219 | source = u'testfiles/largefiles' |
1337 | 220 | self.make_largefiles(count=1, size=3) | 220 | self.make_largefiles(count=1, size=3) |
1339 | 221 | self.backup("full", source, options=["--name=backup1"]) | 221 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1340 | 222 | # Fake an interruption | 222 | # Fake an interruption |
1342 | 223 | self.make_fake_second_volume("backup1") | 223 | self.make_fake_second_volume(u"backup1") |
1343 | 224 | # 'restart' the backup | 224 | # 'restart' the backup |
1345 | 225 | self.backup("full", source, options=["--name=backup1"]) | 225 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1346 | 226 | # Now make sure everything is byte-for-byte the same once restored | 226 | # Now make sure everything is byte-for-byte the same once restored |
1347 | 227 | self.restore() | 227 | self.restore() |
1348 | 228 | assert not os.system("diff -r %s testfiles/restore_out" % source) | 228 | assert not os.system("diff -r %s testfiles/restore_out" % source) |
1349 | @@ -234,16 +234,16 @@ | |||
1350 | 234 | (Expected result is to ignore new, ealier files, but pick up later | 234 | (Expected result is to ignore new, ealier files, but pick up later |
1351 | 235 | ones.) | 235 | ones.) |
1352 | 236 | """ | 236 | """ |
1354 | 237 | source = 'testfiles/largefiles' | 237 | source = u'testfiles/largefiles' |
1355 | 238 | self.make_largefiles(count=1, size=1) | 238 | self.make_largefiles(count=1, size=1) |
1357 | 239 | self.backup("full", source, options=["--name=backup1"]) | 239 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1358 | 240 | # Fake an interruption | 240 | # Fake an interruption |
1360 | 241 | self.make_fake_second_volume("backup1") | 241 | self.make_fake_second_volume(u"backup1") |
1361 | 242 | # Add new files, earlier and later in filename sort order | 242 | # Add new files, earlier and later in filename sort order |
1362 | 243 | assert not os.system("echo hello > %s/a" % source) | 243 | assert not os.system("echo hello > %s/a" % source) |
1363 | 244 | assert not os.system("echo hello > %s/z" % source) | 244 | assert not os.system("echo hello > %s/z" % source) |
1364 | 245 | # 'restart' the backup | 245 | # 'restart' the backup |
1366 | 246 | self.backup("full", source, options=["--name=backup1"]) | 246 | self.backup(u"full", source, options=[u"--name=backup1"]) |
1367 | 247 | # Now make sure everything is the same once restored, except 'a' | 247 | # Now make sure everything is the same once restored, except 'a' |
1368 | 248 | self.restore() | 248 | self.restore() |
1369 | 249 | assert not os.system("test ! -e testfiles/restore_out/a") | 249 | assert not os.system("test ! -e testfiles/restore_out/a") |
1370 | @@ -258,15 +258,15 @@ | |||
1371 | 258 | if the source data changes to be small enough to not create a vol3 on | 258 | if the source data changes to be small enough to not create a vol3 on |
1372 | 259 | restart. | 259 | restart. |
1373 | 260 | """ | 260 | """ |
1375 | 261 | source = 'testfiles/largefiles' | 261 | source = u'testfiles/largefiles' |
1376 | 262 | self.make_largefiles(count=5, size=1) | 262 | self.make_largefiles(count=5, size=1) |
1378 | 263 | self.backup("full", source, fail=3) | 263 | self.backup(u"full", source, fail=3) |
1379 | 264 | # now delete the last volume on remote end and some source files | 264 | # now delete the last volume on remote end and some source files |
1380 | 265 | assert not os.system("rm testfiles/output/duplicity-full*vol3.difftar*") | 265 | assert not os.system("rm testfiles/output/duplicity-full*vol3.difftar*") |
1381 | 266 | assert not os.system("rm %s/file[2345]" % source) | 266 | assert not os.system("rm %s/file[2345]" % source) |
1382 | 267 | assert not os.system("echo hello > %s/z" % source) | 267 | assert not os.system("echo hello > %s/z" % source) |
1383 | 268 | # finish backup | 268 | # finish backup |
1385 | 269 | self.backup("full", source) | 269 | self.backup(u"full", source) |
1386 | 270 | # and verify we can restore | 270 | # and verify we can restore |
1387 | 271 | self.restore() | 271 | self.restore() |
1388 | 272 | 272 | ||
1389 | @@ -277,14 +277,14 @@ | |||
1390 | 277 | possible that the first chunk of the next file will be skipped unless | 277 | possible that the first chunk of the next file will be skipped unless |
1391 | 278 | we're careful. | 278 | we're careful. |
1392 | 279 | """ | 279 | """ |
1394 | 280 | source = 'testfiles/largefiles' | 280 | source = u'testfiles/largefiles' |
1395 | 281 | self.make_largefiles(count=1) | 281 | self.make_largefiles(count=1) |
1397 | 282 | self.backup("full", source, fail=2) | 282 | self.backup(u"full", source, fail=2) |
1398 | 283 | # now remove starting source data and make sure we add something after | 283 | # now remove starting source data and make sure we add something after |
1399 | 284 | assert not os.system("rm %s/*" % source) | 284 | assert not os.system("rm %s/*" % source) |
1400 | 285 | assert not os.system("echo hello > %s/z" % source) | 285 | assert not os.system("echo hello > %s/z" % source) |
1401 | 286 | # finish backup | 286 | # finish backup |
1403 | 287 | self.backup("full", source) | 287 | self.backup(u"full", source) |
1404 | 288 | # and verify we can restore | 288 | # and verify we can restore |
1405 | 289 | self.restore() | 289 | self.restore() |
1406 | 290 | assert not os.system("diff %s/z testfiles/restore_out/z" % source) | 290 | assert not os.system("diff %s/z testfiles/restore_out/z" % source) |
1407 | @@ -295,7 +295,7 @@ | |||
1408 | 295 | 295 | ||
1409 | 296 | def setUp(self): | 296 | def setUp(self): |
1410 | 297 | super(RestartTestWithoutEncryption, self).setUp() | 297 | super(RestartTestWithoutEncryption, self).setUp() |
1412 | 298 | self.class_args.extend(["--no-encryption"]) | 298 | self.class_args.extend([u"--no-encryption"]) |
1413 | 299 | 299 | ||
1414 | 300 | def test_no_write_double_snapshot(self): | 300 | def test_no_write_double_snapshot(self): |
1415 | 301 | """ | 301 | """ |
1416 | @@ -305,8 +305,8 @@ | |||
1417 | 305 | https://launchpad.net/bugs/929067 | 305 | https://launchpad.net/bugs/929067 |
1418 | 306 | """ | 306 | """ |
1419 | 307 | self.make_largefiles() | 307 | self.make_largefiles() |
1422 | 308 | self.backup("full", "testfiles/largefiles", fail=2) | 308 | self.backup(u"full", u"testfiles/largefiles", fail=2) |
1423 | 309 | self.backup("full", "testfiles/largefiles") | 309 | self.backup(u"full", u"testfiles/largefiles") |
1424 | 310 | # Now check sigtar | 310 | # Now check sigtar |
1425 | 311 | sigtars = glob.glob("testfiles/output/duplicity-full*.sigtar.gz") | 311 | sigtars = glob.glob("testfiles/output/duplicity-full*.sigtar.gz") |
1426 | 312 | self.assertEqual(1, len(sigtars)) | 312 | self.assertEqual(1, len(sigtars)) |
1427 | @@ -333,7 +333,7 @@ | |||
1428 | 333 | raise Exception("Platform %s not supported by tar/gtar." % platform.platform()) | 333 | raise Exception("Platform %s not supported by tar/gtar." % platform.platform()) |
1429 | 334 | 334 | ||
1430 | 335 | # Intial normal backup | 335 | # Intial normal backup |
1432 | 336 | self.backup("full", "testfiles/blocktartest") | 336 | self.backup(u"full", u"testfiles/blocktartest") |
1433 | 337 | # Create an exact clone of the snapshot folder in the sigtar already. | 337 | # Create an exact clone of the snapshot folder in the sigtar already. |
1434 | 338 | # Permissions and mtime must match. | 338 | # Permissions and mtime must match. |
1435 | 339 | os.mkdir("testfiles/snapshot", 0o755) | 339 | os.mkdir("testfiles/snapshot", 0o755) |
1436 | @@ -353,7 +353,7 @@ | |||
1437 | 353 | self.assertEqual(0, os.system("rm -r testfiles/cache")) | 353 | self.assertEqual(0, os.system("rm -r testfiles/cache")) |
1438 | 354 | # Try a follow on incremental (which in buggy versions, would create | 354 | # Try a follow on incremental (which in buggy versions, would create |
1439 | 355 | # a deleted entry for the base dir) | 355 | # a deleted entry for the base dir) |
1441 | 356 | self.backup("inc", "testfiles/blocktartest") | 356 | self.backup(u"inc", u"testfiles/blocktartest") |
1442 | 357 | self.assertEqual(1, len(glob.glob("testfiles/output/duplicity-new*.sigtar.gz"))) | 357 | self.assertEqual(1, len(glob.glob("testfiles/output/duplicity-new*.sigtar.gz"))) |
1443 | 358 | # Confirm we can restore it (which in buggy versions, would fail) | 358 | # Confirm we can restore it (which in buggy versions, would fail) |
1444 | 359 | self.restore() | 359 | self.restore() |
1445 | 360 | 360 | ||
1446 | === modified file 'testing/functional/test_selection.py' | |||
1447 | --- testing/functional/test_selection.py 2017-07-11 14:55:38 +0000 | |||
1448 | +++ testing/functional/test_selection.py 2017-12-01 23:01:42 +0000 | |||
1449 | @@ -1,3 +1,4 @@ | |||
1450 | 1 | # -*- coding: utf-8 -*- | ||
1451 | 1 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | 2 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
1452 | 2 | # | 3 | # |
1453 | 3 | # Copyright 2014 Aaron Whitehouse <aaron@whitehouse.kiwi.nz> | 4 | # Copyright 2014 Aaron Whitehouse <aaron@whitehouse.kiwi.nz> |
1454 | @@ -21,6 +22,7 @@ | |||
1455 | 21 | import os | 22 | import os |
1456 | 22 | import sys | 23 | import sys |
1457 | 23 | import platform | 24 | import platform |
1458 | 25 | import io | ||
1459 | 24 | 26 | ||
1460 | 25 | import unittest | 27 | import unittest |
1461 | 26 | 28 | ||
1462 | @@ -91,57 +93,57 @@ | |||
1463 | 91 | # --------- trailing_space sub2_file.txt (ea) # Excluded until trailing_space test, when (is) | 93 | # --------- trailing_space sub2_file.txt (ea) # Excluded until trailing_space test, when (is) |
1464 | 92 | 94 | ||
1465 | 93 | complete_directory_tree = [ | 95 | complete_directory_tree = [ |
1486 | 94 | ['1', '2', '3', 'trailing_space ', '1.doc', '1.py'], | 96 | [u"1", u"2", u"3", u"trailing_space ", u"1.doc", u"1.py"], |
1487 | 95 | ['1sub1', '1sub2', '1sub3'], | 97 | [u"1sub1", u"1sub2", u"1sub3"], |
1488 | 96 | ['1sub1sub1', '1sub1sub2', '1sub1sub3'], | 98 | [u"1sub1sub1", u"1sub1sub2", u"1sub1sub3"], |
1489 | 97 | ['1sub1sub1_file.txt'], | 99 | [u"1sub1sub1_file.txt"], |
1490 | 98 | ['1sub1sub2_file.txt'], | 100 | [u"1sub1sub2_file.txt"], |
1491 | 99 | ['1sub1sub3_file.txt'], | 101 | [u"1sub1sub3_file.txt"], |
1492 | 100 | ['1sub2sub1', '1sub2sub2', '1sub2sub3'], | 102 | [u"1sub2sub1", u"1sub2sub2", u"1sub2sub3"], |
1493 | 101 | ['1sub3sub1', '1sub3sub2', '1sub3sub3'], | 103 | [u"1sub3sub1", u"1sub3sub2", u"1sub3sub3"], |
1494 | 102 | ['2sub1', '2sub2', '2sub3'], | 104 | [u"2sub1", u"2sub2", u"2sub3"], |
1495 | 103 | ['2sub1sub1', '2sub1sub2', '2sub1sub3'], | 105 | [u"2sub1sub1", u"2sub1sub2", u"2sub1sub3"], |
1496 | 104 | ['2sub1sub1_file.txt'], | 106 | [u"2sub1sub1_file.txt"], |
1497 | 105 | ['2sub2sub1', '2sub2sub2', '2sub2sub3'], | 107 | [u"2sub2sub1", u"2sub2sub2", u"2sub2sub3"], |
1498 | 106 | ['2sub3sub1', '2sub3sub2', '2sub3sub3'], | 108 | [u"2sub3sub1", u"2sub3sub2", u"2sub3sub3"], |
1499 | 107 | ['3sub1', '3sub2', '3sub3'], | 109 | [u"3sub1", u"3sub2", u"3sub3"], |
1500 | 108 | ['3sub1sub1', '3sub1sub2', '3sub1sub3'], | 110 | [u"3sub1sub1", u"3sub1sub2", u"3sub1sub3"], |
1501 | 109 | ['3sub2sub1', '3sub2sub2', '3sub2sub3'], | 111 | [u"3sub2sub1", u"3sub2sub2", u"3sub2sub3"], |
1502 | 110 | ['3sub3sub1', '3sub3sub2', '3sub3sub3'], | 112 | [u"3sub3sub1", u"3sub3sub2", u"3sub3sub3"], |
1503 | 111 | ['3sub3sub2_file.txt'], | 113 | [u"3sub3sub2_file.txt"], |
1504 | 112 | ['trailing_space sub1', 'trailing_space sub2'], | 114 | [u"trailing_space sub1", u"trailing_space sub2"], |
1505 | 113 | ['trailing_space sub2_file.txt'] | 115 | [u"trailing_space sub2_file.txt"] |
1506 | 114 | ] | 116 | ] |
1507 | 115 | 117 | ||
1521 | 116 | expected_restored_tree = [['1', '2', '3', '1.py'], | 118 | expected_restored_tree = [[u"1", u"2", u"3", u"1.py"], |
1522 | 117 | ['1sub1', '1sub2', '1sub3'], | 119 | [u"1sub1", u"1sub2", u"1sub3"], |
1523 | 118 | ['1sub1sub1', '1sub1sub3'], | 120 | [u"1sub1sub1", u"1sub1sub3"], |
1524 | 119 | ['1sub1sub1_file.txt'], | 121 | [u"1sub1sub1_file.txt"], |
1525 | 120 | ['1sub2sub1'], | 122 | [u"1sub2sub1"], |
1526 | 121 | ['1sub3sub3'], | 123 | [u"1sub3sub3"], |
1527 | 122 | ['2sub1'], | 124 | [u"2sub1"], |
1528 | 123 | ['2sub1sub1'], | 125 | [u"2sub1sub1"], |
1529 | 124 | ['2sub1sub1_file.txt'], | 126 | [u"2sub1sub1_file.txt"], |
1530 | 125 | ['3sub2', '3sub3'], | 127 | [u"3sub2", u"3sub3"], |
1531 | 126 | ['3sub2sub1', '3sub2sub2', '3sub2sub3'], | 128 | [u"3sub2sub1", u"3sub2sub2", u"3sub2sub3"], |
1532 | 127 | ['3sub3sub1', '3sub3sub2', '3sub3sub3'], | 129 | [u"3sub3sub1", u"3sub3sub2", u"3sub3sub3"], |
1533 | 128 | ['3sub3sub2_file.txt']] | 130 | [u"3sub3sub2_file.txt"]] |
1534 | 129 | 131 | ||
1550 | 130 | expected_restored_tree_with_trailing_space = [['1', '2', '3', 'trailing_space ', '1.py'], | 132 | expected_restored_tree_with_trailing_space = [[u"1", u"2", u"3", u"trailing_space ", u"1.py"], |
1551 | 131 | ['1sub1', '1sub2', '1sub3'], | 133 | [u"1sub1", u"1sub2", u"1sub3"], |
1552 | 132 | ['1sub1sub1', '1sub1sub3'], | 134 | [u"1sub1sub1", u"1sub1sub3"], |
1553 | 133 | ['1sub1sub1_file.txt'], | 135 | [u"1sub1sub1_file.txt"], |
1554 | 134 | ['1sub2sub1'], | 136 | [u"1sub2sub1"], |
1555 | 135 | ['1sub3sub3'], | 137 | [u"1sub3sub3"], |
1556 | 136 | ['2sub1'], | 138 | [u"2sub1"], |
1557 | 137 | ['2sub1sub1'], | 139 | [u"2sub1sub1"], |
1558 | 138 | ['2sub1sub1_file.txt'], | 140 | [u"2sub1sub1_file.txt"], |
1559 | 139 | ['3sub2', '3sub3'], | 141 | [u"3sub2", u"3sub3"], |
1560 | 140 | ['3sub2sub1', '3sub2sub2', '3sub2sub3'], | 142 | [u"3sub2sub1", u"3sub2sub2", u"3sub2sub3"], |
1561 | 141 | ['3sub3sub1', '3sub3sub2', '3sub3sub3'], | 143 | [u"3sub3sub1", u"3sub3sub2", u"3sub3sub3"], |
1562 | 142 | ['3sub3sub2_file.txt'], | 144 | [u"3sub3sub2_file.txt"], |
1563 | 143 | ['trailing_space sub1', 'trailing_space sub2'], | 145 | [u"trailing_space sub1", u"trailing_space sub2"], |
1564 | 144 | ['trailing_space sub2_file.txt']] | 146 | [u"trailing_space sub2_file.txt"]] |
1565 | 145 | 147 | ||
1566 | 146 | def directory_tree_to_list_of_lists(self, parent_directory): | 148 | def directory_tree_to_list_of_lists(self, parent_directory): |
1567 | 147 | """ | 149 | """ |
1568 | @@ -167,7 +169,7 @@ | |||
1569 | 167 | 169 | ||
1570 | 168 | def test_files_are_as_expected(self): | 170 | def test_files_are_as_expected(self): |
1571 | 169 | """Test that the contents of testfiles/select are as expected.""" | 171 | """Test that the contents of testfiles/select are as expected.""" |
1573 | 170 | testfiles = self.directory_tree_to_list_of_lists('testfiles/select2') | 172 | testfiles = self.directory_tree_to_list_of_lists(u"testfiles/select2") |
1574 | 171 | # print(testfiles) | 173 | # print(testfiles) |
1575 | 172 | self.assertEqual(testfiles, self.complete_directory_tree) | 174 | self.assertEqual(testfiles, self.complete_directory_tree) |
1576 | 173 | 175 | ||
1577 | @@ -177,28 +179,28 @@ | |||
1578 | 177 | 179 | ||
1579 | 178 | def test_include_exclude_basic(self): | 180 | def test_include_exclude_basic(self): |
1580 | 179 | """ Test --include and --exclude work in the basic case """ | 181 | """ Test --include and --exclude work in the basic case """ |
1601 | 180 | self.backup("full", "testfiles/select2", | 182 | self.backup(u"full", u"testfiles/select2", |
1602 | 181 | options=["--include", "testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt", | 183 | options=[u"--include", u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt", |
1603 | 182 | "--exclude", "testfiles/select2/3/3sub3/3sub3sub2", | 184 | u"--exclude", u"testfiles/select2/3/3sub3/3sub3sub2", |
1604 | 183 | "--include", "testfiles/select2/3/3sub2/3sub2sub2", | 185 | u"--include", u"testfiles/select2/3/3sub2/3sub2sub2", |
1605 | 184 | "--include", "testfiles/select2/3/3sub3", | 186 | u"--include", u"testfiles/select2/3/3sub3", |
1606 | 185 | "--exclude", "testfiles/select2/3/3sub1", | 187 | u"--exclude", u"testfiles/select2/3/3sub1", |
1607 | 186 | "--exclude", "testfiles/select2/2/2sub1/2sub1sub3", | 188 | u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub3", |
1608 | 187 | "--exclude", "testfiles/select2/2/2sub1/2sub1sub2", | 189 | u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub2", |
1609 | 188 | "--include", "testfiles/select2/2/2sub1", | 190 | u"--include", u"testfiles/select2/2/2sub1", |
1610 | 189 | "--exclude", "testfiles/select2/1/1sub3/1sub3sub2", | 191 | u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub2", |
1611 | 190 | "--exclude", "testfiles/select2/1/1sub3/1sub3sub1", | 192 | u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub1", |
1612 | 191 | "--exclude", "testfiles/select2/1/1sub2/1sub2sub3", | 193 | u"--exclude", u"testfiles/select2/1/1sub2/1sub2sub3", |
1613 | 192 | "--include", "testfiles/select2/1/1sub2/1sub2sub1", | 194 | u"--include", u"testfiles/select2/1/1sub2/1sub2sub1", |
1614 | 193 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt", | 195 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt", |
1615 | 194 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub2", | 196 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2", |
1616 | 195 | "--exclude", "testfiles/select2/1/1sub2", | 197 | u"--exclude", u"testfiles/select2/1/1sub2", |
1617 | 196 | "--include", "testfiles/select2/1.py", | 198 | u"--include", u"testfiles/select2/1.py", |
1618 | 197 | "--include", "testfiles/select2/3", | 199 | u"--include", u"testfiles/select2/3", |
1619 | 198 | "--include", "testfiles/select2/1", | 200 | u"--include", u"testfiles/select2/1", |
1620 | 199 | "--exclude", "testfiles/select2/**"]) | 201 | u"--exclude", u"testfiles/select2/**"]) |
1621 | 200 | self.restore() | 202 | self.restore() |
1623 | 201 | restore_dir = 'testfiles/restore_out' | 203 | restore_dir = u"testfiles/restore_out" |
1624 | 202 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 204 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1625 | 203 | self.assertEqual(restored, self.expected_restored_tree) | 205 | self.assertEqual(restored, self.expected_restored_tree) |
1626 | 204 | 206 | ||
1627 | @@ -207,32 +209,32 @@ | |||
1628 | 207 | # Note that, because this only passes items in as a list of options, this test does not test whether duplicity | 209 | # Note that, because this only passes items in as a list of options, this test does not test whether duplicity |
1629 | 208 | # would correctly interpret commandline options with spaces. However, bin/duplicity uses sys.argv[1:], which | 210 | # would correctly interpret commandline options with spaces. However, bin/duplicity uses sys.argv[1:], which |
1630 | 209 | # should return a list of strings after having correctly processed quotes etc. | 211 | # should return a list of strings after having correctly processed quotes etc. |
1655 | 210 | self.backup("full", "testfiles/select2", | 212 | self.backup(u"full", u"testfiles/select2", |
1656 | 211 | options=["--include", | 213 | options=[u"--include", |
1657 | 212 | "testfiles/select2/trailing_space /trailing_space sub2/trailing_space sub2_file.txt", | 214 | u"testfiles/select2/trailing_space /trailing_space sub2/trailing_space sub2_file.txt", |
1658 | 213 | "--exclude", "testfiles/select2/trailing_space /trailing_space sub2", | 215 | u"--exclude", u"testfiles/select2/trailing_space /trailing_space sub2", |
1659 | 214 | "--include", "testfiles/select2/trailing_space ", | 216 | u"--include", u"testfiles/select2/trailing_space ", |
1660 | 215 | "--include", "testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt", | 217 | u"--include", u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt", |
1661 | 216 | "--exclude", "testfiles/select2/3/3sub3/3sub3sub2", | 218 | u"--exclude", u"testfiles/select2/3/3sub3/3sub3sub2", |
1662 | 217 | "--include", "testfiles/select2/3/3sub2/3sub2sub2", | 219 | u"--include", u"testfiles/select2/3/3sub2/3sub2sub2", |
1663 | 218 | "--include", "testfiles/select2/3/3sub3", | 220 | u"--include", u"testfiles/select2/3/3sub3", |
1664 | 219 | "--exclude", "testfiles/select2/3/3sub1", | 221 | u"--exclude", u"testfiles/select2/3/3sub1", |
1665 | 220 | "--exclude", "testfiles/select2/2/2sub1/2sub1sub3", | 222 | u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub3", |
1666 | 221 | "--exclude", "testfiles/select2/2/2sub1/2sub1sub2", | 223 | u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub2", |
1667 | 222 | "--include", "testfiles/select2/2/2sub1", | 224 | u"--include", u"testfiles/select2/2/2sub1", |
1668 | 223 | "--exclude", "testfiles/select2/1/1sub3/1sub3sub2", | 225 | u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub2", |
1669 | 224 | "--exclude", "testfiles/select2/1/1sub3/1sub3sub1", | 226 | u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub1", |
1670 | 225 | "--exclude", "testfiles/select2/1/1sub2/1sub2sub3", | 227 | u"--exclude", u"testfiles/select2/1/1sub2/1sub2sub3", |
1671 | 226 | "--include", "testfiles/select2/1/1sub2/1sub2sub1", | 228 | u"--include", u"testfiles/select2/1/1sub2/1sub2sub1", |
1672 | 227 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt", | 229 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt", |
1673 | 228 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub2", | 230 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2", |
1674 | 229 | "--exclude", "testfiles/select2/1/1sub2", | 231 | u"--exclude", u"testfiles/select2/1/1sub2", |
1675 | 230 | "--include", "testfiles/select2/1.py", | 232 | u"--include", u"testfiles/select2/1.py", |
1676 | 231 | "--include", "testfiles/select2/3", | 233 | u"--include", u"testfiles/select2/3", |
1677 | 232 | "--include", "testfiles/select2/1", | 234 | u"--include", u"testfiles/select2/1", |
1678 | 233 | "--exclude", "testfiles/select2/**"]) | 235 | u"--exclude", u"testfiles/select2/**"]) |
1679 | 234 | self.restore() | 236 | self.restore() |
1681 | 235 | restore_dir = 'testfiles/restore_out' | 237 | restore_dir = u"testfiles/restore_out" |
1682 | 236 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 238 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1683 | 237 | self.assertEqual(restored, self.expected_restored_tree_with_trailing_space) | 239 | self.assertEqual(restored, self.expected_restored_tree_with_trailing_space) |
1684 | 238 | 240 | ||
1685 | @@ -246,29 +248,29 @@ | |||
1686 | 246 | """Test that exclude filelist works in the basic case """ | 248 | """Test that exclude filelist works in the basic case """ |
1687 | 247 | # As this is an exclude filelist any lines with no +/- modifier should be treated as if they have a -. | 249 | # As this is an exclude filelist any lines with no +/- modifier should be treated as if they have a -. |
1688 | 248 | # Create a filelist | 250 | # Create a filelist |
1710 | 249 | with open('testfiles/exclude.txt', 'w') as f: | 251 | with io.open(u"testfiles/exclude.txt", u"w") as f: |
1711 | 250 | f.write('+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 252 | f.write(u"+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1712 | 251 | 'testfiles/select2/3/3sub3/3sub3sub2\n' | 253 | u"testfiles/select2/3/3sub3/3sub3sub2\n" |
1713 | 252 | '+ testfiles/select2/3/3sub2/3sub2sub2\n' | 254 | u"+ testfiles/select2/3/3sub2/3sub2sub2\n" |
1714 | 253 | '+ testfiles/select2/3/3sub3\n' | 255 | u"+ testfiles/select2/3/3sub3\n" |
1715 | 254 | '- testfiles/select2/3/3sub1\n' # - added to ensure it makes no difference | 256 | u"- testfiles/select2/3/3sub1\n" # - added to ensure it makes no difference |
1716 | 255 | 'testfiles/select2/2/2sub1/2sub1sub3\n' | 257 | u"testfiles/select2/2/2sub1/2sub1sub3\n" |
1717 | 256 | 'testfiles/select2/2/2sub1/2sub1sub2\n' | 258 | u"testfiles/select2/2/2sub1/2sub1sub2\n" |
1718 | 257 | '+ testfiles/select2/2/2sub1\n' | 259 | u"+ testfiles/select2/2/2sub1\n" |
1719 | 258 | 'testfiles/select2/1/1sub3/1sub3sub2\n' | 260 | u"testfiles/select2/1/1sub3/1sub3sub2\n" |
1720 | 259 | 'testfiles/select2/1/1sub3/1sub3sub1\n' | 261 | u"testfiles/select2/1/1sub3/1sub3sub1\n" |
1721 | 260 | 'testfiles/select2/1/1sub2/1sub2sub3\n' | 262 | u"testfiles/select2/1/1sub2/1sub2sub3\n" |
1722 | 261 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' | 263 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" |
1723 | 262 | 'testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 264 | u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
1724 | 263 | 'testfiles/select2/1/1sub1/1sub1sub2\n' | 265 | u"testfiles/select2/1/1sub1/1sub1sub2\n" |
1725 | 264 | '- testfiles/select2/1/1sub2\n' # - added to ensure it makes no difference | 266 | u"- testfiles/select2/1/1sub2\n" # - added to ensure it makes no difference |
1726 | 265 | '+ testfiles/select2/1.py\n' | 267 | u"+ testfiles/select2/1.py\n" |
1727 | 266 | '+ testfiles/select2/3\n' | 268 | u"+ testfiles/select2/3\n" |
1728 | 267 | '+ testfiles/select2/1\n' | 269 | u"+ testfiles/select2/1\n" |
1729 | 268 | 'testfiles/select2/**') | 270 | u"testfiles/select2/**") |
1730 | 269 | self.backup("full", "testfiles/select2", options=["--exclude-filelist=testfiles/exclude.txt"]) | 271 | self.backup(u"full", u"testfiles/select2", options=[u"--exclude-filelist=testfiles/exclude.txt"]) |
1731 | 270 | self.restore() | 272 | self.restore() |
1733 | 271 | restore_dir = 'testfiles/restore_out' | 273 | restore_dir = u"testfiles/restore_out" |
1734 | 272 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 274 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1735 | 273 | self.assertEqual(restored, self.expected_restored_tree) | 275 | self.assertEqual(restored, self.expected_restored_tree) |
1736 | 274 | 276 | ||
1737 | @@ -285,33 +287,33 @@ | |||
1738 | 285 | # * Unnecessarily quoted filenames with/without modifier (both " and ') | 287 | # * Unnecessarily quoted filenames with/without modifier (both " and ') |
1739 | 286 | 288 | ||
1740 | 287 | # Create a filelist | 289 | # Create a filelist |
1766 | 288 | with open('testfiles/exclude.txt', 'w') as f: | 290 | with io.open(u"testfiles/exclude.txt", u"w") as f: |
1767 | 289 | f.write('+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 291 | f.write(u"+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1768 | 290 | 'testfiles/select2/3/3sub3/3sub3sub2\n' | 292 | u"testfiles/select2/3/3sub3/3sub3sub2\n" |
1769 | 291 | '+ testfiles/select2/3/3sub2/3sub2sub2\n' | 293 | u"+ testfiles/select2/3/3sub2/3sub2sub2\n" |
1770 | 292 | ' + testfiles/select2/3/3sub3\n' # Note leading space added here | 294 | u" + testfiles/select2/3/3sub3\n" # Note leading space added here |
1771 | 293 | '- testfiles/select2/3/3sub1\n' | 295 | u"- testfiles/select2/3/3sub1\n" |
1772 | 294 | ' testfiles/select2/2/2sub1/2sub1sub3\n' # Note leading spaces added here | 296 | u" testfiles/select2/2/2sub1/2sub1sub3\n" # Note leading spaces added here |
1773 | 295 | '\n' | 297 | u"\n" |
1774 | 296 | 'testfiles/select2/2/2sub1/2sub1sub2\n' | 298 | u"testfiles/select2/2/2sub1/2sub1sub2\n" |
1775 | 297 | ' + testfiles/select2/2/2sub1 \n' # Note added trailing/leading space here | 299 | u" + testfiles/select2/2/2sub1 \n" # Note added trailing/leading space here |
1776 | 298 | '- "testfiles/select2/1/1sub3/1sub3sub2"\n' # Unnecessary quotes | 300 | u'- "testfiles/select2/1/1sub3/1sub3sub2"\n' # Unnecessary quotes |
1777 | 299 | '# Testing a full-line comment\n' | 301 | u"# Testing a full-line comment\n" |
1778 | 300 | "'testfiles/select2/1/1sub3/1sub3sub1' \n" # Note added spaces and quotes here | 302 | u"'testfiles/select2/1/1sub3/1sub3sub1' \n" # Note added spaces and quotes here |
1779 | 301 | 'testfiles/select2/1/1sub2/1sub2sub3\n' | 303 | u"testfiles/select2/1/1sub2/1sub2sub3\n" |
1780 | 302 | ' \n' | 304 | u" \n" |
1781 | 303 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' | 305 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" |
1782 | 304 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 306 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
1783 | 305 | 'testfiles/select2/1/1sub1/1sub1sub2\n' | 307 | u"testfiles/select2/1/1sub1/1sub1sub2\n" |
1784 | 306 | ' # Testing a full-line comment with leading and trailing spaces \n' | 308 | u" # Testing a full-line comment with leading and trailing spaces \n" |
1785 | 307 | 'testfiles/select2/1/1sub2 \n' # Note added spaces here | 309 | u"testfiles/select2/1/1sub2 \n" # Note added spaces here |
1786 | 308 | '+ testfiles/select2/1.py\n' | 310 | u"+ testfiles/select2/1.py\n" |
1787 | 309 | '+ testfiles/select2/3 \n' # Note added space here | 311 | u"+ testfiles/select2/3 \n" # Note added space here |
1788 | 310 | '+ testfiles/select2/1\n' | 312 | u"+ testfiles/select2/1\n" |
1789 | 311 | '- testfiles/select2/**') | 313 | u"- testfiles/select2/**") |
1790 | 312 | self.backup("full", "testfiles/select2", options=["--exclude-filelist=testfiles/exclude.txt"]) | 314 | self.backup(u"full", u"testfiles/select2", options=[u"--exclude-filelist=testfiles/exclude.txt"]) |
1791 | 313 | self.restore() | 315 | self.restore() |
1793 | 314 | restore_dir = 'testfiles/restore_out' | 316 | restore_dir = u"testfiles/restore_out" |
1794 | 315 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 317 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1795 | 316 | self.assertEqual(restored, self.expected_restored_tree) | 318 | self.assertEqual(restored, self.expected_restored_tree) |
1796 | 317 | 319 | ||
1797 | @@ -330,65 +332,65 @@ | |||
1798 | 330 | # * Unnecessarily quoted filenames with/without modifier (both " and ') | 332 | # * Unnecessarily quoted filenames with/without modifier (both " and ') |
1799 | 331 | 333 | ||
1800 | 332 | # Create a filelist | 334 | # Create a filelist |
1826 | 333 | with open('testfiles/exclude.txt', 'w') as f: | 335 | with io.open(u"testfiles/exclude.txt", u"w") as f: |
1827 | 334 | f.write('+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 336 | f.write(u"+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1828 | 335 | 'testfiles/select2/3/3sub3/3sub3sub2\n' | 337 | u"testfiles/select2/3/3sub3/3sub3sub2\n" |
1829 | 336 | '+ testfiles/select2/3/3sub2/3sub2sub2\n' | 338 | u"+ testfiles/select2/3/3sub2/3sub2sub2\n" |
1830 | 337 | ' + testfiles/select2/3/3sub3\n' # Note leading space added here | 339 | u" + testfiles/select2/3/3sub3\n" # Note leading space added here |
1831 | 338 | '- testfiles/select2/3/3sub1\n' | 340 | u"- testfiles/select2/3/3sub1\n" |
1832 | 339 | ' testfiles/select2/2/2sub1/2sub1sub3\n' # Note leading spaces added here | 341 | u" testfiles/select2/2/2sub1/2sub1sub3\n" # Note leading spaces added here |
1833 | 340 | '\n' | 342 | u"\n" |
1834 | 341 | 'testfiles/select2/2/2sub1/2sub1sub2\n' | 343 | u"testfiles/select2/2/2sub1/2sub1sub2\n" |
1835 | 342 | ' + testfiles/select2/2/2sub1 \n' # Note added trailing/leading space here | 344 | u" + testfiles/select2/2/2sub1 \n" # Note added trailing/leading space here |
1836 | 343 | '- "testfiles/select2/1/1sub3/1sub3sub2"\n' # Unnecessary quotes | 345 | u'- "testfiles/select2/1/1sub3/1sub3sub2"\n' # Unnecessary quotes |
1837 | 344 | '# Testing a full-line comment\n' | 346 | u"# Testing a full-line comment\n" |
1838 | 345 | "'testfiles/select2/1/1sub3/1sub3sub1' \n" # Note added spaces and quotes here | 347 | u"'testfiles/select2/1/1sub3/1sub3sub1' \n" # Note added spaces and quotes here |
1839 | 346 | 'testfiles/select2/1/1sub2/1sub2sub3\n' | 348 | u"testfiles/select2/1/1sub2/1sub2sub3\n" |
1840 | 347 | ' \n' | 349 | u" \n" |
1841 | 348 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' | 350 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" |
1842 | 349 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 351 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
1843 | 350 | 'testfiles/select2/1/1sub1/1sub1sub2\n' | 352 | u"testfiles/select2/1/1sub1/1sub1sub2\n" |
1844 | 351 | ' # Testing a full-line comment with leading and trailing spaces \n' | 353 | u" # Testing a full-line comment with leading and trailing spaces \n" |
1845 | 352 | 'testfiles/select2/1/1sub2 \n' # Note added spaces here | 354 | u"testfiles/select2/1/1sub2 \n" # Note added spaces here |
1846 | 353 | '+ testfiles/select2/1.py\n' | 355 | u"+ testfiles/select2/1.py\n" |
1847 | 354 | '+ testfiles/select2/3 \n' # Note added space here | 356 | u"+ testfiles/select2/3 \n" # Note added space here |
1848 | 355 | '+ testfiles/select2/1\n' | 357 | u"+ testfiles/select2/1\n" |
1849 | 356 | '- testfiles/select2/**') | 358 | u"- testfiles/select2/**") |
1850 | 357 | self.backup("full", "testfiles/select2", options=["--exclude-globbing-filelist=testfiles/exclude.txt"]) | 359 | self.backup(u"full", u"testfiles/select2", options=[u"--exclude-globbing-filelist=testfiles/exclude.txt"]) |
1851 | 358 | self.restore() | 360 | self.restore() |
1853 | 359 | restore_dir = 'testfiles/restore_out' | 361 | restore_dir = u"testfiles/restore_out" |
1854 | 360 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 362 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1855 | 361 | self.assertEqual(restored, self.expected_restored_tree) | 363 | self.assertEqual(restored, self.expected_restored_tree) |
1856 | 362 | 364 | ||
1857 | 363 | def test_exclude_filelist_trailing_whitespace_folders_work_with_quotes(self): | 365 | def test_exclude_filelist_trailing_whitespace_folders_work_with_quotes(self): |
1858 | 364 | """Test that folders with trailing whitespace in the names work correctly if they are enclosed in quotes""" | 366 | """Test that folders with trailing whitespace in the names work correctly if they are enclosed in quotes""" |
1859 | 365 | # Create a filelist | 367 | # Create a filelist |
1884 | 366 | with open('testfiles/exclude.txt', 'w') as f: | 368 | with io.open(u"testfiles/exclude.txt", u"w") as f: |
1885 | 367 | f.write('+ "testfiles/select2/trailing_space /trailing_space sub2/trailing_space sub2_file.txt"\n' # New | 369 | f.write(u'+ "testfiles/select2/trailing_space /trailing_space sub2/trailing_space sub2_file.txt"\n' # New |
1886 | 368 | '- "testfiles/select2/trailing_space /trailing_space sub2"\n' # New | 370 | u"- 'testfiles/select2/trailing_space /trailing_space sub2'\n" # New |
1887 | 369 | '+ "testfiles/select2/trailing_space "\n' # New | 371 | u'+ "testfiles/select2/trailing_space "\n' # New |
1888 | 370 | '+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 372 | u"+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1889 | 371 | 'testfiles/select2/3/3sub3/3sub3sub2\n' | 373 | u"testfiles/select2/3/3sub3/3sub3sub2\n" |
1890 | 372 | '+ testfiles/select2/3/3sub2/3sub2sub2\n' | 374 | u"+ testfiles/select2/3/3sub2/3sub2sub2\n" |
1891 | 373 | '+ testfiles/select2/3/3sub3\n' | 375 | u"+ testfiles/select2/3/3sub3\n" |
1892 | 374 | '- testfiles/select2/3/3sub1\n' | 376 | u"- testfiles/select2/3/3sub1\n" |
1893 | 375 | 'testfiles/select2/2/2sub1/2sub1sub3\n' | 377 | u"testfiles/select2/2/2sub1/2sub1sub3\n" |
1894 | 376 | 'testfiles/select2/2/2sub1/2sub1sub2\n' | 378 | u"testfiles/select2/2/2sub1/2sub1sub2\n" |
1895 | 377 | '+ testfiles/select2/2/2sub1\n' | 379 | u"+ testfiles/select2/2/2sub1\n" |
1896 | 378 | 'testfiles/select2/1/1sub3/1sub3sub2\n' | 380 | u"testfiles/select2/1/1sub3/1sub3sub2\n" |
1897 | 379 | 'testfiles/select2/1/1sub3/1sub3sub1\n' | 381 | u"testfiles/select2/1/1sub3/1sub3sub1\n" |
1898 | 380 | 'testfiles/select2/1/1sub2/1sub2sub3\n' | 382 | u"testfiles/select2/1/1sub2/1sub2sub3\n" |
1899 | 381 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' | 383 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" |
1900 | 382 | 'testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 384 | u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
1901 | 383 | 'testfiles/select2/1/1sub1/1sub1sub2\n' | 385 | u"testfiles/select2/1/1sub1/1sub1sub2\n" |
1902 | 384 | '- testfiles/select2/1/1sub2\n' | 386 | u"- testfiles/select2/1/1sub2\n" |
1903 | 385 | '+ testfiles/select2/1.py\n' | 387 | u"+ testfiles/select2/1.py\n" |
1904 | 386 | '+ testfiles/select2/3\n' | 388 | u"+ testfiles/select2/3\n" |
1905 | 387 | '+ testfiles/select2/1\n' | 389 | u"+ testfiles/select2/1\n" |
1906 | 388 | 'testfiles/select2/**') | 390 | u"testfiles/select2/**") |
1907 | 389 | self.backup("full", "testfiles/select2", options=["--exclude-filelist=testfiles/exclude.txt"]) | 391 | self.backup(u"full", u"testfiles/select2", options=[u"--exclude-filelist=testfiles/exclude.txt"]) |
1908 | 390 | self.restore() | 392 | self.restore() |
1910 | 391 | restore_dir = 'testfiles/restore_out' | 393 | restore_dir = u"testfiles/restore_out" |
1911 | 392 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 394 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1912 | 393 | self.assertEqual(restored, self.expected_restored_tree_with_trailing_space) | 395 | self.assertEqual(restored, self.expected_restored_tree_with_trailing_space) |
1913 | 394 | 396 | ||
1914 | @@ -396,32 +398,32 @@ | |||
1915 | 396 | """Test that exclude filelist is unaffected by the --progress option""" | 398 | """Test that exclude filelist is unaffected by the --progress option""" |
1916 | 397 | # Regression test for Bug #1264744 (https://bugs.launchpad.net/duplicity/+bug/1264744) | 399 | # Regression test for Bug #1264744 (https://bugs.launchpad.net/duplicity/+bug/1264744) |
1917 | 398 | # Create a filelist identical to that used in test_exclude_filelist | 400 | # Create a filelist identical to that used in test_exclude_filelist |
1938 | 399 | with open('testfiles/exclude.txt', 'w') as f: | 401 | with io.open(u"testfiles/exclude.txt", u"w") as f: |
1939 | 400 | f.write('+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 402 | f.write(u"+ testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1940 | 401 | 'testfiles/select2/3/3sub3/3sub3sub2\n' | 403 | u"testfiles/select2/3/3sub3/3sub3sub2\n" |
1941 | 402 | '+ testfiles/select2/3/3sub2/3sub2sub2\n' | 404 | u"+ testfiles/select2/3/3sub2/3sub2sub2\n" |
1942 | 403 | '+ testfiles/select2/3/3sub3\n' | 405 | u"+ testfiles/select2/3/3sub3\n" |
1943 | 404 | '- testfiles/select2/3/3sub1\n' # - added to ensure it makes no difference | 406 | u"- testfiles/select2/3/3sub1\n" # - added to ensure it makes no difference |
1944 | 405 | 'testfiles/select2/2/2sub1/2sub1sub3\n' | 407 | u"testfiles/select2/2/2sub1/2sub1sub3\n" |
1945 | 406 | 'testfiles/select2/2/2sub1/2sub1sub2\n' | 408 | u"testfiles/select2/2/2sub1/2sub1sub2\n" |
1946 | 407 | '+ testfiles/select2/2/2sub1\n' | 409 | u"+ testfiles/select2/2/2sub1\n" |
1947 | 408 | 'testfiles/select2/1/1sub3/1sub3sub2\n' | 410 | u"testfiles/select2/1/1sub3/1sub3sub2\n" |
1948 | 409 | 'testfiles/select2/1/1sub3/1sub3sub1\n' | 411 | u"testfiles/select2/1/1sub3/1sub3sub1\n" |
1949 | 410 | 'testfiles/select2/1/1sub2/1sub2sub3\n' | 412 | u"testfiles/select2/1/1sub2/1sub2sub3\n" |
1950 | 411 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' | 413 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" |
1951 | 412 | 'testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 414 | u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
1952 | 413 | 'testfiles/select2/1/1sub1/1sub1sub2\n' | 415 | u"testfiles/select2/1/1sub1/1sub1sub2\n" |
1953 | 414 | '- testfiles/select2/1/1sub2\n' # - added to ensure it makes no difference | 416 | u"- testfiles/select2/1/1sub2\n" # - added to ensure it makes no difference |
1954 | 415 | '+ testfiles/select2/1.py\n' | 417 | u"+ testfiles/select2/1.py\n" |
1955 | 416 | '+ testfiles/select2/3\n' | 418 | u"+ testfiles/select2/3\n" |
1956 | 417 | '+ testfiles/select2/1\n' | 419 | u"+ testfiles/select2/1\n" |
1957 | 418 | 'testfiles/select2/**') | 420 | u"testfiles/select2/**") |
1958 | 419 | 421 | ||
1959 | 420 | # Backup the files exactly as in test_exclude_filelist, but with the --progress option | 422 | # Backup the files exactly as in test_exclude_filelist, but with the --progress option |
1962 | 421 | self.backup("full", "testfiles/select2", options=["--exclude-filelist=testfiles/exclude.txt", | 423 | self.backup(u"full", u"testfiles/select2", options=[u"--exclude-filelist=testfiles/exclude.txt", |
1963 | 422 | "--progress"]) | 424 | u"--progress"]) |
1964 | 423 | self.restore() | 425 | self.restore() |
1966 | 424 | restore_dir = 'testfiles/restore_out' | 426 | restore_dir = u"testfiles/restore_out" |
1967 | 425 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 427 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
1968 | 426 | # The restored files should match those restored in test_exclude_filelist | 428 | # The restored files should match those restored in test_exclude_filelist |
1969 | 427 | self.assertEqual(restored, self.expected_restored_tree) | 429 | self.assertEqual(restored, self.expected_restored_tree) |
1970 | @@ -437,29 +439,29 @@ | |||
1971 | 437 | # See test_exclude_filelist above for explanation of what is expected. As this is an include filelist | 439 | # See test_exclude_filelist above for explanation of what is expected. As this is an include filelist |
1972 | 438 | # any lines with no +/- modifier should be treated as if they have a +. | 440 | # any lines with no +/- modifier should be treated as if they have a +. |
1973 | 439 | # Create a filelist | 441 | # Create a filelist |
1995 | 440 | with open('testfiles/include.txt', 'w') as f: | 442 | with io.open(u"testfiles/include.txt", u"w") as f: |
1996 | 441 | f.write('testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 443 | f.write(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
1997 | 442 | '- testfiles/select2/3/3sub3/3sub3sub2\n' | 444 | u"- testfiles/select2/3/3sub3/3sub3sub2\n" |
1998 | 443 | 'testfiles/select2/3/3sub2/3sub2sub2\n' | 445 | u"testfiles/select2/3/3sub2/3sub2sub2\n" |
1999 | 444 | '+ testfiles/select2/3/3sub3\n' # + added to ensure it makes no difference | 446 | u"+ testfiles/select2/3/3sub3\n" # + added to ensure it makes no difference |
2000 | 445 | '- testfiles/select2/3/3sub1\n' | 447 | u"- testfiles/select2/3/3sub1\n" |
2001 | 446 | '- testfiles/select2/2/2sub1/2sub1sub3\n' | 448 | u"- testfiles/select2/2/2sub1/2sub1sub3\n" |
2002 | 447 | '- testfiles/select2/2/2sub1/2sub1sub2\n' | 449 | u"- testfiles/select2/2/2sub1/2sub1sub2\n" |
2003 | 448 | 'testfiles/select2/2/2sub1\n' | 450 | u"testfiles/select2/2/2sub1\n" |
2004 | 449 | '- testfiles/select2/1/1sub3/1sub3sub2\n' | 451 | u"- testfiles/select2/1/1sub3/1sub3sub2\n" |
2005 | 450 | '- testfiles/select2/1/1sub3/1sub3sub1\n' | 452 | u"- testfiles/select2/1/1sub3/1sub3sub1\n" |
2006 | 451 | '- testfiles/select2/1/1sub2/1sub2sub3\n' | 453 | u"- testfiles/select2/1/1sub2/1sub2sub3\n" |
2007 | 452 | '+ testfiles/select2/1/1sub2/1sub2sub1\n' # + added to ensure it makes no difference | 454 | u"+ testfiles/select2/1/1sub2/1sub2sub1\n" # + added to ensure it makes no difference |
2008 | 453 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 455 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
2009 | 454 | '- testfiles/select2/1/1sub1/1sub1sub2\n' | 456 | u"- testfiles/select2/1/1sub1/1sub1sub2\n" |
2010 | 455 | '- testfiles/select2/1/1sub2\n' | 457 | u"- testfiles/select2/1/1sub2\n" |
2011 | 456 | 'testfiles/select2/1.py\n' | 458 | u"testfiles/select2/1.py\n" |
2012 | 457 | 'testfiles/select2/3\n' | 459 | u"testfiles/select2/3\n" |
2013 | 458 | 'testfiles/select2/1\n' | 460 | u"testfiles/select2/1\n" |
2014 | 459 | '- testfiles/select2/**') | 461 | u"- testfiles/select2/**") |
2015 | 460 | self.backup("full", "testfiles/select2", options=["--include-filelist=testfiles/include.txt"]) | 462 | self.backup(u"full", u"testfiles/select2", options=[u"--include-filelist=testfiles/include.txt"]) |
2016 | 461 | self.restore() | 463 | self.restore() |
2018 | 462 | restore_dir = 'testfiles/restore_out' | 464 | restore_dir = u"testfiles/restore_out" |
2019 | 463 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 465 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2020 | 464 | self.assertEqual(restored, self.expected_restored_tree) | 466 | self.assertEqual(restored, self.expected_restored_tree) |
2021 | 465 | 467 | ||
2022 | @@ -475,33 +477,33 @@ | |||
2023 | 475 | # * Full-line comments with # as the first character and with leading/trailing spaces | 477 | # * Full-line comments with # as the first character and with leading/trailing spaces |
2024 | 476 | # * Unnecessarily quoted filenames with/without modifier (both " and ') | 478 | # * Unnecessarily quoted filenames with/without modifier (both " and ') |
2025 | 477 | # Create a filelist | 479 | # Create a filelist |
2051 | 478 | with open('testfiles/include.txt', 'w') as f: | 480 | with io.open(u"testfiles/include.txt", u"w") as f: |
2052 | 479 | f.write('testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 481 | f.write(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
2053 | 480 | '- testfiles/select2/3/3sub3/3sub3sub2\n' | 482 | u"- testfiles/select2/3/3sub3/3sub3sub2\n" |
2054 | 481 | '"testfiles/select2/3/3sub2/3sub2sub2"\n' | 483 | u'"testfiles/select2/3/3sub2/3sub2sub2"\n' |
2055 | 482 | ' + testfiles/select2/3/3sub3\n' # + added to ensure it makes no difference | 484 | u" + testfiles/select2/3/3sub3\n" # + added to ensure it makes no difference |
2056 | 483 | '- testfiles/select2/3/3sub1\n' | 485 | u"- testfiles/select2/3/3sub1\n" |
2057 | 484 | '- testfiles/select2/2/2sub1/2sub1sub3\n' | 486 | u"- testfiles/select2/2/2sub1/2sub1sub3\n" |
2058 | 485 | ' - "testfiles/select2/2/2sub1/2sub1sub2"\n' | 487 | u' - "testfiles/select2/2/2sub1/2sub1sub2"\n' |
2059 | 486 | 'testfiles/select2/2/2sub1 \n' | 488 | u"testfiles/select2/2/2sub1 \n" |
2060 | 487 | '\n' | 489 | u"\n" |
2061 | 488 | '- testfiles/select2/1/1sub3/1sub3sub2\n' | 490 | u"- testfiles/select2/1/1sub3/1sub3sub2\n" |
2062 | 489 | '- testfiles/select2/1/1sub3/1sub3sub1 \n' | 491 | u"- testfiles/select2/1/1sub3/1sub3sub1 \n" |
2063 | 490 | "- 'testfiles/select2/1/1sub2/1sub2sub3'\n" | 492 | u"- 'testfiles/select2/1/1sub2/1sub2sub3'\n" |
2064 | 491 | ' \n' | 493 | u" \n" |
2065 | 492 | ' + testfiles/select2/1/1sub2/1sub2sub1 \n' # + added to ensure it makes no difference | 494 | u" + testfiles/select2/1/1sub2/1sub2sub1 \n" # + added to ensure it makes no difference |
2066 | 493 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 495 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
2067 | 494 | ' - testfiles/select2/1/1sub1/1sub1sub2 \n' | 496 | u" - testfiles/select2/1/1sub1/1sub1sub2 \n" |
2068 | 495 | '# Testing full-line comment\n' | 497 | u"# Testing full-line comment\n" |
2069 | 496 | '- testfiles/select2/1/1sub2\n' | 498 | u"- testfiles/select2/1/1sub2\n" |
2070 | 497 | "'testfiles/select2/1.py'\n" | 499 | u"'testfiles/select2/1.py'\n" |
2071 | 498 | 'testfiles/select2/3\n' | 500 | u"testfiles/select2/3\n" |
2072 | 499 | ' # Testing another full-line comment \n' | 501 | u" # Testing another full-line comment \n" |
2073 | 500 | 'testfiles/select2/1\n' | 502 | u"testfiles/select2/1\n" |
2074 | 501 | '- testfiles/select2/**') | 503 | u"- testfiles/select2/**") |
2075 | 502 | self.backup("full", "testfiles/select2", options=["--include-filelist=testfiles/include.txt"]) | 504 | self.backup(u"full", u"testfiles/select2", options=[u"--include-filelist=testfiles/include.txt"]) |
2076 | 503 | self.restore() | 505 | self.restore() |
2078 | 504 | restore_dir = 'testfiles/restore_out' | 506 | restore_dir = u"testfiles/restore_out" |
2079 | 505 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 507 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2080 | 506 | self.assertEqual(restored, self.expected_restored_tree) | 508 | self.assertEqual(restored, self.expected_restored_tree) |
2081 | 507 | 509 | ||
2082 | @@ -519,37 +521,37 @@ | |||
2083 | 519 | # * Full-line comments with # as the first character and with leading/trailing spaces | 521 | # * Full-line comments with # as the first character and with leading/trailing spaces |
2084 | 520 | # * Unnecessarily quoted filenames with/without modifier (both " and ') | 522 | # * Unnecessarily quoted filenames with/without modifier (both " and ') |
2085 | 521 | # Create a filelist | 523 | # Create a filelist |
2115 | 522 | with open('testfiles/include.txt', 'w') as f: | 524 | with io.open(u"testfiles/include.txt", u"w") as f: |
2116 | 523 | f.write('testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 525 | f.write(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
2117 | 524 | 'testfiles/select2/3/3sub2/3sub2sub2 \n' | 526 | u"testfiles/select2/3/3sub2/3sub2sub2 \n" |
2118 | 525 | ' + testfiles/select2/3/3sub3\n' # + added to ensure it makes no difference | 527 | u" + testfiles/select2/3/3sub3\n" # + added to ensure it makes no difference |
2119 | 526 | ' - testfiles/select2/3/3sub1 \n' | 528 | u" - testfiles/select2/3/3sub1 \n" |
2120 | 527 | '- testfiles/select2/2/2sub1/2sub1sub3\n' | 529 | u"- testfiles/select2/2/2sub1/2sub1sub3\n" |
2121 | 528 | '- testfiles/select2/2/2sub1/2sub1sub2\n' | 530 | u"- testfiles/select2/2/2sub1/2sub1sub2\n" |
2122 | 529 | '"testfiles/select2/2/2sub1"\n' | 531 | u'"testfiles/select2/2/2sub1"\n' |
2123 | 530 | ' - testfiles/select2/2/2sub3 \n' # Added because of Bug #1408411 | 532 | u" - testfiles/select2/2/2sub3 \n" # Added because of Bug #1408411 |
2124 | 531 | '- testfiles/select2/2/2sub2\n' # Added because of Bug #1408411 | 533 | u"- testfiles/select2/2/2sub2\n" # Added because of Bug #1408411 |
2125 | 532 | "- 'testfiles/select2/1/1sub3/1sub3sub2'\n" | 534 | u"- 'testfiles/select2/1/1sub3/1sub3sub2'\n" |
2126 | 533 | '\n' | 535 | u"\n" |
2127 | 534 | '- testfiles/select2/1/1sub3/1sub3sub1\n' | 536 | u"- testfiles/select2/1/1sub3/1sub3sub1\n" |
2128 | 535 | '- testfiles/select2/1/1sub2/1sub2sub3\n' | 537 | u"- testfiles/select2/1/1sub2/1sub2sub3\n" |
2129 | 536 | '- "testfiles/select2/1/1sub2/1sub2sub2"\n' # Added because of Bug #1408411 | 538 | u'- "testfiles/select2/1/1sub2/1sub2sub2"\n' # Added because of Bug #1408411 |
2130 | 537 | '# This is a full-line comment\n' | 539 | u"# This is a full-line comment\n" |
2131 | 538 | '+ testfiles/select2/1/1sub2/1sub2sub1 \n' # + added to ensure it makes no difference | 540 | u"+ testfiles/select2/1/1sub2/1sub2sub1 \n" # + added to ensure it makes no difference |
2132 | 539 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 541 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
2133 | 540 | ' \n' | 542 | u" \n" |
2134 | 541 | '- testfiles/select2/1/1sub1/1sub1sub2\n' | 543 | u"- testfiles/select2/1/1sub1/1sub1sub2\n" |
2135 | 542 | # '- testfiles/select2/1/1sub2\n' # Commented out because of Bug #1408411 | 544 | # u"- testfiles/select2/1/1sub2\n" # Commented out because of Bug #1408411 |
2136 | 543 | "'testfiles/select2/1.py'\n" | 545 | u"'testfiles/select2/1.py'\n" |
2137 | 544 | ' # This is another full-line comment, with spaces \n' | 546 | u" # This is another full-line comment, with spaces \n" |
2138 | 545 | 'testfiles/select2/3\n' | 547 | u"testfiles/select2/3\n" |
2139 | 546 | # '- testfiles/select2/2\n' # Commented out because of Bug #1408411 | 548 | # u"- testfiles/select2/2\n" # Commented out because of Bug #1408411 |
2140 | 547 | 'testfiles/select2/1\n' | 549 | u"testfiles/select2/1\n" |
2141 | 548 | '- "testfiles/select2/trailing_space "\n' # es instead of ea as no wildcard - ** | 550 | u'- "testfiles/select2/trailing_space "\n' # es instead of ea as no wildcard - ** |
2142 | 549 | '- testfiles/select2/1.doc') # es instead of ea as no wildcard - ** | 551 | u"- testfiles/select2/1.doc") # es instead of ea as no wildcard - ** |
2143 | 550 | self.backup("full", "testfiles/select2", options=["--include-filelist=testfiles/include.txt"]) | 552 | self.backup(u"full", u"testfiles/select2", options=[u"--include-filelist=testfiles/include.txt"]) |
2144 | 551 | self.restore() | 553 | self.restore() |
2146 | 552 | restore_dir = 'testfiles/restore_out' | 554 | restore_dir = u"testfiles/restore_out" |
2147 | 553 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 555 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2148 | 554 | self.assertEqual(restored, self.expected_restored_tree) | 556 | self.assertEqual(restored, self.expected_restored_tree) |
2149 | 555 | 557 | ||
2150 | @@ -567,33 +569,33 @@ | |||
2151 | 567 | # * Full-line comments with # as the first character and with leading/trailing spaces | 569 | # * Full-line comments with # as the first character and with leading/trailing spaces |
2152 | 568 | # * Unnecessarily quoted filenames with/without modifier (both " and ') | 570 | # * Unnecessarily quoted filenames with/without modifier (both " and ') |
2153 | 569 | # Create a filelist | 571 | # Create a filelist |
2179 | 570 | with open('testfiles/include.txt', 'w') as f: | 572 | with io.open(u"testfiles/include.txt", u"w") as f: |
2180 | 571 | f.write('testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n' | 573 | f.write(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt\n" |
2181 | 572 | '- testfiles/select2/3/3sub3/3sub3sub2\n' | 574 | u"- testfiles/select2/3/3sub3/3sub3sub2\n" |
2182 | 573 | '"testfiles/select2/3/3sub2/3sub2sub2"\n' | 575 | u'"testfiles/select2/3/3sub2/3sub2sub2"\n' |
2183 | 574 | ' + testfiles/select2/3/3sub3\n' # + added to ensure it makes no difference | 576 | u" + testfiles/select2/3/3sub3\n" # + added to ensure it makes no difference |
2184 | 575 | '- testfiles/select2/3/3sub1\n' | 577 | u"- testfiles/select2/3/3sub1\n" |
2185 | 576 | '- testfiles/select2/2/2sub1/2sub1sub3\n' | 578 | u"- testfiles/select2/2/2sub1/2sub1sub3\n" |
2186 | 577 | ' - "testfiles/select2/2/2sub1/2sub1sub2"\n' | 579 | u' - "testfiles/select2/2/2sub1/2sub1sub2"\n' |
2187 | 578 | 'testfiles/select2/2/2sub1 \n' | 580 | u"testfiles/select2/2/2sub1 \n" |
2188 | 579 | '\n' | 581 | u"\n" |
2189 | 580 | '- testfiles/select2/1/1sub3/1sub3sub2\n' | 582 | u"- testfiles/select2/1/1sub3/1sub3sub2\n" |
2190 | 581 | '- testfiles/select2/1/1sub3/1sub3sub1 \n' | 583 | u"- testfiles/select2/1/1sub3/1sub3sub1 \n" |
2191 | 582 | "- 'testfiles/select2/1/1sub2/1sub2sub3'\n" | 584 | u"- 'testfiles/select2/1/1sub2/1sub2sub3'\n" |
2192 | 583 | ' \n' | 585 | u" \n" |
2193 | 584 | ' + testfiles/select2/1/1sub2/1sub2sub1 \n' # + added to ensure it makes no difference | 586 | u" + testfiles/select2/1/1sub2/1sub2sub1 \n" # + added to ensure it makes no difference |
2194 | 585 | '- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n' | 587 | u"- testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt\n" |
2195 | 586 | ' - testfiles/select2/1/1sub1/1sub1sub2 \n' | 588 | u" - testfiles/select2/1/1sub1/1sub1sub2 \n" |
2196 | 587 | '# Testing full-line comment\n' | 589 | u"# Testing full-line comment\n" |
2197 | 588 | '- testfiles/select2/1/1sub2\n' | 590 | u"- testfiles/select2/1/1sub2\n" |
2198 | 589 | "'testfiles/select2/1.py'\n" | 591 | u"'testfiles/select2/1.py'\n" |
2199 | 590 | 'testfiles/select2/3\n' | 592 | u"testfiles/select2/3\n" |
2200 | 591 | ' # Testing another full-line comment \n' | 593 | u" # Testing another full-line comment \n" |
2201 | 592 | 'testfiles/select2/1\n' | 594 | u"testfiles/select2/1\n" |
2202 | 593 | '- testfiles/select2/**') | 595 | u"- testfiles/select2/**") |
2203 | 594 | self.backup("full", "testfiles/select2", options=["--include-globbing-filelist=testfiles/include.txt"]) | 596 | self.backup(u"full", u"testfiles/select2", options=[u"--include-globbing-filelist=testfiles/include.txt"]) |
2204 | 595 | self.restore() | 597 | self.restore() |
2206 | 596 | restore_dir = 'testfiles/restore_out' | 598 | restore_dir = u"testfiles/restore_out" |
2207 | 597 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 599 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2208 | 598 | self.assertEqual(restored, self.expected_restored_tree) | 600 | self.assertEqual(restored, self.expected_restored_tree) |
2209 | 599 | 601 | ||
2210 | @@ -605,54 +607,54 @@ | |||
2211 | 605 | def write_filelist(self, filelist_name): | 607 | def write_filelist(self, filelist_name): |
2212 | 606 | """Used by the below tests to write the filelist""" | 608 | """Used by the below tests to write the filelist""" |
2213 | 607 | assert filelist_name is not None | 609 | assert filelist_name is not None |
2219 | 608 | with open(filelist_name, 'w') as f: | 610 | with io.open(filelist_name, u"w") as f: |
2220 | 609 | f.write("+ testfiles/select/1/2/1\n" | 611 | f.write(u"+ testfiles/select/1/2/1\n" |
2221 | 610 | "- testfiles/select/1/2\n" | 612 | u"- testfiles/select/1/2\n" |
2222 | 611 | "- testfiles/select/1/1\n" | 613 | u"- testfiles/select/1/1\n" |
2223 | 612 | "- testfiles/select/1/3") | 614 | u"- testfiles/select/1/3") |
2224 | 613 | 615 | ||
2225 | 614 | def restore_and_check(self): | 616 | def restore_and_check(self): |
2226 | 615 | """Restores the backup and compares to what was expected (based on the filelist in write_filelist)""" | 617 | """Restores the backup and compares to what was expected (based on the filelist in write_filelist)""" |
2227 | 616 | self.restore() | 618 | self.restore() |
2229 | 617 | restore_dir = 'testfiles/restore_out' | 619 | restore_dir = u"testfiles/restore_out" |
2230 | 618 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 620 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2232 | 619 | self.assertEqual(restored, [['2'], ['1']]) | 621 | self.assertEqual(restored, [[u"2"], [u"1"]]) |
2233 | 620 | 622 | ||
2234 | 621 | def test_commandline_include_exclude(self): | 623 | def test_commandline_include_exclude(self): |
2235 | 622 | """test an excluded folder is included for included contents when using commandline includes and excludes""" | 624 | """test an excluded folder is included for included contents when using commandline includes and excludes""" |
2241 | 623 | self.backup("full", "testfiles/select/1", | 625 | self.backup(u"full", u"testfiles/select/1", |
2242 | 624 | options=["--include", "testfiles/select/1/2/1", | 626 | options=[u"--include", u"testfiles/select/1/2/1", |
2243 | 625 | "--exclude", "testfiles/select/1/2", | 627 | u"--exclude", u"testfiles/select/1/2", |
2244 | 626 | "--exclude", "testfiles/select/1/1", | 628 | u"--exclude", u"testfiles/select/1/1", |
2245 | 627 | "--exclude", "testfiles/select/1/3"]) | 629 | u"--exclude", u"testfiles/select/1/3"]) |
2246 | 628 | self.restore_and_check() | 630 | self.restore_and_check() |
2247 | 629 | 631 | ||
2248 | 630 | def test_include_globbing_filelist(self): | 632 | def test_include_globbing_filelist(self): |
2249 | 631 | """test an excluded folder is included for included contents with an include-globbing-filelist """ | 633 | """test an excluded folder is included for included contents with an include-globbing-filelist """ |
2250 | 632 | # Deprecated, but include for now to ensure it keeps working until it is deliberately removed. | 634 | # Deprecated, but include for now to ensure it keeps working until it is deliberately removed. |
2253 | 633 | self.write_filelist("testfiles/include.txt") | 635 | self.write_filelist(u"testfiles/include.txt") |
2254 | 634 | self.backup("full", "testfiles/select/1", options=["--include-globbing-filelist=testfiles/include.txt"]) | 636 | self.backup(u"full", u"testfiles/select/1", options=[u"--include-globbing-filelist=testfiles/include.txt"]) |
2255 | 635 | self.restore_and_check() | 637 | self.restore_and_check() |
2256 | 636 | 638 | ||
2257 | 637 | def test_exclude_globbing_filelist(self): | 639 | def test_exclude_globbing_filelist(self): |
2258 | 638 | """test an excluded folder is included for included contents with an exclude-globbing-filelist """ | 640 | """test an excluded folder is included for included contents with an exclude-globbing-filelist """ |
2259 | 639 | # Deprecated, but include for now to ensure it keeps working until it is deliberately removed. | 641 | # Deprecated, but include for now to ensure it keeps working until it is deliberately removed. |
2262 | 640 | self.write_filelist("testfiles/exclude.txt") | 642 | self.write_filelist(u"testfiles/exclude.txt") |
2263 | 641 | self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/exclude.txt"]) | 643 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-globbing-filelist=testfiles/exclude.txt"]) |
2264 | 642 | self.restore_and_check() | 644 | self.restore_and_check() |
2265 | 643 | 645 | ||
2266 | 644 | def test_include_filelist(self): | 646 | def test_include_filelist(self): |
2267 | 645 | """test an excluded folder is included for included contents with an include-filelist (non-globbing) """ | 647 | """test an excluded folder is included for included contents with an include-filelist (non-globbing) """ |
2268 | 646 | # Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411) | 648 | # Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411) |
2271 | 647 | self.write_filelist("testfiles/include.txt") | 649 | self.write_filelist(u"testfiles/include.txt") |
2272 | 648 | self.backup("full", "testfiles/select/1", options=["--include-filelist=testfiles/include.txt"]) | 650 | self.backup(u"full", u"testfiles/select/1", options=[u"--include-filelist=testfiles/include.txt"]) |
2273 | 649 | self.restore_and_check() | 651 | self.restore_and_check() |
2274 | 650 | 652 | ||
2275 | 651 | def test_exclude_filelist(self): | 653 | def test_exclude_filelist(self): |
2276 | 652 | """test an excluded folder is included for included contents with an exclude-filelist (non-globbing) """ | 654 | """test an excluded folder is included for included contents with an exclude-filelist (non-globbing) """ |
2277 | 653 | # Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411) | 655 | # Regression test for Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411) |
2280 | 654 | self.write_filelist("testfiles/exclude.txt") | 656 | self.write_filelist(u"testfiles/exclude.txt") |
2281 | 655 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/exclude.txt"]) | 657 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/exclude.txt"]) |
2282 | 656 | self.restore_and_check() | 658 | self.restore_and_check() |
2283 | 657 | 659 | ||
2284 | 658 | 660 | ||
2285 | @@ -664,112 +666,112 @@ | |||
2286 | 664 | def restore_and_check(self): | 666 | def restore_and_check(self): |
2287 | 665 | """Restores the backup and compares to what is expected.""" | 667 | """Restores the backup and compares to what is expected.""" |
2288 | 666 | self.restore() | 668 | self.restore() |
2290 | 667 | restore_dir = 'testfiles/restore_out' | 669 | restore_dir = u"testfiles/restore_out" |
2291 | 668 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 670 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2293 | 669 | self.assertEqual(restored, [['2'], ['1']]) | 671 | self.assertEqual(restored, [[u"2"], [u"1"]]) |
2294 | 670 | 672 | ||
2295 | 671 | def test_exclude_filelist_asterisks_none(self): | 673 | def test_exclude_filelist_asterisks_none(self): |
2296 | 672 | """Basic exclude filelist.""" | 674 | """Basic exclude filelist.""" |
2303 | 673 | with open("testfiles/filelist.txt", 'w') as f: | 675 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2304 | 674 | f.write("+ testfiles/select/1/2/1\n" | 676 | f.write(u"+ testfiles/select/1/2/1\n" |
2305 | 675 | "- testfiles/select/1/2\n" | 677 | u"- testfiles/select/1/2\n" |
2306 | 676 | "- testfiles/select/1/1\n" | 678 | u"- testfiles/select/1/1\n" |
2307 | 677 | "- testfiles/select/1/3") | 679 | u"- testfiles/select/1/3") |
2308 | 678 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 680 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2309 | 679 | self.restore_and_check() | 681 | self.restore_and_check() |
2310 | 680 | 682 | ||
2311 | 681 | def test_exclude_filelist_asterisks_single(self): | 683 | def test_exclude_filelist_asterisks_single(self): |
2312 | 682 | """Exclude filelist with asterisks replacing folders.""" | 684 | """Exclude filelist with asterisks replacing folders.""" |
2313 | 683 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 685 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
2320 | 684 | with open("testfiles/filelist.txt", 'w') as f: | 686 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2321 | 685 | f.write("+ */select/1/2/1\n" | 687 | f.write(u"+ */select/1/2/1\n" |
2322 | 686 | "- */select/1/2\n" | 688 | u"- */select/1/2\n" |
2323 | 687 | "- testfiles/*/1/1\n" | 689 | u"- testfiles/*/1/1\n" |
2324 | 688 | "- */*/1/3") | 690 | u"- */*/1/3") |
2325 | 689 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 691 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2326 | 690 | self.restore_and_check() | 692 | self.restore_and_check() |
2327 | 691 | 693 | ||
2328 | 692 | def test_exclude_filelist_asterisks_double_asterisks(self): | 694 | def test_exclude_filelist_asterisks_double_asterisks(self): |
2329 | 693 | """Exclude filelist with double asterisks replacing folders.""" | 695 | """Exclude filelist with double asterisks replacing folders.""" |
2330 | 694 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 696 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
2337 | 695 | with open("testfiles/filelist.txt", 'w') as f: | 697 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2338 | 696 | f.write("+ **/1/2/1\n" | 698 | f.write(u"+ **/1/2/1\n" |
2339 | 697 | "- **/1/2\n" | 699 | u"- **/1/2\n" |
2340 | 698 | "- **/select/1/1\n" | 700 | u"- **/select/1/1\n" |
2341 | 699 | "- testfiles/select/1/3") | 701 | u"- testfiles/select/1/3") |
2342 | 700 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 702 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2343 | 701 | self.restore_and_check() | 703 | self.restore_and_check() |
2344 | 702 | 704 | ||
2345 | 703 | def test_commandline_asterisks_single_excludes_only(self): | 705 | def test_commandline_asterisks_single_excludes_only(self): |
2346 | 704 | """test_commandline_include_exclude with single asterisks on exclude lines.""" | 706 | """test_commandline_include_exclude with single asterisks on exclude lines.""" |
2352 | 705 | self.backup("full", "testfiles/select/1", | 707 | self.backup(u"full", u"testfiles/select/1", |
2353 | 706 | options=["--include", "testfiles/select/1/2/1", | 708 | options=[u"--include", u"testfiles/select/1/2/1", |
2354 | 707 | "--exclude", "testfiles/*/1/2", | 709 | u"--exclude", u"testfiles/*/1/2", |
2355 | 708 | "--exclude", "*/select/1/1", | 710 | u"--exclude", u"*/select/1/1", |
2356 | 709 | "--exclude", "*/select/1/3"]) | 711 | u"--exclude", u"*/select/1/3"]) |
2357 | 710 | self.restore_and_check() | 712 | self.restore_and_check() |
2358 | 711 | 713 | ||
2359 | 712 | def test_commandline_asterisks_single_both(self): | 714 | def test_commandline_asterisks_single_both(self): |
2360 | 713 | """test_commandline_include_exclude with single asterisks on both exclude and include lines.""" | 715 | """test_commandline_include_exclude with single asterisks on both exclude and include lines.""" |
2361 | 714 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 716 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
2367 | 715 | self.backup("full", "testfiles/select/1", | 717 | self.backup(u"full", u"testfiles/select/1", |
2368 | 716 | options=["--include", "*/select/1/2/1", | 718 | options=[u"--include", u"*/select/1/2/1", |
2369 | 717 | "--exclude", "testfiles/*/1/2", | 719 | u"--exclude", u"testfiles/*/1/2", |
2370 | 718 | "--exclude", "*/select/1/1", | 720 | u"--exclude", u"*/select/1/1", |
2371 | 719 | "--exclude", "*/select/1/3"]) | 721 | u"--exclude", u"*/select/1/3"]) |
2372 | 720 | self.restore_and_check() | 722 | self.restore_and_check() |
2373 | 721 | 723 | ||
2374 | 722 | def test_commandline_asterisks_double_exclude_only(self): | 724 | def test_commandline_asterisks_double_exclude_only(self): |
2375 | 723 | """test_commandline_include_exclude with double asterisks on exclude lines.""" | 725 | """test_commandline_include_exclude with double asterisks on exclude lines.""" |
2381 | 724 | self.backup("full", "testfiles/select/1", | 726 | self.backup(u"full", u"testfiles/select/1", |
2382 | 725 | options=["--include", "testfiles/select/1/2/1", | 727 | options=[u"--include", u"testfiles/select/1/2/1", |
2383 | 726 | "--exclude", "**/1/2", | 728 | u"--exclude", u"**/1/2", |
2384 | 727 | "--exclude", "**/1/1", | 729 | u"--exclude", u"**/1/1", |
2385 | 728 | "--exclude", "**/1/3"]) | 730 | u"--exclude", u"**/1/3"]) |
2386 | 729 | self.restore_and_check() | 731 | self.restore_and_check() |
2387 | 730 | 732 | ||
2388 | 731 | def test_commandline_asterisks_double_both(self): | 733 | def test_commandline_asterisks_double_both(self): |
2389 | 732 | """test_commandline_include_exclude with double asterisks on both exclude and include lines.""" | 734 | """test_commandline_include_exclude with double asterisks on both exclude and include lines.""" |
2390 | 733 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 735 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
2396 | 734 | self.backup("full", "testfiles/select/1", | 736 | self.backup(u"full", u"testfiles/select/1", |
2397 | 735 | options=["--include", "**/1/2/1", | 737 | options=[u"--include", u"**/1/2/1", |
2398 | 736 | "--exclude", "**/1/2", | 738 | u"--exclude", u"**/1/2", |
2399 | 737 | "--exclude", "**/1/1", | 739 | u"--exclude", u"**/1/1", |
2400 | 738 | "--exclude", "**/1/3"]) | 740 | u"--exclude", u"**/1/3"]) |
2401 | 739 | self.restore_and_check() | 741 | self.restore_and_check() |
2402 | 740 | 742 | ||
2403 | 741 | def test_single_and_double_asterisks(self): | 743 | def test_single_and_double_asterisks(self): |
2404 | 742 | """This compares a backup using --include-globbing-filelist with a single and double *.""" | 744 | """This compares a backup using --include-globbing-filelist with a single and double *.""" |
2419 | 743 | with open("testfiles/filelist.txt", 'w') as f: | 745 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2420 | 744 | f.write("+ testfiles/select2/*\n" | 746 | f.write(u"+ testfiles/select2/*\n" |
2421 | 745 | "- testfiles/select") | 747 | u"- testfiles/select") |
2422 | 746 | self.backup("full", "testfiles/", options=["--include-globbing-filelist=testfiles/filelist.txt"]) | 748 | self.backup(u"full", u"testfiles/", options=[u"--include-globbing-filelist=testfiles/filelist.txt"]) |
2423 | 747 | self.restore() | 749 | self.restore() |
2424 | 748 | restore_dir = 'testfiles/restore_out' | 750 | restore_dir = u"testfiles/restore_out" |
2425 | 749 | restored = self.directory_tree_to_list_of_lists(restore_dir + "/select2") | 751 | restored = self.directory_tree_to_list_of_lists(restore_dir + u"/select2") |
2426 | 750 | with open("testfiles/filelist2.txt", 'w') as f: | 752 | with io.open(u"testfiles/filelist2.txt", u"w") as f: |
2427 | 751 | f.write("+ testfiles/select2/**\n" | 753 | f.write(u"+ testfiles/select2/**\n" |
2428 | 752 | "- testfiles/select") | 754 | u"- testfiles/select") |
2429 | 753 | self.backup("full", "testfiles/", options=["--include-globbing-filelist=testfiles/filelist2.txt"]) | 755 | self.backup(u"full", u"testfiles/", options=[u"--include-globbing-filelist=testfiles/filelist2.txt"]) |
2430 | 754 | self.restore() | 756 | self.restore() |
2431 | 755 | restore_dir = 'testfiles/restore_out' | 757 | restore_dir = u"testfiles/restore_out" |
2432 | 756 | restored2 = self.directory_tree_to_list_of_lists(restore_dir + "/select2") | 758 | restored2 = self.directory_tree_to_list_of_lists(restore_dir + u"/select2") |
2433 | 757 | self.assertEqual(restored, restored2) | 759 | self.assertEqual(restored, restored2) |
2434 | 758 | 760 | ||
2435 | 759 | def test_single_and_double_asterisks_includes_excludes(self): | 761 | def test_single_and_double_asterisks_includes_excludes(self): |
2436 | 760 | """This compares a backup using --includes/--excludes with a single and double *.""" | 762 | """This compares a backup using --includes/--excludes with a single and double *.""" |
2449 | 761 | self.backup("full", "testfiles/", | 763 | self.backup(u"full", u"testfiles/", |
2450 | 762 | options=["--include", "testfiles/select2/*", | 764 | options=[u"--include", u"testfiles/select2/*", |
2451 | 763 | "--exclude", "testfiles/select"]) | 765 | u"--exclude", u"testfiles/select"]) |
2452 | 764 | self.restore() | 766 | self.restore() |
2453 | 765 | restore_dir = 'testfiles/restore_out' | 767 | restore_dir = u"testfiles/restore_out" |
2454 | 766 | restored = self.directory_tree_to_list_of_lists(restore_dir + "/select2") | 768 | restored = self.directory_tree_to_list_of_lists(restore_dir + u"/select2") |
2455 | 767 | self.backup("full", "testfiles/", | 769 | self.backup(u"full", u"testfiles/", |
2456 | 768 | options=["--include", "testfiles/select2/**", | 770 | options=[u"--include", u"testfiles/select2/**", |
2457 | 769 | "--exclude", "testfiles/select"]) | 771 | u"--exclude", u"testfiles/select"]) |
2458 | 770 | self.restore() | 772 | self.restore() |
2459 | 771 | restore_dir = 'testfiles/restore_out' | 773 | restore_dir = u"testfiles/restore_out" |
2460 | 772 | restored2 = self.directory_tree_to_list_of_lists(restore_dir + "/select2") | 774 | restored2 = self.directory_tree_to_list_of_lists(restore_dir + u"/select2") |
2461 | 773 | self.assertEqual(restored, restored2) | 775 | self.assertEqual(restored, restored2) |
2462 | 774 | 776 | ||
2463 | 775 | 777 | ||
2464 | @@ -780,62 +782,62 @@ | |||
2465 | 780 | def restore_and_check(self): | 782 | def restore_and_check(self): |
2466 | 781 | """Restores the backup and compares to what is expected.""" | 783 | """Restores the backup and compares to what is expected.""" |
2467 | 782 | self.restore() | 784 | self.restore() |
2469 | 783 | restore_dir = 'testfiles/restore_out' | 785 | restore_dir = u"testfiles/restore_out" |
2470 | 784 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 786 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2472 | 785 | self.assertEqual(restored, [['2'], ['1']]) | 787 | self.assertEqual(restored, [[u"2"], [u"1"]]) |
2473 | 786 | 788 | ||
2474 | 787 | def test_exclude_filelist_trailing_slashes(self): | 789 | def test_exclude_filelist_trailing_slashes(self): |
2475 | 788 | """test_exclude_filelist_asterisks_none with trailing slashes.""" | 790 | """test_exclude_filelist_asterisks_none with trailing slashes.""" |
2482 | 789 | with open("testfiles/filelist.txt", 'w') as f: | 791 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2483 | 790 | f.write("+ testfiles/select/1/2/1/\n" | 792 | f.write(u"+ testfiles/select/1/2/1/\n" |
2484 | 791 | "- testfiles/select/1/2/\n" | 793 | u"- testfiles/select/1/2/\n" |
2485 | 792 | "- testfiles/select/1/1/\n" | 794 | u"- testfiles/select/1/1/\n" |
2486 | 793 | "- testfiles/select/1/3/") | 795 | u"- testfiles/select/1/3/") |
2487 | 794 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 796 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2488 | 795 | self.restore_and_check() | 797 | self.restore_and_check() |
2489 | 796 | 798 | ||
2490 | 797 | def test_exclude_filelist_trailing_slashes_single_wildcards_excludes(self): | 799 | def test_exclude_filelist_trailing_slashes_single_wildcards_excludes(self): |
2491 | 798 | """test_exclude_filelist_trailing_slashes with single wildcards in excludes.""" | 800 | """test_exclude_filelist_trailing_slashes with single wildcards in excludes.""" |
2492 | 799 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) | 801 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) |
2499 | 800 | with open("testfiles/filelist.txt", 'w') as f: | 802 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2500 | 801 | f.write("+ testfiles/select/1/2/1/\n" | 803 | f.write(u"+ testfiles/select/1/2/1/\n" |
2501 | 802 | "- */select/1/2/\n" | 804 | u"- */select/1/2/\n" |
2502 | 803 | "- testfiles/*/1/1/\n" | 805 | u"- testfiles/*/1/1/\n" |
2503 | 804 | "- */*/1/3/") | 806 | u"- */*/1/3/") |
2504 | 805 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 807 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2505 | 806 | self.restore_and_check() | 808 | self.restore_and_check() |
2506 | 807 | 809 | ||
2507 | 808 | def test_exclude_filelist_trailing_slashes_double_wildcards_excludes(self): | 810 | def test_exclude_filelist_trailing_slashes_double_wildcards_excludes(self): |
2508 | 809 | """test_exclude_filelist_trailing_slashes with double wildcards in excludes.""" | 811 | """test_exclude_filelist_trailing_slashes with double wildcards in excludes.""" |
2509 | 810 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) | 812 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) |
2516 | 811 | with open("testfiles/filelist.txt", 'w') as f: | 813 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2517 | 812 | f.write("+ testfiles/select/1/2/1/\n" | 814 | f.write(u"+ testfiles/select/1/2/1/\n" |
2518 | 813 | "- **/1/2/\n" | 815 | u"- **/1/2/\n" |
2519 | 814 | "- **/1/1/\n" | 816 | u"- **/1/1/\n" |
2520 | 815 | "- **/1/3/") | 817 | u"- **/1/3/") |
2521 | 816 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 818 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2522 | 817 | self.restore_and_check() | 819 | self.restore_and_check() |
2523 | 818 | 820 | ||
2524 | 819 | def test_exclude_filelist_trailing_slashes_double_wildcards_excludes_2(self): | 821 | def test_exclude_filelist_trailing_slashes_double_wildcards_excludes_2(self): |
2525 | 820 | """second test_exclude_filelist_trailing_slashes with double wildcards in excludes.""" | 822 | """second test_exclude_filelist_trailing_slashes with double wildcards in excludes.""" |
2526 | 821 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and | 823 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and |
2527 | 822 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 824 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
2534 | 823 | with open("testfiles/filelist.txt", 'w') as f: | 825 | with io.open(u"testfiles/filelist.txt", u"w") as f: |
2535 | 824 | f.write("+ **/1/2/1/\n" | 826 | f.write(u"+ **/1/2/1/\n" |
2536 | 825 | "- **/1/2/\n" | 827 | u"- **/1/2/\n" |
2537 | 826 | "- **/1/1/\n" | 828 | u"- **/1/1/\n" |
2538 | 827 | "- **/1/3/") | 829 | u"- **/1/3/") |
2539 | 828 | self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"]) | 830 | self.backup(u"full", u"testfiles/select/1", options=[u"--exclude-filelist=testfiles/filelist.txt"]) |
2540 | 829 | self.restore_and_check() | 831 | self.restore_and_check() |
2541 | 830 | 832 | ||
2542 | 831 | def test_exclude_filelist_trailing_slashes_wildcards(self): | 833 | def test_exclude_filelist_trailing_slashes_wildcards(self): |
2543 | 832 | """test_commandline_asterisks_single_excludes_only with trailing slashes.""" | 834 | """test_commandline_asterisks_single_excludes_only with trailing slashes.""" |
2544 | 833 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) | 835 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) |
2550 | 834 | self.backup("full", "testfiles/select/1", | 836 | self.backup(u"full", u"testfiles/select/1", |
2551 | 835 | options=["--include", "testfiles/select/1/2/1/", | 837 | options=[u"--include", u"testfiles/select/1/2/1/", |
2552 | 836 | "--exclude", "testfiles/*/1/2/", | 838 | u"--exclude", u"testfiles/*/1/2/", |
2553 | 837 | "--exclude", "*/select/1/1/", | 839 | u"--exclude", u"*/select/1/1/", |
2554 | 838 | "--exclude", "*/select/1/3/"]) | 840 | u"--exclude", u"*/select/1/3/"]) |
2555 | 839 | self.restore_and_check() | 841 | self.restore_and_check() |
2556 | 840 | 842 | ||
2557 | 841 | 843 | ||
2558 | @@ -845,49 +847,49 @@ | |||
2559 | 845 | 847 | ||
2560 | 846 | def test_no_trailing_slash(self): | 848 | def test_no_trailing_slash(self): |
2561 | 847 | """ Test that including 1.py works as expected""" | 849 | """ Test that including 1.py works as expected""" |
2565 | 848 | self.backup("full", "testfiles/select2", | 850 | self.backup(u"full", u"testfiles/select2", |
2566 | 849 | options=["--include", "testfiles/select2/1.py", | 851 | options=[u"--include", u"testfiles/select2/1.py", |
2567 | 850 | "--exclude", "**"]) | 852 | u"--exclude", u"**"]) |
2568 | 851 | self.restore() | 853 | self.restore() |
2570 | 852 | restore_dir = 'testfiles/restore_out' | 854 | restore_dir = u"testfiles/restore_out" |
2571 | 853 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 855 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2573 | 854 | self.assertEqual(restored, [['1.py']]) | 856 | self.assertEqual(restored, [[u"1.py"]]) |
2574 | 855 | 857 | ||
2575 | 856 | def test_trailing_slash(self): | 858 | def test_trailing_slash(self): |
2576 | 857 | """ Test that globs with a trailing slash only match directories""" | 859 | """ Test that globs with a trailing slash only match directories""" |
2577 | 858 | # Regression test for Bug #1479545 | 860 | # Regression test for Bug #1479545 |
2578 | 859 | # (https://bugs.launchpad.net/duplicity/+bug/1479545) | 861 | # (https://bugs.launchpad.net/duplicity/+bug/1479545) |
2582 | 860 | self.backup("full", "testfiles/select2", | 862 | self.backup(u"full", u"testfiles/select2", |
2583 | 861 | options=["--include", "testfiles/select2/1.py/", | 863 | options=[u"--include", u"testfiles/select2/1.py/", |
2584 | 862 | "--exclude", "**"]) | 864 | u"--exclude", u"**"]) |
2585 | 863 | self.restore() | 865 | self.restore() |
2587 | 864 | restore_dir = 'testfiles/restore_out' | 866 | restore_dir = u"testfiles/restore_out" |
2588 | 865 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 867 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2589 | 866 | self.assertEqual(restored, []) | 868 | self.assertEqual(restored, []) |
2590 | 867 | 869 | ||
2591 | 868 | def test_include_files_not_subdirectories(self): | 870 | def test_include_files_not_subdirectories(self): |
2592 | 869 | """ Test that a trailing slash glob followed by a * glob only matches | 871 | """ Test that a trailing slash glob followed by a * glob only matches |
2593 | 870 | files and not subdirectories""" | 872 | files and not subdirectories""" |
2598 | 871 | self.backup("full", "testfiles/select2", | 873 | self.backup(u"full", u"testfiles/select2", |
2599 | 872 | options=["--exclude", "testfiles/select2/*/", | 874 | options=[u"--exclude", u"testfiles/select2/*/", |
2600 | 873 | "--include", "testfiles/select2/*", | 875 | u"--include", u"testfiles/select2/*", |
2601 | 874 | "--exclude", "**"]) | 876 | u"--exclude", u"**"]) |
2602 | 875 | self.restore() | 877 | self.restore() |
2604 | 876 | restore_dir = 'testfiles/restore_out' | 878 | restore_dir = u"testfiles/restore_out" |
2605 | 877 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 879 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2607 | 878 | self.assertEqual(restored, [['1.doc', '1.py']]) | 880 | self.assertEqual(restored, [[u"1.doc", u"1.py"]]) |
2608 | 879 | 881 | ||
2609 | 880 | def test_include_subdirectories_not_files(self): | 882 | def test_include_subdirectories_not_files(self): |
2610 | 881 | """ Test that a trailing slash glob only matches directories""" | 883 | """ Test that a trailing slash glob only matches directories""" |
2615 | 882 | self.backup("full", "testfiles/select2", | 884 | self.backup(u"full", u"testfiles/select2", |
2616 | 883 | options=["--include", "testfiles/select2/1/1sub1/**/", | 885 | options=[u"--include", u"testfiles/select2/1/1sub1/**/", |
2617 | 884 | "--exclude", "testfiles/select2/1/1sub1/**", | 886 | u"--exclude", u"testfiles/select2/1/1sub1/**", |
2618 | 885 | "--exclude", "**"]) | 887 | u"--exclude", u"**"]) |
2619 | 886 | self.restore() | 888 | self.restore() |
2621 | 887 | restore_dir = 'testfiles/restore_out' | 889 | restore_dir = u"testfiles/restore_out" |
2622 | 888 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 890 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2625 | 889 | self.assertEqual(restored, [['1'], ['1sub1'], | 891 | self.assertEqual(restored, [[u"1"], [u"1sub1"], |
2626 | 890 | ['1sub1sub1', '1sub1sub2', '1sub1sub3']]) | 892 | [u"1sub1sub1", u"1sub1sub2", u"1sub1sub3"]]) |
2627 | 891 | 893 | ||
2628 | 892 | 894 | ||
2629 | 893 | class TestGlobbingReplacement(IncludeExcludeFunctionalTest): | 895 | class TestGlobbingReplacement(IncludeExcludeFunctionalTest): |
2630 | @@ -905,25 +907,25 @@ | |||
2631 | 905 | # Identical to test_include_exclude_basic with globbing characters added to both include and exclude lines | 907 | # Identical to test_include_exclude_basic with globbing characters added to both include and exclude lines |
2632 | 906 | # Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371). | 908 | # Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371). |
2633 | 907 | # See above and the unit tests for more granularity on the issue. | 909 | # See above and the unit tests for more granularity on the issue. |
2640 | 908 | self.backup("full", "testfiles/select2", | 910 | self.backup(u"full", u"testfiles/select2", |
2641 | 909 | options=["--include", "testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt", # Note ** and ? added | 911 | options=[u"--include", u"testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt", # Note ** and ? added |
2642 | 910 | "--exclude", "testfiles/select2/*/3s*1", # Note * added in both directory and filename | 912 | u"--exclude", u"testfiles/select2/*/3s*1", # Note * added in both directory and filename |
2643 | 911 | "--exclude", "testfiles/select2/**/2sub1sub3", # Note ** added | 913 | u"--exclude", u"testfiles/select2/**/2sub1sub3", # Note ** added |
2644 | 912 | "--exclude", "ignorecase:testfiles/select2/2/2sub1/2Sub1Sub2", # Note ignorecase added | 914 | u"--exclude", u"ignorecase:testfiles/select2/2/2sub1/2Sub1Sub2", # Note ignorecase added |
2645 | 913 | "--include", "ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1", # Note ignorecase, [] and | 915 | u"--include", u"ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1", # Note ignorecase, [] and |
2646 | 914 | # ? added | 916 | # ? added |
2657 | 915 | "--exclude", "testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2", # Note [] added | 917 | u"--exclude", u"testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2", # Note [] added |
2658 | 916 | "--exclude", "testfiles/select2/1/1sub[1-4]/1sub3sub1", # Note [range] added | 918 | u"--exclude", u"testfiles/select2/1/1sub[1-4]/1sub3sub1", # Note [range] added |
2659 | 917 | "--include", "testfiles/select2/*/1sub2/1s[w,u,p,q]b2sub1", # Note * and [] added | 919 | u"--include", u"testfiles/select2/*/1sub2/1s[w,u,p,q]b2sub1", # Note * and [] added |
2660 | 918 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt", # Note ? added | 920 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt", # Note ? added |
2661 | 919 | "--exclude", "testfiles/select2/1/1*1/1sub1sub2", # Note * added | 921 | u"--exclude", u"testfiles/select2/1/1*1/1sub1sub2", # Note * added |
2662 | 920 | "--exclude", "testfiles/select2/1/1sub2", | 922 | u"--exclude", u"testfiles/select2/1/1sub2", |
2663 | 921 | "--include", "testfiles/select[2-4]/*.py", # Note * and [range] added | 923 | u"--include", u"testfiles/select[2-4]/*.py", # Note * and [range] added |
2664 | 922 | "--include", "testfiles/*2/3", # Note * added | 924 | u"--include", u"testfiles/*2/3", # Note * added |
2665 | 923 | "--include", "**/select2/1", # Note ** added | 925 | u"--include", u"**/select2/1", # Note ** added |
2666 | 924 | "--exclude", "testfiles/select2/**"]) | 926 | u"--exclude", u"testfiles/select2/**"]) |
2667 | 925 | self.restore() | 927 | self.restore() |
2669 | 926 | restore_dir = 'testfiles/restore_out' | 928 | restore_dir = u"testfiles/restore_out" |
2670 | 927 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 929 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2671 | 928 | self.assertEqual(restored, self.expected_restored_tree) | 930 | self.assertEqual(restored, self.expected_restored_tree) |
2672 | 929 | 931 | ||
2673 | @@ -933,40 +935,40 @@ | |||
2674 | 933 | 935 | ||
2675 | 934 | def test_exclude_if_present_baseline(self): | 936 | def test_exclude_if_present_baseline(self): |
2676 | 935 | """ Test that duplicity normally backs up files""" | 937 | """ Test that duplicity normally backs up files""" |
2682 | 936 | with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag: | 938 | with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/.nobackup", u"w") as tag: |
2683 | 937 | tag.write("Files in this folder should not be backed up.") | 939 | tag.write(u"Files in this folder should not be backed up.") |
2684 | 938 | self.backup("full", "testfiles/select2/1/1sub1", | 940 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2685 | 939 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | 941 | options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/*", |
2686 | 940 | "--exclude", "**"]) | 942 | u"--exclude", u"**"]) |
2687 | 941 | self.restore() | 943 | self.restore() |
2689 | 942 | restore_dir = 'testfiles/restore_out' | 944 | restore_dir = u"testfiles/restore_out" |
2690 | 943 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 945 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2693 | 944 | self.assertEqual(restored, [['1sub1sub1'], | 946 | self.assertEqual(restored, [[u"1sub1sub1"], |
2694 | 945 | ['.nobackup', '1sub1sub1_file.txt']]) | 947 | [u".nobackup", u"1sub1sub1_file.txt"]]) |
2695 | 946 | 948 | ||
2696 | 947 | def test_exclude_if_present_excludes(self): | 949 | def test_exclude_if_present_excludes(self): |
2697 | 948 | """ Test that duplicity excludes files with relevant tag""" | 950 | """ Test that duplicity excludes files with relevant tag""" |
2704 | 949 | with open("testfiles/select2/1/1sub1/1sub1sub1/.nobackup", "w") as tag: | 951 | with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/.nobackup", u"w") as tag: |
2705 | 950 | tag.write("Files in this folder should not be backed up.") | 952 | tag.write(u"Files in this folder should not be backed up.") |
2706 | 951 | self.backup("full", "testfiles/select2/1/1sub1", | 953 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2707 | 952 | options=["--exclude-if-present", ".nobackup", | 954 | options=[u"--exclude-if-present", u".nobackup", |
2708 | 953 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | 955 | u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/*", |
2709 | 954 | "--exclude", "**"]) | 956 | u"--exclude", u"**"]) |
2710 | 955 | self.restore() | 957 | self.restore() |
2712 | 956 | restore_dir = 'testfiles/restore_out' | 958 | restore_dir = u"testfiles/restore_out" |
2713 | 957 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 959 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2714 | 958 | self.assertEqual(restored, []) | 960 | self.assertEqual(restored, []) |
2715 | 959 | 961 | ||
2716 | 960 | def test_exclude_if_present_excludes_2(self): | 962 | def test_exclude_if_present_excludes_2(self): |
2717 | 961 | """ Test that duplicity excludes files with relevant tag""" | 963 | """ Test that duplicity excludes files with relevant tag""" |
2724 | 962 | with open("testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", "w") as tag: | 964 | with io.open(u"testfiles/select2/1/1sub1/1sub1sub1/EXCLUDE.tag", u"w") as tag: |
2725 | 963 | tag.write("Files in this folder should also not be backed up.") | 965 | tag.write(u"Files in this folder should also not be backed up.") |
2726 | 964 | self.backup("full", "testfiles/select2/1/1sub1", | 966 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2727 | 965 | options=["--exclude-if-present", "EXCLUDE.tag", | 967 | options=[u"--exclude-if-present", u"EXCLUDE.tag", |
2728 | 966 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | 968 | u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/*", |
2729 | 967 | "--exclude", "**"]) | 969 | u"--exclude", u"**"]) |
2730 | 968 | self.restore() | 970 | self.restore() |
2732 | 969 | restore_dir = 'testfiles/restore_out' | 971 | restore_dir = u"testfiles/restore_out" |
2733 | 970 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 972 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2734 | 971 | self.assertEqual(restored, []) | 973 | self.assertEqual(restored, []) |
2735 | 972 | 974 | ||
2736 | @@ -974,42 +976,42 @@ | |||
2737 | 974 | class TestLockedFoldersNoError(IncludeExcludeFunctionalTest): | 976 | class TestLockedFoldersNoError(IncludeExcludeFunctionalTest): |
2738 | 975 | """ This tests that inaccessible folders do not cause an error""" | 977 | """ This tests that inaccessible folders do not cause an error""" |
2739 | 976 | 978 | ||
2742 | 977 | @unittest.skipUnless(platform.platform().startswith('Linux'), | 979 | @unittest.skipUnless(platform.platform().startswith("Linux"), |
2743 | 978 | 'Skip on non-Linux systems') | 980 | u"Skip on non-Linux systems") |
2744 | 979 | def test_locked_baseline(self): | 981 | def test_locked_baseline(self): |
2745 | 980 | """ Test no error if locked in path but excluded""" | 982 | """ Test no error if locked in path but excluded""" |
2747 | 981 | folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3" | 983 | folder_to_lock = u"testfiles/select2/1/1sub1/1sub1sub3" |
2748 | 982 | initial_mode = os.stat(folder_to_lock).st_mode | 984 | initial_mode = os.stat(folder_to_lock).st_mode |
2749 | 983 | os.chmod(folder_to_lock, 0o0000) | 985 | os.chmod(folder_to_lock, 0o0000) |
2753 | 984 | self.backup("full", "testfiles/select2/1/1sub1", | 986 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2754 | 985 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | 987 | options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/*", |
2755 | 986 | "--exclude", "**"]) | 988 | u"--exclude", u"**"]) |
2756 | 987 | os.chmod(folder_to_lock, initial_mode) | 989 | os.chmod(folder_to_lock, initial_mode) |
2757 | 988 | self.restore() | 990 | self.restore() |
2759 | 989 | restore_dir = 'testfiles/restore_out' | 991 | restore_dir = u"testfiles/restore_out" |
2760 | 990 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 992 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2763 | 991 | self.assertEqual(restored, [['1sub1sub1'], | 993 | self.assertEqual(restored, [[u"1sub1sub1"], |
2764 | 992 | ['1sub1sub1_file.txt']]) | 994 | [u"1sub1sub1_file.txt"]]) |
2765 | 993 | 995 | ||
2768 | 994 | @unittest.skipUnless(platform.platform().startswith('Linux'), | 996 | @unittest.skipUnless(platform.platform().startswith("Linux"), |
2769 | 995 | 'Skip on non-Linux systems') | 997 | u"Skip on non-Linux systems") |
2770 | 996 | def test_locked_excl_if_present(self): | 998 | def test_locked_excl_if_present(self): |
2771 | 997 | """ Test no error if excluded locked with --exclude-if-present""" | 999 | """ Test no error if excluded locked with --exclude-if-present""" |
2772 | 998 | # Regression test for Bug #1620085 | 1000 | # Regression test for Bug #1620085 |
2773 | 999 | # https://bugs.launchpad.net/duplicity/+bug/1620085 | 1001 | # https://bugs.launchpad.net/duplicity/+bug/1620085 |
2775 | 1000 | folder_to_lock = "testfiles/select2/1/1sub1/1sub1sub3" | 1002 | folder_to_lock = u"testfiles/select2/1/1sub1/1sub1sub3" |
2776 | 1001 | initial_mode = os.stat(folder_to_lock).st_mode | 1003 | initial_mode = os.stat(folder_to_lock).st_mode |
2777 | 1002 | os.chmod(folder_to_lock, 0o0000) | 1004 | os.chmod(folder_to_lock, 0o0000) |
2782 | 1003 | self.backup("full", "testfiles/select2/1/1sub1", | 1005 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2783 | 1004 | options=["--exclude-if-present", "EXCLUDE.tag", | 1006 | options=[u"--exclude-if-present", u"EXCLUDE.tag", |
2784 | 1005 | "--include", "testfiles/select2/1/1sub1/1sub1sub1/*", | 1007 | u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/*", |
2785 | 1006 | "--exclude", "**"]) | 1008 | u"--exclude", u"**"]) |
2786 | 1007 | os.chmod(folder_to_lock, initial_mode) | 1009 | os.chmod(folder_to_lock, initial_mode) |
2787 | 1008 | self.restore() | 1010 | self.restore() |
2789 | 1009 | restore_dir = 'testfiles/restore_out' | 1011 | restore_dir = u"testfiles/restore_out" |
2790 | 1010 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1012 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2793 | 1011 | self.assertEqual(restored, [['1sub1sub1'], | 1013 | self.assertEqual(restored, [[u"1sub1sub1"], |
2794 | 1012 | ['1sub1sub1_file.txt']]) | 1014 | [u"1sub1sub1_file.txt"]]) |
2795 | 1013 | 1015 | ||
2796 | 1014 | 1016 | ||
2797 | 1015 | class TestFolderIncludesFiles(IncludeExcludeFunctionalTest): | 1017 | class TestFolderIncludesFiles(IncludeExcludeFunctionalTest): |
2798 | @@ -1018,73 +1020,73 @@ | |||
2799 | 1018 | 1020 | ||
2800 | 1019 | def test_includes_files(self): | 1021 | def test_includes_files(self): |
2801 | 1020 | """This tests that including a folder includes the files within it""" | 1022 | """This tests that including a folder includes the files within it""" |
2805 | 1021 | self.backup("full", "testfiles/select2/1/1sub1", | 1023 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2806 | 1022 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1", | 1024 | options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1", |
2807 | 1023 | "--exclude", "**"]) | 1025 | u"--exclude", u"**"]) |
2808 | 1024 | self.restore() | 1026 | self.restore() |
2810 | 1025 | restore_dir = 'testfiles/restore_out' | 1027 | restore_dir = u"testfiles/restore_out" |
2811 | 1026 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1028 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2814 | 1027 | self.assertEqual(restored, [['1sub1sub1'], | 1029 | self.assertEqual(restored, [[u"1sub1sub1"], |
2815 | 1028 | ['1sub1sub1_file.txt']]) | 1030 | [u"1sub1sub1_file.txt"]]) |
2816 | 1029 | 1031 | ||
2817 | 1030 | def test_includes_files_trailing_slash(self): | 1032 | def test_includes_files_trailing_slash(self): |
2818 | 1031 | """This tests that including a folder includes the files within it""" | 1033 | """This tests that including a folder includes the files within it""" |
2822 | 1032 | self.backup("full", "testfiles/select2/1/1sub1", | 1034 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2823 | 1033 | options=["--include", "testfiles/select2/1/1sub1/1sub1sub1/", | 1035 | options=[u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/", |
2824 | 1034 | "--exclude", "**"]) | 1036 | u"--exclude", u"**"]) |
2825 | 1035 | self.restore() | 1037 | self.restore() |
2827 | 1036 | restore_dir = 'testfiles/restore_out' | 1038 | restore_dir = u"testfiles/restore_out" |
2828 | 1037 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1039 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2831 | 1038 | self.assertEqual(restored, [['1sub1sub1'], | 1040 | self.assertEqual(restored, [[u"1sub1sub1"], |
2832 | 1039 | ['1sub1sub1_file.txt']]) | 1041 | [u"1sub1sub1_file.txt"]]) |
2833 | 1040 | 1042 | ||
2834 | 1041 | def test_includes_files_trailing_slash_globbing_chars(self): | 1043 | def test_includes_files_trailing_slash_globbing_chars(self): |
2835 | 1042 | """Tests folder includes with globbing char and /""" | 1044 | """Tests folder includes with globbing char and /""" |
2839 | 1043 | self.backup("full", "testfiles/select2/1/1sub1", | 1045 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2840 | 1044 | options=["--include", "testfiles/s?lect2/1/1sub1/1sub1sub1/", | 1046 | options=[u"--include", u"testfiles/s?lect2/1/1sub1/1sub1sub1/", |
2841 | 1045 | "--exclude", "**"]) | 1047 | u"--exclude", u"**"]) |
2842 | 1046 | self.restore() | 1048 | self.restore() |
2844 | 1047 | restore_dir = 'testfiles/restore_out' | 1049 | restore_dir = u"testfiles/restore_out" |
2845 | 1048 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1050 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2848 | 1049 | self.assertEqual(restored, [['1sub1sub1'], | 1051 | self.assertEqual(restored, [[u"1sub1sub1"], |
2849 | 1050 | ['1sub1sub1_file.txt']]) | 1052 | [u"1sub1sub1_file.txt"]]) |
2850 | 1051 | 1053 | ||
2851 | 1052 | def test_excludes_files_no_trailing_slash(self): | 1054 | def test_excludes_files_no_trailing_slash(self): |
2852 | 1053 | """This tests that excluding a folder excludes the files within it""" | 1055 | """This tests that excluding a folder excludes the files within it""" |
2859 | 1054 | self.backup("full", "testfiles/select2/1/1sub1", | 1056 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2860 | 1055 | options=["--exclude", "testfiles/select2/1/1sub1/1sub1sub1", | 1057 | options=[u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub1", |
2861 | 1056 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub2", | 1058 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2", |
2862 | 1057 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub3", | 1059 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3", |
2863 | 1058 | "--include", "testfiles/select2/1/1sub1/1sub1**", | 1060 | u"--include", u"testfiles/select2/1/1sub1/1sub1**", |
2864 | 1059 | "--exclude", "testfiles/select2/1/1sub1/irrelevant.txt"]) | 1061 | u"--exclude", u"testfiles/select2/1/1sub1/irrelevant.txt"]) |
2865 | 1060 | self.restore() | 1062 | self.restore() |
2867 | 1061 | restore_dir = 'testfiles/restore_out' | 1063 | restore_dir = u"testfiles/restore_out" |
2868 | 1062 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1064 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2869 | 1063 | self.assertEqual(restored, []) | 1065 | self.assertEqual(restored, []) |
2870 | 1064 | 1066 | ||
2871 | 1065 | def test_excludes_files_trailing_slash(self): | 1067 | def test_excludes_files_trailing_slash(self): |
2872 | 1066 | """Excluding a folder excludes the files within it, if ends with /""" | 1068 | """Excluding a folder excludes the files within it, if ends with /""" |
2879 | 1067 | self.backup("full", "testfiles/select2/1/1sub1", | 1069 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2880 | 1068 | options=["--exclude", "testfiles/select2/1/1sub1/1sub1sub1/", | 1070 | options=[u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub1/", |
2881 | 1069 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub2/", | 1071 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2/", |
2882 | 1070 | "--exclude", "testfiles/select2/1/1sub1/1sub1sub3/", | 1072 | u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/", |
2883 | 1071 | "--include", "testfiles/select2/1/1sub1/1sub1**", | 1073 | u"--include", u"testfiles/select2/1/1sub1/1sub1**", |
2884 | 1072 | "--exclude", "testfiles/select2/1/1sub1/irrelevant.txt"]) | 1074 | u"--exclude", u"testfiles/select2/1/1sub1/irrelevant.txt"]) |
2885 | 1073 | self.restore() | 1075 | self.restore() |
2887 | 1074 | restore_dir = 'testfiles/restore_out' | 1076 | restore_dir = u"testfiles/restore_out" |
2888 | 1075 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1077 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2889 | 1076 | self.assertEqual(restored, []) | 1078 | self.assertEqual(restored, []) |
2890 | 1077 | 1079 | ||
2891 | 1078 | def test_excludes_files_trailing_slash_globbing_chars(self): | 1080 | def test_excludes_files_trailing_slash_globbing_chars(self): |
2892 | 1079 | """Tests folder excludes with globbing char and /""" | 1081 | """Tests folder excludes with globbing char and /""" |
2899 | 1080 | self.backup("full", "testfiles/select2/1/1sub1", | 1082 | self.backup(u"full", u"testfiles/select2/1/1sub1", |
2900 | 1081 | options=["--exclude", "testfiles/sel?ct2/1/1sub1/1sub1sub1/", | 1083 | options=[u"--exclude", u"testfiles/sel?ct2/1/1sub1/1sub1sub1/", |
2901 | 1082 | "--exclude", "testfiles/sel[e,f]ct2/1/1sub1/1sub1sub2/", | 1084 | u"--exclude", u"testfiles/sel[e,f]ct2/1/1sub1/1sub1sub2/", |
2902 | 1083 | "--exclude", "testfiles/sel*t2/1/1sub1/1sub1sub3/", | 1085 | u"--exclude", u"testfiles/sel*t2/1/1sub1/1sub1sub3/", |
2903 | 1084 | "--include", "testfiles/select2/1/1sub1/1sub1**", | 1086 | u"--include", u"testfiles/select2/1/1sub1/1sub1**", |
2904 | 1085 | "--exclude", "testfiles/select2/1/1sub1/irrelevant.txt"]) | 1087 | u"--exclude", u"testfiles/select2/1/1sub1/irrelevant.txt"]) |
2905 | 1086 | self.restore() | 1088 | self.restore() |
2907 | 1087 | restore_dir = 'testfiles/restore_out' | 1089 | restore_dir = u"testfiles/restore_out" |
2908 | 1088 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1090 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2909 | 1089 | self.assertEqual(restored, []) | 1091 | self.assertEqual(restored, []) |
2910 | 1090 | 1092 | ||
2911 | @@ -1094,30 +1096,110 @@ | |||
2912 | 1094 | 1096 | ||
2913 | 1095 | def test_absolute_paths_non_globbing(self): | 1097 | def test_absolute_paths_non_globbing(self): |
2914 | 1096 | """ Test --include and --exclude work with absolute paths""" | 1098 | """ Test --include and --exclude work with absolute paths""" |
2935 | 1097 | self.backup("full", os.path.abspath("testfiles/select2"), | 1099 | self.backup(u"full", os.path.abspath(u"testfiles/select2"), |
2936 | 1098 | options=["--include", os.path.abspath("testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"), | 1100 | options=[u"--include", os.path.abspath(u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"), |
2937 | 1099 | "--exclude", os.path.abspath("testfiles/select2/3/3sub3/3sub3sub2"), | 1101 | u"--exclude", os.path.abspath(u"testfiles/select2/3/3sub3/3sub3sub2"), |
2938 | 1100 | "--include", os.path.abspath("testfiles/select2/3/3sub2/3sub2sub2"), | 1102 | u"--include", os.path.abspath(u"testfiles/select2/3/3sub2/3sub2sub2"), |
2939 | 1101 | "--include", os.path.abspath("testfiles/select2/3/3sub3"), | 1103 | u"--include", os.path.abspath(u"testfiles/select2/3/3sub3"), |
2940 | 1102 | "--exclude", os.path.abspath("testfiles/select2/3/3sub1"), | 1104 | u"--exclude", os.path.abspath(u"testfiles/select2/3/3sub1"), |
2941 | 1103 | "--exclude", os.path.abspath("testfiles/select2/2/2sub1/2sub1sub3"), | 1105 | u"--exclude", os.path.abspath(u"testfiles/select2/2/2sub1/2sub1sub3"), |
2942 | 1104 | "--exclude", os.path.abspath("testfiles/select2/2/2sub1/2sub1sub2"), | 1106 | u"--exclude", os.path.abspath(u"testfiles/select2/2/2sub1/2sub1sub2"), |
2943 | 1105 | "--include", os.path.abspath("testfiles/select2/2/2sub1"), | 1107 | u"--include", os.path.abspath(u"testfiles/select2/2/2sub1"), |
2944 | 1106 | "--exclude", os.path.abspath("testfiles/select2/1/1sub3/1sub3sub2"), | 1108 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub3/1sub3sub2"), |
2945 | 1107 | "--exclude", os.path.abspath("testfiles/select2/1/1sub3/1sub3sub1"), | 1109 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub3/1sub3sub1"), |
2946 | 1108 | "--exclude", os.path.abspath("testfiles/select2/1/1sub2/1sub2sub3"), | 1110 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub2/1sub2sub3"), |
2947 | 1109 | "--include", os.path.abspath("testfiles/select2/1/1sub2/1sub2sub1"), | 1111 | u"--include", os.path.abspath(u"testfiles/select2/1/1sub2/1sub2sub1"), |
2948 | 1110 | "--exclude", os.path.abspath("testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt"), | 1112 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt"), |
2949 | 1111 | "--exclude", os.path.abspath("testfiles/select2/1/1sub1/1sub1sub2"), | 1113 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub1/1sub1sub2"), |
2950 | 1112 | "--exclude", os.path.abspath("testfiles/select2/1/1sub2"), | 1114 | u"--exclude", os.path.abspath(u"testfiles/select2/1/1sub2"), |
2951 | 1113 | "--include", os.path.abspath("testfiles/select2/1.py"), | 1115 | u"--include", os.path.abspath(u"testfiles/select2/1.py"), |
2952 | 1114 | "--include", os.path.abspath("testfiles/select2/3"), | 1116 | u"--include", os.path.abspath(u"testfiles/select2/3"), |
2953 | 1115 | "--include", os.path.abspath("testfiles/select2/1"), | 1117 | u"--include", os.path.abspath(u"testfiles/select2/1"), |
2954 | 1116 | "--exclude", os.path.abspath("testfiles/select2/**")]) | 1118 | u"--exclude", os.path.abspath(u"testfiles/select2/**")]) |
2955 | 1117 | self.restore() | 1119 | self.restore() |
2957 | 1118 | restore_dir = 'testfiles/restore_out' | 1120 | restore_dir = u"testfiles/restore_out" |
2958 | 1119 | restored = self.directory_tree_to_list_of_lists(restore_dir) | 1121 | restored = self.directory_tree_to_list_of_lists(restore_dir) |
2959 | 1120 | self.assertEqual(restored, self.expected_restored_tree) | 1122 | self.assertEqual(restored, self.expected_restored_tree) |
2960 | 1121 | 1123 | ||
2961 | 1124 | |||
2962 | 1125 | @unittest.skipUnless(sys.getfilesystemencoding() == "UTF-8", | ||
2963 | 1126 | u"Skipping TestUnicode -- Only tested to work on UTF-8 systems") | ||
2964 | 1127 | class TestUnicode(IncludeExcludeFunctionalTest): | ||
2965 | 1128 | """ Tests include/exclude options with unicode paths""" | ||
2966 | 1129 | |||
2967 | 1130 | def test_unicode_paths_non_globbing(self): | ||
2968 | 1131 | """ Test --include and --exclude work with unicode paths""" | ||
2969 | 1132 | self.backup(u"full", u"testfiles/select-unicode", | ||
2970 | 1133 | options=[u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/उदाहरण.txt", | ||
2971 | 1134 | u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/דוגמא.txt", | ||
2972 | 1135 | u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/მაგალითი/", | ||
2973 | 1136 | u"--include", u"testfiles/select-unicode/прыклад/пример/例/", | ||
2974 | 1137 | u"--exclude", u"testfiles/select-unicode/прыклад/пример/", | ||
2975 | 1138 | u"--include", u"testfiles/select-unicode/прыклад/", | ||
2976 | 1139 | u"--include", u"testfiles/select-unicode/օրինակ.txt", | ||
2977 | 1140 | u"--exclude", u"testfiles/select-unicode/**"]) | ||
2978 | 1141 | self.restore() | ||
2979 | 1142 | restore_dir = u"testfiles/restore_out" | ||
2980 | 1143 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
2981 | 1144 | self.assertEqual(restored, [[u"прыклад", u"օրինակ.txt"], | ||
2982 | 1145 | [u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]]) | ||
2983 | 1146 | |||
2984 | 1147 | def test_unicode_paths_asterisks(self): | ||
2985 | 1148 | """ Test --include and --exclude work with unicode paths and globs containing * and **""" | ||
2986 | 1149 | p = u"testfiles/select-unicode/" | ||
2987 | 1150 | self.backup(u"full", u"testfiles/select-unicode", | ||
2988 | 1151 | options=[u"--exclude", p + u"прыклад/пример/例/Παρά*ειγμα/उदाहरण.txt", # Note * | ||
2989 | 1152 | u"--exclude", p + u"прыклад/пример/例/Παράδειγμα/דוגמא.txt", | ||
2990 | 1153 | u"--exclude", p + u"прыклад/пример/例/მაგალითი/", | ||
2991 | 1154 | u"--include", p + u"пр**/例/", # Note ** | ||
2992 | 1155 | u"--exclude", p + u"прыклад/пример/", | ||
2993 | 1156 | u"--include", p + u"прыкла*/", # Note * | ||
2994 | 1157 | u"--include", p + u"օր*ակ.txt", # Note * | ||
2995 | 1158 | u"--exclude", p + u"**"]) | ||
2996 | 1159 | self.restore() | ||
2997 | 1160 | restore_dir = u"testfiles/restore_out" | ||
2998 | 1161 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
2999 | 1162 | self.assertEqual(restored, [[u"прыклад", u"օրինակ.txt"], | ||
3000 | 1163 | [u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]]) | ||
3001 | 1164 | |||
3002 | 1165 | def test_unicode_paths_square_brackets(self): | ||
3003 | 1166 | """ Test --include and --exclude work with unicode paths with character options in []s and [!]s""" | ||
3004 | 1167 | p = u"testfiles/select-unicode/" | ||
3005 | 1168 | self.backup(u"full", u"testfiles/select-unicode", | ||
3006 | 1169 | options=[u"--exclude", p + u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt", | ||
3007 | 1170 | u"--exclude", p + u"пры[к,и,р]лад/пример/例/Παράδειγμα/דוגמא.txt", | ||
3008 | 1171 | u"--exclude", p + u"прыклад/пр[!a,b,c]мер/例/მაგალითი/", | ||
3009 | 1172 | u"--include", p + u"прыклад/при[g,м,д]ер/例/", | ||
3010 | 1173 | u"--exclude", p + u"прыклад/пример/", | ||
3011 | 1174 | u"--include", p + u"прыклад/", | ||
3012 | 1175 | u"--include", p + u"օրինակ.txt", | ||
3013 | 1176 | u"--exclude", p + u"**"]) | ||
3014 | 1177 | self.restore() | ||
3015 | 1178 | restore_dir = u"testfiles/restore_out" | ||
3016 | 1179 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
3017 | 1180 | self.assertEqual(restored, [[u"прыклад", u"օրինակ.txt"], | ||
3018 | 1181 | [u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]]) | ||
3019 | 1182 | |||
3020 | 1183 | def test_unicode_filelist(self): | ||
3021 | 1184 | """Test that exclude filelist works with unicode filenames""" | ||
3022 | 1185 | # As this is an exclude filelist any lines with no +/- modifier should be treated as if they have a -. | ||
3023 | 1186 | path = u"testfiles/select-unicode/" | ||
3024 | 1187 | # Create a filelist | ||
3025 | 1188 | with io.open(u"testfiles/exclude.txt", u"w", encoding="UTF-8") as f: | ||
3026 | 1189 | f.write(u"- " + path + u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt\n" | ||
3027 | 1190 | u"- " + path + u"прыклад/пример/例/Παράδειγμα/דוגמא.txt\n" | ||
3028 | 1191 | u"- " + path + u"прыклад/пример/例/მაგალითი/\n" | ||
3029 | 1192 | u"+ " + path + u"прыклад/пример/例/\n" | ||
3030 | 1193 | u"- " + path + u"прыклад/пример/\n" | ||
3031 | 1194 | u"+ " + path + u"прыклад/\n" | ||
3032 | 1195 | u"+ " + path + u"օրինակ.txt\n" | ||
3033 | 1196 | u"- " + path + u"**") | ||
3034 | 1197 | self.backup(u"full", path, options=[u"--exclude-filelist=testfiles/exclude.txt"]) | ||
3035 | 1198 | self.restore() | ||
3036 | 1199 | restore_dir = u"testfiles/restore_out" | ||
3037 | 1200 | restored = self.directory_tree_to_list_of_lists(restore_dir) | ||
3038 | 1201 | self.assertEqual(restored, [[u"прыклад", u"օրինակ.txt"], | ||
3039 | 1202 | [u"пример", u"উদাহরণ"], [u"例"], [u"Παράδειγμα"], [u"ઉદાહરણ.log"]]) | ||
3040 | 1203 | |||
3041 | 1122 | if __name__ == "__main__": | 1204 | if __name__ == "__main__": |
3042 | 1123 | unittest.main() | 1205 | unittest.main() |
3043 | 1124 | 1206 | ||
3044 | === modified file 'testing/functional/test_verify.py' | |||
3045 | --- testing/functional/test_verify.py 2015-01-01 13:07:31 +0000 | |||
3046 | +++ testing/functional/test_verify.py 2017-12-01 23:01:42 +0000 | |||
3047 | @@ -32,20 +32,20 @@ | |||
3048 | 32 | """ | 32 | """ |
3049 | 33 | def test_verify(self): | 33 | def test_verify(self): |
3050 | 34 | """Test that verify (without --compare-data) works in the basic case""" | 34 | """Test that verify (without --compare-data) works in the basic case""" |
3053 | 35 | self.backup("full", "testfiles/various_file_types", options=[]) | 35 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3054 | 36 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[]) | 36 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[]) |
3055 | 37 | 37 | ||
3056 | 38 | def test_verify_changed_source_file(self): | 38 | def test_verify_changed_source_file(self): |
3057 | 39 | """Test verify (without --compare-data) gives no error if a source file is changed""" | 39 | """Test verify (without --compare-data) gives no error if a source file is changed""" |
3058 | 40 | # This test was made to pass in fixing Bug #1354880 | 40 | # This test was made to pass in fixing Bug #1354880 |
3060 | 41 | self.backup("full", "testfiles/various_file_types", options=[]) | 41 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3061 | 42 | 42 | ||
3062 | 43 | # Edit source file | 43 | # Edit source file |
3063 | 44 | with open('testfiles/various_file_types/executable', 'r+') as f: | 44 | with open('testfiles/various_file_types/executable', 'r+') as f: |
3064 | 45 | f.write('This changes a source file.') | 45 | f.write('This changes a source file.') |
3065 | 46 | 46 | ||
3066 | 47 | # Test verify for the file | 47 | # Test verify for the file |
3068 | 48 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[]) | 48 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[]) |
3069 | 49 | 49 | ||
3070 | 50 | def test_verify_changed_source_file_adjust_mtime(self): | 50 | def test_verify_changed_source_file_adjust_mtime(self): |
3071 | 51 | """Test verify (without --compare-data) gives no error if a source file is changed and the mtime is changed | 51 | """Test verify (without --compare-data) gives no error if a source file is changed and the mtime is changed |
3072 | @@ -58,7 +58,7 @@ | |||
3073 | 58 | # the times from a stat call don't match what a utime will set. | 58 | # the times from a stat call don't match what a utime will set. |
3074 | 59 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) | 59 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) |
3075 | 60 | 60 | ||
3077 | 61 | self.backup("full", "testfiles/various_file_types", options=[]) | 61 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3078 | 62 | 62 | ||
3079 | 63 | # Edit source file | 63 | # Edit source file |
3080 | 64 | with open('testfiles/various_file_types/executable', 'r+') as f: | 64 | with open('testfiles/various_file_types/executable', 'r+') as f: |
3081 | @@ -68,19 +68,19 @@ | |||
3082 | 68 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) | 68 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) |
3083 | 69 | 69 | ||
3084 | 70 | # Test verify for the file | 70 | # Test verify for the file |
3086 | 71 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[]) | 71 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[]) |
3087 | 72 | 72 | ||
3088 | 73 | def test_verify_compare_data(self): | 73 | def test_verify_compare_data(self): |
3089 | 74 | """Test that verify works in the basic case when the --compare-data option is used""" | 74 | """Test that verify works in the basic case when the --compare-data option is used""" |
3091 | 75 | self.backup("full", "testfiles/various_file_types", options=[]) | 75 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3092 | 76 | 76 | ||
3093 | 77 | # Test verify for the file with --compare-data | 77 | # Test verify for the file with --compare-data |
3096 | 78 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', | 78 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', |
3097 | 79 | options=["--compare-data"]) | 79 | options=[u"--compare-data"]) |
3098 | 80 | 80 | ||
3099 | 81 | def test_verify_compare_data_changed_source_file(self): | 81 | def test_verify_compare_data_changed_source_file(self): |
3100 | 82 | """Test verify with --compare-data gives an error if a source file is changed""" | 82 | """Test verify with --compare-data gives an error if a source file is changed""" |
3102 | 83 | self.backup("full", "testfiles/various_file_types", options=[]) | 83 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3103 | 84 | 84 | ||
3104 | 85 | # Edit source file | 85 | # Edit source file |
3105 | 86 | with open('testfiles/various_file_types/executable', 'r+') as f: | 86 | with open('testfiles/various_file_types/executable', 'r+') as f: |
3106 | @@ -88,8 +88,8 @@ | |||
3107 | 88 | 88 | ||
3108 | 89 | # Test verify for edited file fails with --compare-data | 89 | # Test verify for edited file fails with --compare-data |
3109 | 90 | try: | 90 | try: |
3112 | 91 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', | 91 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', |
3113 | 92 | options=["--compare-data"]) | 92 | options=[u"--compare-data"]) |
3114 | 93 | except CmdError as e: | 93 | except CmdError as e: |
3115 | 94 | self.assertEqual(e.exit_status, 1, str(e)) | 94 | self.assertEqual(e.exit_status, 1, str(e)) |
3116 | 95 | else: | 95 | else: |
3117 | @@ -105,7 +105,7 @@ | |||
3118 | 105 | # the times from a stat call don't match what a utime will set | 105 | # the times from a stat call don't match what a utime will set |
3119 | 106 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) | 106 | os.utime('testfiles/various_file_types/executable', (file_info.st_atime, file_info.st_mtime)) |
3120 | 107 | 107 | ||
3122 | 108 | self.backup("full", "testfiles/various_file_types", options=[]) | 108 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3123 | 109 | # Edit source file | 109 | # Edit source file |
3124 | 110 | with open('testfiles/various_file_types/executable', 'r+') as f: | 110 | with open('testfiles/various_file_types/executable', 'r+') as f: |
3125 | 111 | f.write('This changes a source file.') | 111 | f.write('This changes a source file.') |
3126 | @@ -115,8 +115,8 @@ | |||
3127 | 115 | 115 | ||
3128 | 116 | # Test verify for edited file fails with --compare-data | 116 | # Test verify for edited file fails with --compare-data |
3129 | 117 | try: | 117 | try: |
3132 | 118 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', | 118 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', |
3133 | 119 | options=["--compare-data"]) | 119 | options=[u"--compare-data"]) |
3134 | 120 | except CmdError as e: | 120 | except CmdError as e: |
3135 | 121 | self.assertEqual(e.exit_status, 1, str(e)) | 121 | self.assertEqual(e.exit_status, 1, str(e)) |
3136 | 122 | else: | 122 | else: |
3137 | @@ -124,7 +124,7 @@ | |||
3138 | 124 | 124 | ||
3139 | 125 | def test_verify_corrupt_archive(self): | 125 | def test_verify_corrupt_archive(self): |
3140 | 126 | """Test verify (without --compare-data) gives an error if the archive is corrupted""" | 126 | """Test verify (without --compare-data) gives an error if the archive is corrupted""" |
3142 | 127 | self.backup("full", "testfiles/various_file_types", options=[]) | 127 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3143 | 128 | output_files = os.listdir("testfiles/output") | 128 | output_files = os.listdir("testfiles/output") |
3144 | 129 | archives = [elem for elem in output_files if "vol" in elem] | 129 | archives = [elem for elem in output_files if "vol" in elem] |
3145 | 130 | for archive in archives: | 130 | for archive in archives: |
3146 | @@ -133,7 +133,7 @@ | |||
3147 | 133 | f.write('This writes text into each archive file to corrupt it.') | 133 | f.write('This writes text into each archive file to corrupt it.') |
3148 | 134 | # Test verify for the file | 134 | # Test verify for the file |
3149 | 135 | try: | 135 | try: |
3151 | 136 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', options=[]) | 136 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', options=[]) |
3152 | 137 | except CmdError as e: | 137 | except CmdError as e: |
3153 | 138 | # Should return a 21 error code for "hash mismatch" | 138 | # Should return a 21 error code for "hash mismatch" |
3154 | 139 | self.assertEqual(e.exit_status, 21, str(e)) | 139 | self.assertEqual(e.exit_status, 21, str(e)) |
3155 | @@ -142,7 +142,7 @@ | |||
3156 | 142 | 142 | ||
3157 | 143 | def test_verify_corrupt_archive_compare_data(self): | 143 | def test_verify_corrupt_archive_compare_data(self): |
3158 | 144 | """Test verify with --compare-data gives an error if the archive is corrupted""" | 144 | """Test verify with --compare-data gives an error if the archive is corrupted""" |
3160 | 145 | self.backup("full", "testfiles/various_file_types", options=[]) | 145 | self.backup(u"full", u"testfiles/various_file_types", options=[]) |
3161 | 146 | output_files = os.listdir("testfiles/output") | 146 | output_files = os.listdir("testfiles/output") |
3162 | 147 | archives = [elem for elem in output_files if "vol" in elem] | 147 | archives = [elem for elem in output_files if "vol" in elem] |
3163 | 148 | for archive in archives: | 148 | for archive in archives: |
3164 | @@ -151,8 +151,8 @@ | |||
3165 | 151 | f.write('This writes text into each archive file to corrupt it.') | 151 | f.write('This writes text into each archive file to corrupt it.') |
3166 | 152 | # Test verify for the file | 152 | # Test verify for the file |
3167 | 153 | try: | 153 | try: |
3170 | 154 | self.verify('testfiles/various_file_types/executable', file_to_verify='executable', | 154 | self.verify(u'testfiles/various_file_types/executable', file_to_verify=u'executable', |
3171 | 155 | options=["--compare-data"]) | 155 | options=[u"--compare-data"]) |
3172 | 156 | except CmdError as e: | 156 | except CmdError as e: |
3173 | 157 | # Should return a 21 error code for "hash mismatch" | 157 | # Should return a 21 error code for "hash mismatch" |
3174 | 158 | self.assertEqual(e.exit_status, 21, str(e)) | 158 | self.assertEqual(e.exit_status, 21, str(e)) |
3175 | 159 | 159 | ||
3176 | === added file 'testing/testfiles.tar.gz' | |||
3177 | 160 | Binary files testing/testfiles.tar.gz 1970-01-01 00:00:00 +0000 and testing/testfiles.tar.gz 2017-12-01 23:01:42 +0000 differ | 160 | Binary files testing/testfiles.tar.gz 1970-01-01 00:00:00 +0000 and testing/testfiles.tar.gz 2017-12-01 23:01:42 +0000 differ |
3178 | === removed file 'testing/testfiles.tar.gz' | |||
3179 | 161 | Binary files testing/testfiles.tar.gz 2017-11-14 16:53:17 +0000 and testing/testfiles.tar.gz 1970-01-01 00:00:00 +0000 differ | 161 | Binary files testing/testfiles.tar.gz 2017-11-14 16:53:17 +0000 and testing/testfiles.tar.gz 1970-01-01 00:00:00 +0000 differ |
3180 | === modified file 'testing/unit/test_diffdir.py' | |||
3181 | --- testing/unit/test_diffdir.py 2017-01-18 22:59:29 +0000 | |||
3182 | +++ testing/unit/test_diffdir.py 2017-12-01 23:01:42 +0000 | |||
3183 | @@ -20,8 +20,6 @@ | |||
3184 | 20 | # along with duplicity; if not, write to the Free Software Foundation, | 20 | # along with duplicity; if not, write to the Free Software Foundation, |
3185 | 21 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 21 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3186 | 22 | 22 | ||
3187 | 23 | import os | ||
3188 | 24 | import sys | ||
3189 | 25 | import unittest | 23 | import unittest |
3190 | 26 | 24 | ||
3191 | 27 | from duplicity.path import * # @UnusedWildImport | 25 | from duplicity.path import * # @UnusedWildImport |
3192 | 28 | 26 | ||
3193 | === modified file 'testing/unit/test_globmatch.py' | |||
3194 | --- testing/unit/test_globmatch.py 2017-07-11 14:55:38 +0000 | |||
3195 | +++ testing/unit/test_globmatch.py 2017-12-01 23:01:42 +0000 | |||
3196 | @@ -1,3 +1,4 @@ | |||
3197 | 1 | # -*- coding: utf-8 -*- | ||
3198 | 1 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | 2 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
3199 | 2 | # | 3 | # |
3200 | 3 | # Copyright 2002 Ben Escoto <ben@emerose.org> | 4 | # Copyright 2002 Ben Escoto <ben@emerose.org> |
3201 | @@ -20,6 +21,8 @@ | |||
3202 | 20 | # along with duplicity; if not, write to the Free Software Foundation, | 21 | # along with duplicity; if not, write to the Free Software Foundation, |
3203 | 21 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 22 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3204 | 22 | 23 | ||
3205 | 24 | import unittest | ||
3206 | 25 | |||
3207 | 23 | from duplicity.globmatch import * | 26 | from duplicity.globmatch import * |
3208 | 24 | from duplicity.path import * | 27 | from duplicity.path import * |
3209 | 25 | from . import UnitTestCase | 28 | from . import UnitTestCase |
3210 | @@ -75,14 +78,14 @@ | |||
3211 | 75 | 78 | ||
3212 | 76 | def test_glob_to_regex(self): | 79 | def test_glob_to_regex(self): |
3213 | 77 | """test_glob_re - test translation of shell pattern to regular exp""" | 80 | """test_glob_re - test translation of shell pattern to regular exp""" |
3222 | 78 | self.assertEqual(glob_to_regex("hello"), "hello") | 81 | self.assertEqual(glob_to_regex(u"hello"), u"hello") |
3223 | 79 | self.assertEqual(glob_to_regex(".e?ll**o"), "\\.e[^/]ll.*o") | 82 | self.assertEqual(glob_to_regex(u".e?ll**o"), u"\\.e[^/]ll.*o") |
3224 | 80 | self.assertEqual(glob_to_regex("[abc]el[^de][!fg]h"), | 83 | self.assertEqual(glob_to_regex(u"[abc]el[^de][!fg]h"), |
3225 | 81 | "[abc]el[^de][^fg]h") | 84 | u"[abc]el[^de][^fg]h") |
3226 | 82 | self.assertEqual(glob_to_regex("/usr/*/bin/"), | 85 | self.assertEqual(glob_to_regex(u"/usr/*/bin/"), |
3227 | 83 | "\\/usr\\/[^/]*\\/bin\\/") | 86 | u"\\/usr\\/[^/]*\\/bin\\/") |
3228 | 84 | self.assertEqual(glob_to_regex("[a.b/c]"), "[a.b/c]") | 87 | self.assertEqual(glob_to_regex(u"[a.b/c]"), u"[a.b/c]") |
3229 | 85 | self.assertEqual(glob_to_regex("[a*b-c]e[!]]"), "[a*b-c]e[^]]") | 88 | self.assertEqual(glob_to_regex(u"[a*b-c]e[!]]"), u"[a*b-c]e[^]]") |
3230 | 86 | 89 | ||
3231 | 87 | 90 | ||
3232 | 88 | class TestSelectValuesFromGlobs(UnitTestCase): | 91 | class TestSelectValuesFromGlobs(UnitTestCase): |
3233 | @@ -91,22 +94,22 @@ | |||
3234 | 91 | def test_glob_scans_parent_directories(self): | 94 | def test_glob_scans_parent_directories(self): |
3235 | 92 | """Test glob scans parent""" | 95 | """Test glob scans parent""" |
3236 | 93 | self.assertEqual( | 96 | self.assertEqual( |
3238 | 94 | inc_sel_dir("testfiles/parent/sub", "testfiles/parent"), 2) | 97 | inc_sel_dir(u"testfiles/parent/sub", u"testfiles/parent"), 2) |
3239 | 95 | self.assertEqual( | 98 | self.assertEqual( |
3241 | 96 | inc_sel_dir("testfiles/select2/3/3sub2", "testfiles/select2/3"), 2) | 99 | inc_sel_dir(u"testfiles/select2/3/3sub2", u"testfiles/select2/3"), 2) |
3242 | 97 | 100 | ||
3243 | 98 | def test_double_asterisk_include(self): | 101 | def test_double_asterisk_include(self): |
3244 | 99 | """Test a few globbing patterns, including **""" | 102 | """Test a few globbing patterns, including **""" |
3247 | 100 | self.assertEqual(inc_sel_file("**", "foo.txt"), 1) | 103 | self.assertEqual(inc_sel_file(u"**", u"foo.txt"), 1) |
3248 | 101 | self.assertEqual(inc_sel_dir("**", "folder"), 1) | 104 | self.assertEqual(inc_sel_dir(u"**", u"folder"), 1) |
3249 | 102 | 105 | ||
3250 | 103 | def test_double_asterisk_extension_include(self): | 106 | def test_double_asterisk_extension_include(self): |
3251 | 104 | """Test **.py""" | 107 | """Test **.py""" |
3257 | 105 | self.assertEqual(inc_sel_file("**.py", "what/ever.py"), 1) | 108 | self.assertEqual(inc_sel_file(u"**.py", u"what/ever.py"), 1) |
3258 | 106 | self.assertEqual(inc_sel_file("**.py", "what/ever.py/foo"), 1) | 109 | self.assertEqual(inc_sel_file(u"**.py", u"what/ever.py/foo"), 1) |
3259 | 107 | self.assertEqual(inc_sel_dir("**.py", "foo"), 2) | 110 | self.assertEqual(inc_sel_dir(u"**.py", u"foo"), 2) |
3260 | 108 | self.assertEqual(inc_sel_dir("**.py", "usr/local/bin"), 2) | 111 | self.assertEqual(inc_sel_dir(u"**.py", u"usr/local/bin"), 2) |
3261 | 109 | self.assertEqual(inc_sel_dir("**.py", "/usr/local/bin"), 2) | 112 | self.assertEqual(inc_sel_dir(u"**.py", u"/usr/local/bin"), 2) |
3262 | 110 | 113 | ||
3263 | 111 | 114 | ||
3264 | 112 | class TestTrailingSlash(UnitTestCase): | 115 | class TestTrailingSlash(UnitTestCase): |
3265 | @@ -115,95 +118,95 @@ | |||
3266 | 115 | def test_trailing_slash_matches_only_dirs(self): | 118 | def test_trailing_slash_matches_only_dirs(self): |
3267 | 116 | """Test matching where glob includes a trailing slash""" | 119 | """Test matching where glob includes a trailing slash""" |
3268 | 117 | # Test the folder named "folder" is included | 120 | # Test the folder named "folder" is included |
3270 | 118 | self.assertEqual(inc_sel_dir("fold*/", "folder"), 1) | 121 | self.assertEqual(inc_sel_dir(u"fold*/", u"folder"), 1) |
3271 | 119 | 122 | ||
3272 | 120 | # Test the file (not folder) named "folder" is not included | 123 | # Test the file (not folder) named "folder" is not included |
3275 | 121 | self.assertEqual(inc_sel_file("fold*/", "folder"), None) | 124 | self.assertEqual(inc_sel_file(u"fold*/", u"folder"), None) |
3276 | 122 | self.assertEqual(inc_sel_file("folder/", "folder"), None) | 125 | self.assertEqual(inc_sel_file(u"folder/", u"folder"), None) |
3277 | 123 | 126 | ||
3278 | 124 | # Test miscellaneous file/folder | 127 | # Test miscellaneous file/folder |
3280 | 125 | self.assertEqual(inc_sel_file("fo*/", "foo.txt"), None) | 128 | self.assertEqual(inc_sel_file(u"fo*/", u"foo.txt"), None) |
3281 | 126 | 129 | ||
3282 | 127 | def test_included_files_are_matched_no_slash(self): | 130 | def test_included_files_are_matched_no_slash(self): |
3283 | 128 | """Test that files within an included folder are matched""" | 131 | """Test that files within an included folder are matched""" |
3287 | 129 | self.assertEqual(inc_sel_file("fold*", "folder/file.txt"), 1) | 132 | self.assertEqual(inc_sel_file(u"fold*", u"folder/file.txt"), 1) |
3288 | 130 | self.assertEqual(inc_sel_file("fold*", "folder/file.txt"), 1) | 133 | self.assertEqual(inc_sel_file(u"fold*", u"folder/file.txt"), 1) |
3289 | 131 | self.assertEqual(inc_sel_file("fold*", "folder/2/file.txt"), 1) | 134 | self.assertEqual(inc_sel_file(u"fold*", u"folder/2/file.txt"), 1) |
3290 | 132 | 135 | ||
3291 | 133 | def test_included_files_are_matched_no_slash_2(self): | 136 | def test_included_files_are_matched_no_slash_2(self): |
3292 | 134 | """Test that files within an included folder are matched""" | 137 | """Test that files within an included folder are matched""" |
3295 | 135 | self.assertEqual(inc_sel_file("folder", "folder/file.txt"), 1) | 138 | self.assertEqual(inc_sel_file(u"folder", u"folder/file.txt"), 1) |
3296 | 136 | self.assertEqual(inc_sel_file("folder/2", "folder/2/file.txt"), 1) | 139 | self.assertEqual(inc_sel_file(u"folder/2", u"folder/2/file.txt"), 1) |
3297 | 137 | 140 | ||
3298 | 138 | def test_included_files_are_matched_slash(self): | 141 | def test_included_files_are_matched_slash(self): |
3299 | 139 | """Test that files within an included folder are matched with /""" | 142 | """Test that files within an included folder are matched with /""" |
3300 | 140 | # Bug #1624725 | 143 | # Bug #1624725 |
3301 | 141 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 144 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
3303 | 142 | self.assertEqual(inc_sel_file("folder/", "folder/file.txt"), 1) | 145 | self.assertEqual(inc_sel_file(u"folder/", u"folder/file.txt"), 1) |
3304 | 143 | 146 | ||
3305 | 144 | def test_included_files_are_matched_slash_2(self): | 147 | def test_included_files_are_matched_slash_2(self): |
3306 | 145 | """Test that files within an included folder are matched with /""" | 148 | """Test that files within an included folder are matched with /""" |
3307 | 146 | # Bug #1624725 | 149 | # Bug #1624725 |
3308 | 147 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 150 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
3309 | 148 | self.assertEqual(inc_sel_file( | 151 | self.assertEqual(inc_sel_file( |
3312 | 149 | "testfiles/select2/1/1sub1/1sub1sub1/", | 152 | u"testfiles/select2/1/1sub1/1sub1sub1/", |
3313 | 150 | "testfiles/select2/1/1sub1/1sub1sub1/1sub1sub1_file.txt"), 1) | 153 | u"testfiles/select2/1/1sub1/1sub1sub1/1sub1sub1_file.txt"), 1) |
3314 | 151 | 154 | ||
3315 | 152 | def test_included_files_are_matched_slash_2_parents(self): | 155 | def test_included_files_are_matched_slash_2_parents(self): |
3316 | 153 | """Test that duplicity will scan parent of glob/""" | 156 | """Test that duplicity will scan parent of glob/""" |
3317 | 154 | # Bug #1624725 | 157 | # Bug #1624725 |
3318 | 155 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 158 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
3319 | 156 | self.assertEqual(inc_sel_dir( | 159 | self.assertEqual(inc_sel_dir( |
3322 | 157 | "testfiles/select2/1/1sub1/1sub1sub1/", | 160 | u"testfiles/select2/1/1sub1/1sub1sub1/", |
3323 | 158 | "testfiles/select2/1/1sub1/1sub1sub1"), 1) | 161 | u"testfiles/select2/1/1sub1/1sub1sub1"), 1) |
3324 | 159 | self.assertEqual(inc_sel_dir( | 162 | self.assertEqual(inc_sel_dir( |
3327 | 160 | "testfiles/select2/1/1sub1/1sub1sub1/", | 163 | u"testfiles/select2/1/1sub1/1sub1sub1/", |
3328 | 161 | "testfiles/select2/1/1sub1"), 2) | 164 | u"testfiles/select2/1/1sub1"), 2) |
3329 | 162 | 165 | ||
3330 | 163 | def test_included_files_are_matched_slash_wildcard(self): | 166 | def test_included_files_are_matched_slash_wildcard(self): |
3331 | 164 | """Test that files within an included folder are matched with /""" | 167 | """Test that files within an included folder are matched with /""" |
3332 | 165 | # Bug #1624725 | 168 | # Bug #1624725 |
3333 | 166 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 169 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
3335 | 167 | self.assertEqual(inc_sel_file("fold*/", "folder/file.txt"), 1) | 170 | self.assertEqual(inc_sel_file(u"fold*/", u"folder/file.txt"), 1) |
3336 | 168 | 171 | ||
3337 | 169 | def test_slash_matches_everything(self): | 172 | def test_slash_matches_everything(self): |
3338 | 170 | """Test / matches everything""" | 173 | """Test / matches everything""" |
3345 | 171 | self.assertEqual(inc_sel_dir("/", "/tmp/testfiles/select/1/2"), 1) | 174 | self.assertEqual(inc_sel_dir(u"/", u"/tmp/testfiles/select/1/2"), 1) |
3346 | 172 | self.assertEqual(inc_sel_dir("/", "/test/random/path"), 1) | 175 | self.assertEqual(inc_sel_dir(u"/", u"/test/random/path"), 1) |
3347 | 173 | self.assertEqual(exc_sel_dir("/", "/test/random/path"), 0) | 176 | self.assertEqual(exc_sel_dir(u"/", u"/test/random/path"), 0) |
3348 | 174 | self.assertEqual(inc_sel_dir("/", "/"), 1) | 177 | self.assertEqual(inc_sel_dir(u"/", u"/"), 1) |
3349 | 175 | self.assertEqual(inc_sel_dir("/", "/var/log"), 1) | 178 | self.assertEqual(inc_sel_dir(u"/", u"/var/log"), 1) |
3350 | 176 | self.assertEqual(inc_sel_file("/", "/var/log/log.txt"), 1) | 179 | self.assertEqual(inc_sel_file(u"/", u"/var/log/log.txt"), 1) |
3351 | 177 | 180 | ||
3352 | 178 | def test_slash_star_scans_folder(self): | 181 | def test_slash_star_scans_folder(self): |
3353 | 179 | """Test that folder/* scans folder/""" | 182 | """Test that folder/* scans folder/""" |
3354 | 180 | # This behaviour is a bit ambiguous - either include or scan could be | 183 | # This behaviour is a bit ambiguous - either include or scan could be |
3355 | 181 | # argued as most appropriate here, but only an empty folder is at stake | 184 | # argued as most appropriate here, but only an empty folder is at stake |
3356 | 182 | # so long as test_slash_star_includes_folder_contents passes. | 185 | # so long as test_slash_star_includes_folder_contents passes. |
3358 | 183 | self.assertEqual(inc_sel_dir("folder/*", "folder"), 2) | 186 | self.assertEqual(inc_sel_dir(u"folder/*", u"folder"), 2) |
3359 | 184 | 187 | ||
3360 | 185 | def test_slash_star_includes_folder_contents(self): | 188 | def test_slash_star_includes_folder_contents(self): |
3361 | 186 | """Test that folder/* includes folder contents""" | 189 | """Test that folder/* includes folder contents""" |
3364 | 187 | self.assertEqual(inc_sel_file("folder/*", "folder/file.txt"), 1) | 190 | self.assertEqual(inc_sel_file(u"folder/*", u"folder/file.txt"), 1) |
3365 | 188 | self.assertEqual(inc_sel_file("folder/*", "folder/other_file.log"), 1) | 191 | self.assertEqual(inc_sel_file(u"folder/*", u"folder/other_file.log"), 1) |
3366 | 189 | 192 | ||
3367 | 190 | def test_slash_star_star_scans_folder(self): | 193 | def test_slash_star_star_scans_folder(self): |
3368 | 191 | """Test that folder/** scans folder/""" | 194 | """Test that folder/** scans folder/""" |
3370 | 192 | self.assertEqual(inc_sel_dir("folder/**", "folder"), 2) | 195 | self.assertEqual(inc_sel_dir(u"folder/**", u"folder"), 2) |
3371 | 193 | 196 | ||
3372 | 194 | def test_simple_trailing_slash_match(self): | 197 | def test_simple_trailing_slash_match(self): |
3373 | 195 | """Test that a normal folder string ending in / matches that path""" | 198 | """Test that a normal folder string ending in / matches that path""" |
3376 | 196 | self.assertEqual(inc_sel_dir("testfiles/select/1/2/1/", | 199 | self.assertEqual(inc_sel_dir(u"testfiles/select/1/2/1/", |
3377 | 197 | "testfiles/select/1/2/1"), 1) | 200 | u"testfiles/select/1/2/1"), 1) |
3378 | 198 | 201 | ||
3379 | 199 | def test_double_asterisk_string_slash(self): | 202 | def test_double_asterisk_string_slash(self): |
3380 | 200 | """Test string starting with ** and ending in /""" | 203 | """Test string starting with ** and ending in /""" |
3382 | 201 | self.assertEqual(inc_sel_dir("**/1/2/", "testfiles/select/1/2"), 1) | 204 | self.assertEqual(inc_sel_dir(u"**/1/2/", u"testfiles/select/1/2"), 1) |
3383 | 202 | 205 | ||
3384 | 203 | def test_string_double_asterisk_string_slash(self): | 206 | def test_string_double_asterisk_string_slash(self): |
3385 | 204 | """Test string ** string /""" | 207 | """Test string ** string /""" |
3388 | 205 | self.assertEqual(inc_sel_dir("testfiles**/2/", | 208 | self.assertEqual(inc_sel_dir(u"testfiles**/2/", |
3389 | 206 | "testfiles/select/1/2"), 1) | 209 | u"testfiles/select/1/2"), 1) |
3390 | 207 | 210 | ||
3391 | 208 | 211 | ||
3392 | 209 | class TestDoubleAsterisk(UnitTestCase): | 212 | class TestDoubleAsterisk(UnitTestCase): |
3393 | @@ -211,19 +214,75 @@ | |||
3394 | 211 | 214 | ||
3395 | 212 | def test_double_asterisk_no_match(self): | 215 | def test_double_asterisk_no_match(self): |
3396 | 213 | """Test that a folder string ending /** does not match other paths""" | 216 | """Test that a folder string ending /** does not match other paths""" |
3398 | 214 | self.assertEqual(inc_sel_dir("/test/folder/**", "/test/foo"), None) | 217 | self.assertEqual(inc_sel_dir(u"/test/folder/**", u"/test/foo"), None) |
3399 | 215 | 218 | ||
3400 | 216 | def test_double_asterisk_match(self): | 219 | def test_double_asterisk_match(self): |
3401 | 217 | """Test that a folder string ending in /** matches that path""" | 220 | """Test that a folder string ending in /** matches that path""" |
3410 | 218 | self.assertEqual(inc_sel_dir("/test/folder/**", | 221 | self.assertEqual(inc_sel_dir(u"/test/folder/**", |
3411 | 219 | "/test/folder/foo"), 1) | 222 | u"/test/folder/foo"), 1) |
3412 | 220 | self.assertEqual(inc_sel_file("/test/folder/**", | 223 | self.assertEqual(inc_sel_file(u"/test/folder/**", |
3413 | 221 | "/test/folder/foo.txt"), 1) | 224 | u"/test/folder/foo.txt"), 1) |
3414 | 222 | self.assertEqual(inc_sel_dir("/test/folder/**", | 225 | self.assertEqual(inc_sel_dir(u"/test/folder/**", |
3415 | 223 | "/test/folder/2/foo"), 1) | 226 | u"/test/folder/2/foo"), 1) |
3416 | 224 | self.assertEqual(inc_sel_file("/test/folder/**", | 227 | self.assertEqual(inc_sel_file(u"/test/folder/**", |
3417 | 225 | "/test/folder/2/foo.txt"), 1) | 228 | u"/test/folder/2/foo.txt"), 1) |
3418 | 226 | 229 | ||
3419 | 227 | def test_asterisk_slash_double_asterisk(self): | 230 | def test_asterisk_slash_double_asterisk(self): |
3420 | 228 | """Test folder string ending in */**""" | 231 | """Test folder string ending in */**""" |
3422 | 229 | self.assertEqual(inc_sel_dir("fold*/**", "folder"), 2) | 232 | self.assertEqual(inc_sel_dir(u"fold*/**", u"folder"), 2) |
3423 | 233 | |||
3424 | 234 | |||
3425 | 235 | class TestSimpleUnicode(UnitTestCase): | ||
3426 | 236 | """Test simple unicode comparison""" | ||
3427 | 237 | |||
3428 | 238 | def test_simple_unicode(self): | ||
3429 | 239 | """Test simple unicode comparison""" | ||
3430 | 240 | self.assertEqual(inc_sel_file(u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt", | ||
3431 | 241 | u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), 1) | ||
3432 | 242 | |||
3433 | 243 | |||
3434 | 244 | class TestSquareBrackets(UnitTestCase): | ||
3435 | 245 | """Test glob matching where the glob includes []s and [!]s""" | ||
3436 | 246 | |||
3437 | 247 | def test_square_bracket_options(self): | ||
3438 | 248 | """Test file including options in []s""" | ||
3439 | 249 | self.assertEqual(inc_sel_file(u"/test/f[o,s,p]lder/foo.txt", | ||
3440 | 250 | u"/test/folder/foo.txt"), 1) | ||
3441 | 251 | self.assertEqual(inc_sel_file(u"/test/f[i,s,p]lder/foo.txt", | ||
3442 | 252 | u"/test/folder/foo.txt"), None) | ||
3443 | 253 | self.assertEqual(inc_sel_file(u"/test/f[s,o,p]lder/foo.txt", | ||
3444 | 254 | u"/test/folder/foo.txt"), 1) | ||
3445 | 255 | |||
3446 | 256 | def test_square_bracket_options_unicode(self): | ||
3447 | 257 | """Test file including options in []s""" | ||
3448 | 258 | self.assertEqual(inc_sel_file(u"прыклад/пр[и,j,l]мер/例/Παράδειγμα/उदाहरण.txt", | ||
3449 | 259 | u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), 1) | ||
3450 | 260 | self.assertEqual(inc_sel_file(u"прыклад/п[a,b,c]имер/例/Παράδειγμα/उदाहरण.txt", | ||
3451 | 261 | u"прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), None) | ||
3452 | 262 | |||
3453 | 263 | def test_not_square_bracket_options(self): | ||
3454 | 264 | """Test file including options in [!]s""" | ||
3455 | 265 | self.assertEqual(inc_sel_file(u"/test/f[!o,s,p]lder/foo.txt", | ||
3456 | 266 | u"/test/folder/foo.txt"), None) | ||
3457 | 267 | self.assertEqual(inc_sel_file(u"/test/f[!i,s,p]lder/foo.txt", | ||
3458 | 268 | u"/test/folder/foo.txt"), 1) | ||
3459 | 269 | self.assertEqual(inc_sel_file(u"/test/f[!s,o,p]lder/foo.txt", | ||
3460 | 270 | u"/test/folder/foo.txt"), None) | ||
3461 | 271 | |||
3462 | 272 | def test_square_bracket_range(self): | ||
3463 | 273 | """Test file including range in []s""" | ||
3464 | 274 | self.assertEqual(inc_sel_file(u"/test/folder[1-5]/foo.txt", | ||
3465 | 275 | u"/test/folder4/foo.txt"), 1) | ||
3466 | 276 | self.assertEqual(inc_sel_file(u"/test/folder[5-9]/foo.txt", | ||
3467 | 277 | u"/test/folder4/foo.txt"), None) | ||
3468 | 278 | self.assertEqual(inc_sel_file(u"/test/folder[1-5]/foo.txt", | ||
3469 | 279 | u"/test/folder6/foo.txt"), None) | ||
3470 | 280 | |||
3471 | 281 | def test_square_bracket_not_range(self): | ||
3472 | 282 | """Test file including range in [!]s""" | ||
3473 | 283 | self.assertEqual(inc_sel_file(u"/test/folder[!1-5]/foo.txt", | ||
3474 | 284 | u"/test/folder4/foo.txt"), None) | ||
3475 | 285 | self.assertEqual(inc_sel_file(u"/test/folder[!5-9]/foo.txt", | ||
3476 | 286 | u"/test/folder4/foo.txt"), 1) | ||
3477 | 287 | self.assertEqual(inc_sel_file(u"/test/folder[!1-5]/foo.txt", | ||
3478 | 288 | u"/test/folder6/foo.txt"), 1) | ||
3479 | 230 | 289 | ||
3480 | === modified file 'testing/unit/test_gpg.py' | |||
3481 | --- testing/unit/test_gpg.py 2017-07-11 14:55:38 +0000 | |||
3482 | +++ testing/unit/test_gpg.py 2017-12-01 23:01:42 +0000 | |||
3483 | @@ -71,23 +71,23 @@ | |||
3484 | 71 | 71 | ||
3485 | 72 | def test_gpg_asym(self): | 72 | def test_gpg_asym(self): |
3486 | 73 | """Test GPG asymmetric encryption""" | 73 | """Test GPG asymmetric encryption""" |
3488 | 74 | profile = gpg.GPGProfile(passphrase=self.sign_passphrase, | 74 | profile = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3489 | 75 | recipients=[self.encrypt_key1, | 75 | recipients=[self.encrypt_key1, |
3490 | 76 | self.encrypt_key2]) | 76 | self.encrypt_key2]) |
3491 | 77 | self.gpg_cycle("aoensutha aonetuh saoe", profile) | 77 | self.gpg_cycle("aoensutha aonetuh saoe", profile) |
3492 | 78 | 78 | ||
3494 | 79 | profile2 = gpg.GPGProfile(passphrase=self.sign_passphrase, | 79 | profile2 = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3495 | 80 | recipients=[self.encrypt_key1]) | 80 | recipients=[self.encrypt_key1]) |
3496 | 81 | self.gpg_cycle("aoeu" * 10000, profile2) | 81 | self.gpg_cycle("aoeu" * 10000, profile2) |
3497 | 82 | 82 | ||
3498 | 83 | def test_gpg_hidden_asym(self): | 83 | def test_gpg_hidden_asym(self): |
3499 | 84 | """Test GPG asymmetric encryption with hidden key id""" | 84 | """Test GPG asymmetric encryption with hidden key id""" |
3501 | 85 | profile = gpg.GPGProfile(passphrase=self.sign_passphrase, | 85 | profile = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3502 | 86 | hidden_recipients=[self.encrypt_key1, | 86 | hidden_recipients=[self.encrypt_key1, |
3503 | 87 | self.encrypt_key2]) | 87 | self.encrypt_key2]) |
3504 | 88 | self.gpg_cycle("aoensutha aonetuh saoe", profile) | 88 | self.gpg_cycle("aoensutha aonetuh saoe", profile) |
3505 | 89 | 89 | ||
3507 | 90 | profile2 = gpg.GPGProfile(passphrase=self.sign_passphrase, | 90 | profile2 = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3508 | 91 | hidden_recipients=[self.encrypt_key1]) | 91 | hidden_recipients=[self.encrypt_key1]) |
3509 | 92 | self.gpg_cycle("aoeu" * 10000, profile2) | 92 | self.gpg_cycle("aoeu" * 10000, profile2) |
3510 | 93 | 93 | ||
3511 | @@ -95,7 +95,7 @@ | |||
3512 | 95 | """Test to make sure GPG reports the proper signature key""" | 95 | """Test to make sure GPG reports the proper signature key""" |
3513 | 96 | plaintext = "hello" * 50000 | 96 | plaintext = "hello" * 50000 |
3514 | 97 | 97 | ||
3516 | 98 | signing_profile = gpg.GPGProfile(passphrase=self.sign_passphrase, | 98 | signing_profile = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3517 | 99 | sign_key=self.sign_key, | 99 | sign_key=self.sign_key, |
3518 | 100 | recipients=[self.encrypt_key1]) | 100 | recipients=[self.encrypt_key1]) |
3519 | 101 | 101 | ||
3520 | @@ -114,7 +114,7 @@ | |||
3521 | 114 | """Test to make sure GPG reports the proper signature key even with hidden encryption key id""" | 114 | """Test to make sure GPG reports the proper signature key even with hidden encryption key id""" |
3522 | 115 | plaintext = "hello" * 50000 | 115 | plaintext = "hello" * 50000 |
3523 | 116 | 116 | ||
3525 | 117 | signing_profile = gpg.GPGProfile(passphrase=self.sign_passphrase, | 117 | signing_profile = gpg.GPGProfile(passphrase=self.sign_passphrase_bytes, |
3526 | 118 | sign_key=self.sign_key, | 118 | sign_key=self.sign_key, |
3527 | 119 | hidden_recipients=[self.encrypt_key1]) | 119 | hidden_recipients=[self.encrypt_key1]) |
3528 | 120 | 120 | ||
3529 | 121 | 121 | ||
3530 | === modified file 'testing/unit/test_patchdir.py' | |||
3531 | --- testing/unit/test_patchdir.py 2015-02-01 17:37:37 +0000 | |||
3532 | +++ testing/unit/test_patchdir.py 2017-12-01 23:01:42 +0000 | |||
3533 | @@ -21,7 +21,6 @@ | |||
3534 | 21 | 21 | ||
3535 | 22 | from future_builtins import map | 22 | from future_builtins import map |
3536 | 23 | 23 | ||
3537 | 24 | import sys | ||
3538 | 25 | import cStringIO | 24 | import cStringIO |
3539 | 26 | import unittest | 25 | import unittest |
3540 | 27 | 26 | ||
3541 | 28 | 27 | ||
3542 | === modified file 'testing/unit/test_selection.py' | |||
3543 | --- testing/unit/test_selection.py 2017-07-11 14:55:38 +0000 | |||
3544 | +++ testing/unit/test_selection.py 2017-12-01 23:01:42 +0000 | |||
3545 | @@ -1,3 +1,4 @@ | |||
3546 | 1 | # -*- coding: utf-8 -*- | ||
3547 | 1 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | 2 | # -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- |
3548 | 2 | # | 3 | # |
3549 | 3 | # Copyright 2002 Ben Escoto <ben@emerose.org> | 4 | # Copyright 2002 Ben Escoto <ben@emerose.org> |
3550 | @@ -36,165 +37,165 @@ | |||
3551 | 36 | def setUp(self): | 37 | def setUp(self): |
3552 | 37 | super(MatchingTest, self).setUp() | 38 | super(MatchingTest, self).setUp() |
3553 | 38 | self.unpack_testfiles() | 39 | self.unpack_testfiles() |
3555 | 39 | self.root = Path("testfiles/select") | 40 | self.root = Path(u"testfiles/select") |
3556 | 40 | self.Select = Select(self.root) | 41 | self.Select = Select(self.root) |
3557 | 41 | 42 | ||
3558 | 42 | def makeext(self, path): | 43 | def makeext(self, path): |
3560 | 43 | return self.root.new_index(tuple(path.split("/"))) | 44 | return self.root.new_index(tuple(path.split(u"/"))) |
3561 | 44 | 45 | ||
3562 | 45 | def testRegexp(self): | 46 | def testRegexp(self): |
3563 | 46 | """Test regular expression selection func""" | 47 | """Test regular expression selection func""" |
3568 | 47 | sf1 = self.Select.regexp_get_sf(".*\.py", 1) | 48 | sf1 = self.Select.regexp_get_sf(u".*\.py", 1) |
3569 | 48 | assert sf1(self.makeext("1.py")) == 1 | 49 | assert sf1(self.makeext(u"1.py")) == 1 |
3570 | 49 | assert sf1(self.makeext("usr/foo.py")) == 1 | 50 | assert sf1(self.makeext(u"usr/foo.py")) == 1 |
3571 | 50 | assert sf1(self.root.append("1.doc")) is None | 51 | assert sf1(self.root.append(u"1.doc")) is None |
3572 | 51 | 52 | ||
3577 | 52 | sf2 = self.Select.regexp_get_sf("hello", 0) | 53 | sf2 = self.Select.regexp_get_sf(u"hello", 0) |
3578 | 53 | assert sf2(Path("hello")) == 0 | 54 | assert sf2(Path(u"hello")) == 0 |
3579 | 54 | assert sf2(Path("foohello_there")) == 0 | 55 | assert sf2(Path(u"foohello_there")) == 0 |
3580 | 55 | assert sf2(Path("foo")) is None | 56 | assert sf2(Path(u"foo")) is None |
3581 | 56 | 57 | ||
3582 | 57 | def test_tuple_include(self): | 58 | def test_tuple_include(self): |
3583 | 58 | """Test include selection function made from a regular filename""" | 59 | """Test include selection function made from a regular filename""" |
3584 | 59 | self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf, | 60 | self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf, |
3590 | 60 | "foo", 1) | 61 | u"foo", 1) |
3591 | 61 | 62 | ||
3592 | 62 | sf2 = self.Select.glob_get_sf("testfiles/select/usr/local/bin/", 1) | 63 | sf2 = self.Select.glob_get_sf(u"testfiles/select/usr/local/bin/", 1) |
3593 | 63 | 64 | ||
3594 | 64 | with patch('duplicity.path.ROPath.isdir') as mock_isdir: | 65 | with patch(u"duplicity.path.ROPath.isdir") as mock_isdir: |
3595 | 65 | mock_isdir.return_value = True | 66 | mock_isdir.return_value = True |
3596 | 66 | # Can't pass the return_value as an argument to patch, i.e.: | 67 | # Can't pass the return_value as an argument to patch, i.e.: |
3598 | 67 | # with patch('duplicity.path.ROPath.isdir', return_value=True): | 68 | # with patch("duplicity.path.ROPath.isdir", return_value=True): |
3599 | 68 | # as build system's mock is too old to support it. | 69 | # as build system's mock is too old to support it. |
3600 | 69 | 70 | ||
3607 | 70 | self.assertEqual(sf2(self.makeext("usr")), 2) | 71 | self.assertEqual(sf2(self.makeext(u"usr")), 2) |
3608 | 71 | self.assertEqual(sf2(self.makeext("usr/local")), 2) | 72 | self.assertEqual(sf2(self.makeext(u"usr/local")), 2) |
3609 | 72 | self.assertEqual(sf2(self.makeext("usr/local/bin")), 1) | 73 | self.assertEqual(sf2(self.makeext(u"usr/local/bin")), 1) |
3610 | 73 | self.assertEqual(sf2(self.makeext("usr/local/doc")), None) | 74 | self.assertEqual(sf2(self.makeext(u"usr/local/doc")), None) |
3611 | 74 | self.assertEqual(sf2(self.makeext("usr/local/bin/gzip")), 1) | 75 | self.assertEqual(sf2(self.makeext(u"usr/local/bin/gzip")), 1) |
3612 | 75 | self.assertEqual(sf2(self.makeext("usr/local/bingzip")), None) | 76 | self.assertEqual(sf2(self.makeext(u"usr/local/bingzip")), None) |
3613 | 76 | 77 | ||
3614 | 77 | def test_tuple_exclude(self): | 78 | def test_tuple_exclude(self): |
3615 | 78 | """Test exclude selection function made from a regular filename""" | 79 | """Test exclude selection function made from a regular filename""" |
3616 | 79 | self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf, | 80 | self.assertRaises(FilePrefixError, self.Select.glob_get_normal_sf, |
3622 | 80 | "foo", 0) | 81 | u"foo", 0) |
3623 | 81 | 82 | ||
3624 | 82 | sf2 = self.Select.glob_get_sf("testfiles/select/usr/local/bin/", 0) | 83 | sf2 = self.Select.glob_get_sf(u"testfiles/select/usr/local/bin/", 0) |
3625 | 83 | 84 | ||
3626 | 84 | with patch('duplicity.path.ROPath.isdir') as mock_isdir: | 85 | with patch(u"duplicity.path.ROPath.isdir") as mock_isdir: |
3627 | 85 | mock_isdir.return_value = True | 86 | mock_isdir.return_value = True |
3628 | 86 | 87 | ||
3635 | 87 | assert sf2(self.makeext("usr")) is None | 88 | assert sf2(self.makeext(u"usr")) is None |
3636 | 88 | assert sf2(self.makeext("usr/local")) is None | 89 | assert sf2(self.makeext(u"usr/local")) is None |
3637 | 89 | assert sf2(self.makeext("usr/local/bin")) == 0 | 90 | assert sf2(self.makeext(u"usr/local/bin")) == 0 |
3638 | 90 | assert sf2(self.makeext("usr/local/doc")) is None | 91 | assert sf2(self.makeext(u"usr/local/doc")) is None |
3639 | 91 | assert sf2(self.makeext("usr/local/bin/gzip")) == 0 | 92 | assert sf2(self.makeext(u"usr/local/bin/gzip")) == 0 |
3640 | 92 | assert sf2(self.makeext("usr/local/bingzip")) is None | 93 | assert sf2(self.makeext(u"usr/local/bingzip")) is None |
3641 | 93 | 94 | ||
3642 | 94 | def test_glob_star_include(self): | 95 | def test_glob_star_include(self): |
3643 | 95 | """Test a few globbing patterns, including **""" | 96 | """Test a few globbing patterns, including **""" |
3647 | 96 | sf1 = self.Select.glob_get_sf("**", 1) | 97 | sf1 = self.Select.glob_get_sf(u"**", 1) |
3648 | 97 | assert sf1(self.makeext("foo")) == 1 | 98 | assert sf1(self.makeext(u"foo")) == 1 |
3649 | 98 | assert sf1(self.makeext("")) == 1 | 99 | assert sf1(self.makeext(u"")) == 1 |
3650 | 99 | 100 | ||
3656 | 100 | sf2 = self.Select.glob_get_sf("**.py", 1) | 101 | sf2 = self.Select.glob_get_sf(u"**.py", 1) |
3657 | 101 | assert sf2(self.makeext("foo")) == 2 | 102 | assert sf2(self.makeext(u"foo")) == 2 |
3658 | 102 | assert sf2(self.makeext("usr/local/bin")) == 2 | 103 | assert sf2(self.makeext(u"usr/local/bin")) == 2 |
3659 | 103 | assert sf2(self.makeext("what/ever.py")) == 1 | 104 | assert sf2(self.makeext(u"what/ever.py")) == 1 |
3660 | 104 | assert sf2(self.makeext("what/ever.py/foo")) == 1 | 105 | assert sf2(self.makeext(u"what/ever.py/foo")) == 1 |
3661 | 105 | 106 | ||
3662 | 106 | def test_glob_star_exclude(self): | 107 | def test_glob_star_exclude(self): |
3663 | 107 | """Test a few glob excludes, including **""" | 108 | """Test a few glob excludes, including **""" |
3666 | 108 | sf1 = self.Select.glob_get_sf("**", 0) | 109 | sf1 = self.Select.glob_get_sf(u"**", 0) |
3667 | 109 | assert sf1(self.makeext("/usr/local/bin")) == 0 | 110 | assert sf1(self.makeext(u"/usr/local/bin")) == 0 |
3668 | 110 | 111 | ||
3674 | 111 | sf2 = self.Select.glob_get_sf("**.py", 0) | 112 | sf2 = self.Select.glob_get_sf(u"**.py", 0) |
3675 | 112 | assert sf2(self.makeext("foo")) is None | 113 | assert sf2(self.makeext(u"foo")) is None |
3676 | 113 | assert sf2(self.makeext("usr/local/bin")) is None | 114 | assert sf2(self.makeext(u"usr/local/bin")) is None |
3677 | 114 | assert sf2(self.makeext("what/ever.py")) == 0 | 115 | assert sf2(self.makeext(u"what/ever.py")) == 0 |
3678 | 115 | assert sf2(self.makeext("what/ever.py/foo")) == 0 | 116 | assert sf2(self.makeext(u"what/ever.py/foo")) == 0 |
3679 | 116 | 117 | ||
3680 | 117 | def test_simple_glob_double_asterisk(self): | 118 | def test_simple_glob_double_asterisk(self): |
3681 | 118 | """test_simple_glob_double_asterisk - primarily to check that the defaults used by the error tests work""" | 119 | """test_simple_glob_double_asterisk - primarily to check that the defaults used by the error tests work""" |
3683 | 119 | assert self.Select.glob_get_normal_sf("**", 1) | 120 | assert self.Select.glob_get_normal_sf(u"**", 1) |
3684 | 120 | 121 | ||
3685 | 121 | def test_glob_sf_exception(self): | 122 | def test_glob_sf_exception(self): |
3686 | 122 | """test_glob_sf_exception - see if globbing errors returned""" | 123 | """test_glob_sf_exception - see if globbing errors returned""" |
3687 | 123 | self.assertRaises(GlobbingError, self.Select.glob_get_normal_sf, | 124 | self.assertRaises(GlobbingError, self.Select.glob_get_normal_sf, |
3689 | 124 | "testfiles/select/hello//there", 1) | 125 | u"testfiles/select/hello//there", 1) |
3690 | 125 | 126 | ||
3691 | 126 | def test_file_prefix_sf_exception(self): | 127 | def test_file_prefix_sf_exception(self): |
3692 | 127 | """test_file_prefix_sf_exception - see if FilePrefix error is returned""" | 128 | """test_file_prefix_sf_exception - see if FilePrefix error is returned""" |
3693 | 128 | # These should raise a FilePrefixError because the root directory for the selection is "testfiles/select" | 129 | # These should raise a FilePrefixError because the root directory for the selection is "testfiles/select" |
3694 | 129 | self.assertRaises(FilePrefixError, | 130 | self.assertRaises(FilePrefixError, |
3696 | 130 | self.Select.glob_get_sf, "testfiles/whatever", 1) | 131 | self.Select.glob_get_sf, u"testfiles/whatever", 1) |
3697 | 131 | self.assertRaises(FilePrefixError, | 132 | self.assertRaises(FilePrefixError, |
3699 | 132 | self.Select.glob_get_sf, "testfiles/?hello", 0) | 133 | self.Select.glob_get_sf, u"testfiles/?hello", 0) |
3700 | 133 | 134 | ||
3701 | 134 | def test_scan(self): | 135 | def test_scan(self): |
3702 | 135 | """Tests what is returned for selection tests regarding directory scanning""" | 136 | """Tests what is returned for selection tests regarding directory scanning""" |
3704 | 136 | select = Select(Path("/")) | 137 | select = Select(Path(u"/")) |
3705 | 137 | 138 | ||
3714 | 138 | assert select.glob_get_sf("**.py", 1)(Path("/")) == 2 | 139 | assert select.glob_get_sf(u"**.py", 1)(Path(u"/")) == 2 |
3715 | 139 | assert select.glob_get_sf("**.py", 1)(Path("foo")) == 2 | 140 | assert select.glob_get_sf(u"**.py", 1)(Path(u"foo")) == 2 |
3716 | 140 | assert select.glob_get_sf("**.py", 1)(Path("usr/local/bin")) == 2 | 141 | assert select.glob_get_sf(u"**.py", 1)(Path(u"usr/local/bin")) == 2 |
3717 | 141 | assert select.glob_get_sf("/testfiles/select/**.py", 1)(Path("/testfiles/select")) == 2 | 142 | assert select.glob_get_sf(u"/testfiles/select/**.py", 1)(Path(u"/testfiles/select")) == 2 |
3718 | 142 | assert select.glob_get_sf("/testfiles/select/test.py", 1)(Path("/testfiles/select")) == 2 | 143 | assert select.glob_get_sf(u"/testfiles/select/test.py", 1)(Path(u"/testfiles/select")) == 2 |
3719 | 143 | assert select.glob_get_normal_sf("/testfiles/se?ect/test.py", 1)(Path("/testfiles/select")) == 2 | 144 | assert select.glob_get_normal_sf(u"/testfiles/se?ect/test.py", 1)(Path(u"/testfiles/select")) == 2 |
3720 | 144 | assert select.glob_get_sf("/testfiles/select/test.py", 0)(Path("/testfiles/select")) is None | 145 | assert select.glob_get_sf(u"/testfiles/select/test.py", 0)(Path(u"/testfiles/select")) is None |
3721 | 145 | assert select.glob_get_normal_sf("/testfiles/select/test.py", 0)(Path("/testfiles/select")) is None | 146 | assert select.glob_get_normal_sf(u"/testfiles/select/test.py", 0)(Path(u"/testfiles/select")) is None |
3722 | 146 | 147 | ||
3723 | 147 | def test_ignore_case(self): | 148 | def test_ignore_case(self): |
3724 | 148 | """test_ignore_case - try a few expressions with ignorecase:""" | 149 | """test_ignore_case - try a few expressions with ignorecase:""" |
3725 | 149 | 150 | ||
3731 | 150 | sf = self.Select.glob_get_sf("ignorecase:testfiles/SeLect/foo/bar", 1) | 151 | sf = self.Select.glob_get_sf(u"ignorecase:testfiles/SeLect/foo/bar", 1) |
3732 | 151 | assert sf(self.makeext("FOO/BAR")) == 1 | 152 | assert sf(self.makeext(u"FOO/BAR")) == 1 |
3733 | 152 | assert sf(self.makeext("foo/bar")) == 1 | 153 | assert sf(self.makeext(u"foo/bar")) == 1 |
3734 | 153 | assert sf(self.makeext("fOo/BaR")) == 1 | 154 | assert sf(self.makeext(u"fOo/BaR")) == 1 |
3735 | 154 | self.assertRaises(FilePrefixError, self.Select.glob_get_sf, "ignorecase:tesfiles/sect/foo/bar", 1) | 155 | self.assertRaises(FilePrefixError, self.Select.glob_get_sf, u"ignorecase:tesfiles/sect/foo/bar", 1) |
3736 | 155 | 156 | ||
3737 | 156 | def test_root(self): | 157 | def test_root(self): |
3738 | 157 | """test_root - / may be a counterexample to several of these..""" | 158 | """test_root - / may be a counterexample to several of these..""" |
3740 | 158 | root = Path("/") | 159 | root = Path(u"/") |
3741 | 159 | select = Select(root) | 160 | select = Select(root) |
3742 | 160 | 161 | ||
3748 | 161 | self.assertEqual(select.glob_get_sf("/", 1)(root), 1) | 162 | self.assertEqual(select.glob_get_sf(u"/", 1)(root), 1) |
3749 | 162 | self.assertEqual(select.glob_get_sf("/foo", 1)(root), 2) | 163 | self.assertEqual(select.glob_get_sf(u"/foo", 1)(root), 2) |
3750 | 163 | self.assertEqual(select.glob_get_sf("/foo/bar", 1)(root), 2) | 164 | self.assertEqual(select.glob_get_sf(u"/foo/bar", 1)(root), 2) |
3751 | 164 | self.assertEqual(select.glob_get_sf("/", 0)(root), 0) | 165 | self.assertEqual(select.glob_get_sf(u"/", 0)(root), 0) |
3752 | 165 | self.assertEqual(select.glob_get_sf("/foo", 0)(root), None) | 166 | self.assertEqual(select.glob_get_sf(u"/foo", 0)(root), None) |
3753 | 166 | 167 | ||
3760 | 167 | assert select.glob_get_sf("**.py", 1)(root) == 2 | 168 | assert select.glob_get_sf(u"**.py", 1)(root) == 2 |
3761 | 168 | assert select.glob_get_sf("**", 1)(root) == 1 | 169 | assert select.glob_get_sf(u"**", 1)(root) == 1 |
3762 | 169 | assert select.glob_get_sf("ignorecase:/", 1)(root) == 1 | 170 | assert select.glob_get_sf(u"ignorecase:/", 1)(root) == 1 |
3763 | 170 | assert select.glob_get_sf("**.py", 0)(root) is None | 171 | assert select.glob_get_sf(u"**.py", 0)(root) is None |
3764 | 171 | assert select.glob_get_sf("**", 0)(root) == 0 | 172 | assert select.glob_get_sf(u"**", 0)(root) == 0 |
3765 | 172 | assert select.glob_get_sf("/foo/*", 0)(root) is None | 173 | assert select.glob_get_sf(u"/foo/*", 0)(root) is None |
3766 | 173 | 174 | ||
3767 | 174 | def test_other_filesystems(self): | 175 | def test_other_filesystems(self): |
3768 | 175 | """Test to see if --exclude-other-filesystems works correctly""" | 176 | """Test to see if --exclude-other-filesystems works correctly""" |
3770 | 176 | root = Path("/") | 177 | root = Path(u"/") |
3771 | 177 | select = Select(root) | 178 | select = Select(root) |
3772 | 178 | sf = select.other_filesystems_get_sf(0) | 179 | sf = select.other_filesystems_get_sf(0) |
3773 | 179 | assert sf(root) is None | 180 | assert sf(root) is None |
3792 | 180 | if os.path.ismount("/usr/bin"): | 181 | if os.path.ismount(u"/usr/bin"): |
3793 | 181 | sfval = 0 | 182 | sfval = 0 |
3794 | 182 | else: | 183 | else: |
3795 | 183 | sfval = None | 184 | sfval = None |
3796 | 184 | assert sf(Path("/usr/bin")) == sfval, \ | 185 | assert sf(Path(u"/usr/bin")) == sfval, \ |
3797 | 185 | "Assumption: /usr/bin is on the same filesystem as /" | 186 | u"Assumption: /usr/bin is on the same filesystem as /" |
3798 | 186 | if os.path.ismount("/dev"): | 187 | if os.path.ismount(u"/dev"): |
3799 | 187 | sfval = 0 | 188 | sfval = 0 |
3800 | 188 | else: | 189 | else: |
3801 | 189 | sfval = None | 190 | sfval = None |
3802 | 190 | assert sf(Path("/dev")) == sfval, \ | 191 | assert sf(Path(u"/dev")) == sfval, \ |
3803 | 191 | "Assumption: /dev is on a different filesystem" | 192 | u"Assumption: /dev is on a different filesystem" |
3804 | 192 | if os.path.ismount("/proc"): | 193 | if os.path.ismount(u"/proc"): |
3805 | 193 | sfval = 0 | 194 | sfval = 0 |
3806 | 194 | else: | 195 | else: |
3807 | 195 | sfval = None | 196 | sfval = None |
3808 | 196 | assert sf(Path("/proc")) == sfval, \ | 197 | assert sf(Path(u"/proc")) == sfval, \ |
3809 | 197 | "Assumption: /proc is on a different filesystem" | 198 | u"Assumption: /proc is on a different filesystem" |
3810 | 198 | 199 | ||
3811 | 199 | 200 | ||
3812 | 200 | class ParseArgsTest(UnitTestCase): | 201 | class ParseArgsTest(UnitTestCase): |
3813 | @@ -203,24 +204,34 @@ | |||
3814 | 203 | super(ParseArgsTest, self).setUp() | 204 | super(ParseArgsTest, self).setUp() |
3815 | 204 | self.unpack_testfiles() | 205 | self.unpack_testfiles() |
3816 | 205 | self.root = None | 206 | self.root = None |
3826 | 206 | self.expected_restored_tree = [(), ('1',), ('1', '1sub1'), ('1', '1sub1', '1sub1sub1'), | 207 | self.expected_restored_tree = [(), (u"1",), (u"1", u"1sub1"), (u"1", u"1sub1", u"1sub1sub1"), |
3827 | 207 | ('1', '1sub1', '1sub1sub1', '1sub1sub1_file.txt'), ('1', '1sub1', '1sub1sub3'), | 208 | (u"1", u"1sub1", u"1sub1sub1", u"1sub1sub1_file.txt"), |
3828 | 208 | ('1', '1sub2'), ('1', '1sub2', '1sub2sub1'), ('1', '1sub3'), | 209 | (u"1", u"1sub1", u"1sub1sub3"), (u"1", u"1sub2"), (u"1", u"1sub2", u"1sub2sub1"), |
3829 | 209 | ('1', '1sub3', '1sub3sub3'), ('1.py',), ('2',), ('2', '2sub1'), | 210 | (u"1", u"1sub3"), (u"1", u"1sub3", u"1sub3sub3"), (u"1.py",), (u"2",), |
3830 | 210 | ('2', '2sub1', '2sub1sub1'), ('2', '2sub1', '2sub1sub1', '2sub1sub1_file.txt'), | 211 | (u"2", u"2sub1"), (u"2", u"2sub1", u"2sub1sub1"), |
3831 | 211 | ('3',), ('3', '3sub2'), ('3', '3sub2', '3sub2sub1'), | 212 | (u"2", u"2sub1", u"2sub1sub1", u"2sub1sub1_file.txt"), |
3832 | 212 | ('3', '3sub2', '3sub2sub2'), ('3', '3sub2', '3sub2sub3'), ('3', '3sub3'), | 213 | (u"3",), (u"3", u"3sub2"), (u"3", u"3sub2", u"3sub2sub1"), |
3833 | 213 | ('3', '3sub3', '3sub3sub1'), ('3', '3sub3', '3sub3sub2'), | 214 | (u"3", u"3sub2", u"3sub2sub2"), (u"3", u"3sub2", u"3sub2sub3"), (u"3", u"3sub3"), |
3834 | 214 | ('3', '3sub3', '3sub3sub2', '3sub3sub2_file.txt'), ('3', '3sub3', '3sub3sub3')] | 215 | (u"3", u"3sub3", u"3sub3sub1"), (u"3", u"3sub3", u"3sub3sub2"), |
3835 | 216 | (u"3", u"3sub3", u"3sub3sub2", u"3sub3sub2_file.txt"), | ||
3836 | 217 | (u"3", u"3sub3", u"3sub3sub3")] | ||
3837 | 218 | |||
3838 | 219 | def uc_index_from_path(self, path): | ||
3839 | 220 | """Takes a path type and returns path.index, with each element converted into unicode""" | ||
3840 | 221 | uindex = tuple([element.decode(sys.getfilesystemencoding(), "strict") for element in path.index]) | ||
3841 | 222 | return uindex | ||
3842 | 215 | 223 | ||
3843 | 216 | def ParseTest(self, tuplelist, indicies, filelists=[]): | 224 | def ParseTest(self, tuplelist, indicies, filelists=[]): |
3844 | 217 | """No error if running select on tuple goes over indicies""" | 225 | """No error if running select on tuple goes over indicies""" |
3845 | 218 | if not self.root: | 226 | if not self.root: |
3847 | 219 | self.root = Path("testfiles/select") | 227 | self.root = Path(u"testfiles/select") |
3848 | 220 | self.Select = Select(self.root) | 228 | self.Select = Select(self.root) |
3849 | 221 | self.Select.ParseArgs(tuplelist, self.remake_filelists(filelists)) | 229 | self.Select.ParseArgs(tuplelist, self.remake_filelists(filelists)) |
3850 | 222 | self.Select.set_iter() | 230 | self.Select.set_iter() |
3852 | 223 | results_as_list = list(Iter.map(lambda path: path.index, self.Select)) | 231 | |
3853 | 232 | # Create a list of the paths returned by the select function, converted | ||
3854 | 233 | # into path.index styled tuples | ||
3855 | 234 | results_as_list = list(Iter.map(self.uc_index_from_path, self.Select)) | ||
3856 | 224 | # print(results_as_list) | 235 | # print(results_as_list) |
3857 | 225 | self.assertEqual(indicies, results_as_list) | 236 | self.assertEqual(indicies, results_as_list) |
3858 | 226 | 237 | ||
3859 | @@ -228,7 +239,7 @@ | |||
3860 | 228 | """Turn strings in filelist into fileobjs""" | 239 | """Turn strings in filelist into fileobjs""" |
3861 | 229 | new_filelists = [] | 240 | new_filelists = [] |
3862 | 230 | for f in filelist: | 241 | for f in filelist: |
3864 | 231 | if isinstance(f, types.StringType): | 242 | if isinstance(f, unicode): |
3865 | 232 | new_filelists.append(StringIO.StringIO(f)) | 243 | new_filelists.append(StringIO.StringIO(f)) |
3866 | 233 | else: | 244 | else: |
3867 | 234 | new_filelists.append(f) | 245 | new_filelists.append(f) |
3868 | @@ -236,629 +247,645 @@ | |||
3869 | 236 | 247 | ||
3870 | 237 | def test_parse(self): | 248 | def test_parse(self): |
3871 | 238 | """Test just one include, all exclude""" | 249 | """Test just one include, all exclude""" |
3876 | 239 | self.ParseTest([("--include", "testfiles/select/1/1"), | 250 | self.ParseTest([(u"--include", u"testfiles/select/1/1"), |
3877 | 240 | ("--exclude", "**")], | 251 | (u"--exclude", u"**")], |
3878 | 241 | [(), ('1',), ("1", "1"), ("1", '1', '1'), | 252 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"), |
3879 | 242 | ('1', '1', '2'), ('1', '1', '3')]) | 253 | (u"1", u"1", u"2"), (u"1", u"1", u"3")]) |
3880 | 243 | 254 | ||
3881 | 244 | def test_parse2(self): | 255 | def test_parse2(self): |
3882 | 245 | """Test three level include/exclude""" | 256 | """Test three level include/exclude""" |
3889 | 246 | self.ParseTest([("--exclude", "testfiles/select/1/1/1"), | 257 | self.ParseTest([(u"--exclude", u"testfiles/select/1/1/1"), |
3890 | 247 | ("--include", "testfiles/select/1/1"), | 258 | (u"--include", u"testfiles/select/1/1"), |
3891 | 248 | ("--exclude", "testfiles/select/1"), | 259 | (u"--exclude", u"testfiles/select/1"), |
3892 | 249 | ("--exclude", "**")], | 260 | (u"--exclude", u"**")], |
3893 | 250 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 261 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3894 | 251 | ('1', '1', '3')]) | 262 | (u"1", u"1", u"3")]) |
3895 | 252 | 263 | ||
3896 | 253 | def test_filelist(self): | 264 | def test_filelist(self): |
3897 | 254 | """Filelist glob test similar to above testParse2""" | 265 | """Filelist glob test similar to above testParse2""" |
3905 | 255 | self.ParseTest([("--include-filelist", "file")], | 266 | self.ParseTest([(u"--include-filelist", u"file")], |
3906 | 256 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 267 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3907 | 257 | ('1', '1', '3')], | 268 | (u"1", u"1", u"3")], |
3908 | 258 | ["- testfiles/select/1/1/1\n" | 269 | [u"- testfiles/select/1/1/1\n" |
3909 | 259 | "testfiles/select/1/1\n" | 270 | u"testfiles/select/1/1\n" |
3910 | 260 | "- testfiles/select/1\n" | 271 | u"- testfiles/select/1\n" |
3911 | 261 | "- **"]) | 272 | u"- **"]) |
3912 | 262 | 273 | ||
3913 | 263 | def test_include_filelist_1_trailing_whitespace(self): | 274 | def test_include_filelist_1_trailing_whitespace(self): |
3914 | 264 | """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on include""" | 275 | """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on include""" |
3922 | 265 | self.ParseTest([("--include-filelist", "file")], | 276 | self.ParseTest([(u"--include-filelist", u"file")], |
3923 | 266 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 277 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3924 | 267 | ('1', '1', '3')], | 278 | (u"1", u"1", u"3")], |
3925 | 268 | ["- testfiles/select/1/1/1\n" | 279 | [u"- testfiles/select/1/1/1\n" |
3926 | 269 | "testfiles/select/1/1 \n" | 280 | u"testfiles/select/1/1 \n" |
3927 | 270 | "- testfiles/select/1\n" | 281 | u"- testfiles/select/1\n" |
3928 | 271 | "- **"]) | 282 | u"- **"]) |
3929 | 272 | 283 | ||
3930 | 273 | def test_include_filelist_2_trailing_whitespaces(self): | 284 | def test_include_filelist_2_trailing_whitespaces(self): |
3931 | 274 | """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on include""" | 285 | """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on include""" |
3939 | 275 | self.ParseTest([("--include-filelist", "file")], | 286 | self.ParseTest([(u"--include-filelist", u"file")], |
3940 | 276 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 287 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3941 | 277 | ('1', '1', '3')], | 288 | (u"1", u"1", u"3")], |
3942 | 278 | ["- testfiles/select/1/1/1\n" | 289 | [u"- testfiles/select/1/1/1\n" |
3943 | 279 | "testfiles/select/1/1 \n" | 290 | u"testfiles/select/1/1 \n" |
3944 | 280 | "- testfiles/select/1\n" | 291 | u"- testfiles/select/1\n" |
3945 | 281 | "- **"]) | 292 | u"- **"]) |
3946 | 282 | 293 | ||
3947 | 283 | def test_include_filelist_1_leading_whitespace(self): | 294 | def test_include_filelist_1_leading_whitespace(self): |
3948 | 284 | """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on include""" | 295 | """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on include""" |
3956 | 285 | self.ParseTest([("--include-filelist", "file")], | 296 | self.ParseTest([(u"--include-filelist", u"file")], |
3957 | 286 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 297 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3958 | 287 | ('1', '1', '3')], | 298 | (u"1", u"1", u"3")], |
3959 | 288 | ["- testfiles/select/1/1/1\n" | 299 | [u"- testfiles/select/1/1/1\n" |
3960 | 289 | " testfiles/select/1/1\n" | 300 | u" testfiles/select/1/1\n" |
3961 | 290 | "- testfiles/select/1\n" | 301 | u"- testfiles/select/1\n" |
3962 | 291 | "- **"]) | 302 | u"- **"]) |
3963 | 292 | 303 | ||
3964 | 293 | def test_include_filelist_2_leading_whitespaces(self): | 304 | def test_include_filelist_2_leading_whitespaces(self): |
3965 | 294 | """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on include""" | 305 | """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on include""" |
3973 | 295 | self.ParseTest([("--include-filelist", "file")], | 306 | self.ParseTest([(u"--include-filelist", u"file")], |
3974 | 296 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 307 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3975 | 297 | ('1', '1', '3')], | 308 | (u"1", u"1", u"3")], |
3976 | 298 | ["- testfiles/select/1/1/1\n" | 309 | [u"- testfiles/select/1/1/1\n" |
3977 | 299 | " testfiles/select/1/1\n" | 310 | u" testfiles/select/1/1\n" |
3978 | 300 | "- testfiles/select/1\n" | 311 | u"- testfiles/select/1\n" |
3979 | 301 | "- **"]) | 312 | u"- **"]) |
3980 | 302 | 313 | ||
3981 | 303 | def test_include_filelist_1_trailing_whitespace_exclude(self): | 314 | def test_include_filelist_1_trailing_whitespace_exclude(self): |
3982 | 304 | """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on exclude""" | 315 | """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on exclude""" |
3990 | 305 | self.ParseTest([("--include-filelist", "file")], | 316 | self.ParseTest([(u"--include-filelist", u"file")], |
3991 | 306 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 317 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
3992 | 307 | ('1', '1', '3')], | 318 | (u"1", u"1", u"3")], |
3993 | 308 | ["- testfiles/select/1/1/1 \n" | 319 | [u"- testfiles/select/1/1/1 \n" |
3994 | 309 | "testfiles/select/1/1\n" | 320 | u"testfiles/select/1/1\n" |
3995 | 310 | "- testfiles/select/1\n" | 321 | u"- testfiles/select/1\n" |
3996 | 311 | "- **"]) | 322 | u"- **"]) |
3997 | 312 | 323 | ||
3998 | 313 | def test_include_filelist_2_trailing_whitespace_exclude(self): | 324 | def test_include_filelist_2_trailing_whitespace_exclude(self): |
3999 | 314 | """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on exclude""" | 325 | """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on exclude""" |
4007 | 315 | self.ParseTest([("--include-filelist", "file")], | 326 | self.ParseTest([(u"--include-filelist", u"file")], |
4008 | 316 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 327 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4009 | 317 | ('1', '1', '3')], | 328 | (u"1", u"1", u"3")], |
4010 | 318 | ["- testfiles/select/1/1/1 \n" | 329 | [u"- testfiles/select/1/1/1 \n" |
4011 | 319 | "testfiles/select/1/1\n" | 330 | u"testfiles/select/1/1\n" |
4012 | 320 | "- testfiles/select/1\n" | 331 | u"- testfiles/select/1\n" |
4013 | 321 | "- **"]) | 332 | u"- **"]) |
4014 | 322 | 333 | ||
4015 | 323 | def test_include_filelist_1_leading_whitespace_exclude(self): | 334 | def test_include_filelist_1_leading_whitespace_exclude(self): |
4016 | 324 | """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on exclude""" | 335 | """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on exclude""" |
4024 | 325 | self.ParseTest([("--include-filelist", "file")], | 336 | self.ParseTest([(u"--include-filelist", u"file")], |
4025 | 326 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 337 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4026 | 327 | ('1', '1', '3')], | 338 | (u"1", u"1", u"3")], |
4027 | 328 | [" - testfiles/select/1/1/1\n" | 339 | [u" - testfiles/select/1/1/1\n" |
4028 | 329 | "testfiles/select/1/1\n" | 340 | u"testfiles/select/1/1\n" |
4029 | 330 | "- testfiles/select/1\n" | 341 | u"- testfiles/select/1\n" |
4030 | 331 | "- **"]) | 342 | u"- **"]) |
4031 | 332 | 343 | ||
4032 | 333 | def test_include_filelist_2_leading_whitespaces_exclude(self): | 344 | def test_include_filelist_2_leading_whitespaces_exclude(self): |
4033 | 334 | """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on exclude""" | 345 | """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on exclude""" |
4041 | 335 | self.ParseTest([("--include-filelist", "file")], | 346 | self.ParseTest([(u"--include-filelist", u"file")], |
4042 | 336 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 347 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4043 | 337 | ('1', '1', '3')], | 348 | (u"1", u"1", u"3")], |
4044 | 338 | [" - testfiles/select/1/1/1\n" | 349 | [u" - testfiles/select/1/1/1\n" |
4045 | 339 | "testfiles/select/1/1\n" | 350 | u"testfiles/select/1/1\n" |
4046 | 340 | "- testfiles/select/1\n" | 351 | u"- testfiles/select/1\n" |
4047 | 341 | "- **"]) | 352 | u"- **"]) |
4048 | 342 | 353 | ||
4049 | 343 | def test_include_filelist_check_excluded_folder_included_for_contents(self): | 354 | def test_include_filelist_check_excluded_folder_included_for_contents(self): |
4050 | 344 | """Filelist glob test to check excluded folder is included if contents are""" | 355 | """Filelist glob test to check excluded folder is included if contents are""" |
4059 | 345 | self.ParseTest([("--include-filelist", "file")], | 356 | self.ParseTest([(u"--include-filelist", u"file")], |
4060 | 346 | [(), ('1',), ('1', '1'), ('1', '1', '1'), ('1', '1', '2'), | 357 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"), (u"1", u"1", u"2"), |
4061 | 347 | ('1', '1', '3'), ('1', '2'), ('1', '2', '1'), ('1', '3'), ('1', '3', '1'), ('1', '3', '2'), | 358 | (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"), |
4062 | 348 | ('1', '3', '3')], | 359 | (u"1", u"3", u"2"), (u"1", u"3", u"3")], |
4063 | 349 | ["+ testfiles/select/1/2/1\n" | 360 | [u"+ testfiles/select/1/2/1\n" |
4064 | 350 | "- testfiles/select/1/2\n" | 361 | u"- testfiles/select/1/2\n" |
4065 | 351 | "testfiles/select/1\n" | 362 | u"testfiles/select/1\n" |
4066 | 352 | "- **"]) | 363 | u"- **"]) |
4067 | 353 | 364 | ||
4068 | 354 | def test_include_filelist_with_unnecessary_quotes(self): | 365 | def test_include_filelist_with_unnecessary_quotes(self): |
4069 | 355 | """Filelist glob test similar to globbing filelist, but with quotes around one of the paths.""" | 366 | """Filelist glob test similar to globbing filelist, but with quotes around one of the paths.""" |
4077 | 356 | self.ParseTest([("--include-filelist", "file")], | 367 | self.ParseTest([(u"--include-filelist", u"file")], |
4078 | 357 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 368 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4079 | 358 | ('1', '1', '3')], | 369 | (u"1", u"1", u"3")], |
4080 | 359 | ["- 'testfiles/select/1/1/1'\n" | 370 | [u"- 'testfiles/select/1/1/1'\n" |
4081 | 360 | "testfiles/select/1/1\n" | 371 | u"testfiles/select/1/1\n" |
4082 | 361 | "- testfiles/select/1\n" | 372 | u"- testfiles/select/1\n" |
4083 | 362 | "- **"]) | 373 | u"- **"]) |
4084 | 363 | 374 | ||
4085 | 364 | def test_include_filelist_with_unnecessary_double_quotes(self): | 375 | def test_include_filelist_with_unnecessary_double_quotes(self): |
4086 | 365 | """Filelist glob test similar to globbing filelist, but with double quotes around one of the paths.""" | 376 | """Filelist glob test similar to globbing filelist, but with double quotes around one of the paths.""" |
4094 | 366 | self.ParseTest([("--include-filelist", "file")], | 377 | self.ParseTest([(u"--include-filelist", u"file")], |
4095 | 367 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 378 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4096 | 368 | ('1', '1', '3')], | 379 | (u"1", u"1", u"3")], |
4097 | 369 | ['- "testfiles/select/1/1/1"\n' | 380 | [u'- "testfiles/select/1/1/1"\n' |
4098 | 370 | 'testfiles/select/1/1\n' | 381 | u"testfiles/select/1/1\n" |
4099 | 371 | '- testfiles/select/1\n' | 382 | u"- testfiles/select/1\n" |
4100 | 372 | '- **']) | 383 | u"- **"]) |
4101 | 373 | 384 | ||
4102 | 374 | def test_include_filelist_with_full_line_comment(self): | 385 | def test_include_filelist_with_full_line_comment(self): |
4103 | 375 | """Filelist glob test similar to globbing filelist, but with a full-line comment.""" | 386 | """Filelist glob test similar to globbing filelist, but with a full-line comment.""" |
4112 | 376 | self.ParseTest([("--include-filelist", "file")], | 387 | self.ParseTest([(u"--include-filelist", u"file")], |
4113 | 377 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 388 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4114 | 378 | ('1', '1', '3')], | 389 | (u"1", u"1", u"3")], |
4115 | 379 | ['- testfiles/select/1/1/1\n' | 390 | [u"- testfiles/select/1/1/1\n" |
4116 | 380 | '# This is a test\n' | 391 | u"# This is a test\n" |
4117 | 381 | 'testfiles/select/1/1\n' | 392 | u"testfiles/select/1/1\n" |
4118 | 382 | '- testfiles/select/1\n' | 393 | u"- testfiles/select/1\n" |
4119 | 383 | '- **']) | 394 | u"- **"]) |
4120 | 384 | 395 | ||
4121 | 385 | def test_include_filelist_with_blank_line(self): | 396 | def test_include_filelist_with_blank_line(self): |
4122 | 386 | """Filelist glob test similar to globbing filelist, but with a blank line.""" | 397 | """Filelist glob test similar to globbing filelist, but with a blank line.""" |
4131 | 387 | self.ParseTest([("--include-filelist", "file")], | 398 | self.ParseTest([(u"--include-filelist", u"file")], |
4132 | 388 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 399 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4133 | 389 | ('1', '1', '3')], | 400 | (u"1", u"1", u"3")], |
4134 | 390 | ['- testfiles/select/1/1/1\n' | 401 | [u"- testfiles/select/1/1/1\n" |
4135 | 391 | '\n' | 402 | u"\n" |
4136 | 392 | 'testfiles/select/1/1\n' | 403 | u"testfiles/select/1/1\n" |
4137 | 393 | '- testfiles/select/1\n' | 404 | u"- testfiles/select/1\n" |
4138 | 394 | '- **']) | 405 | u"- **"]) |
4139 | 395 | 406 | ||
4140 | 396 | def test_include_filelist_with_blank_line_and_whitespace(self): | 407 | def test_include_filelist_with_blank_line_and_whitespace(self): |
4141 | 397 | """Filelist glob test similar to globbing filelist, but with a blank line and whitespace.""" | 408 | """Filelist glob test similar to globbing filelist, but with a blank line and whitespace.""" |
4150 | 398 | self.ParseTest([("--include-filelist", "file")], | 409 | self.ParseTest([(u"--include-filelist", u"file")], |
4151 | 399 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 410 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4152 | 400 | ('1', '1', '3')], | 411 | (u"1", u"1", u"3")], |
4153 | 401 | ['- testfiles/select/1/1/1\n' | 412 | [u"- testfiles/select/1/1/1\n" |
4154 | 402 | ' \n' | 413 | u" \n" |
4155 | 403 | 'testfiles/select/1/1\n' | 414 | u"testfiles/select/1/1\n" |
4156 | 404 | '- testfiles/select/1\n' | 415 | u"- testfiles/select/1\n" |
4157 | 405 | '- **']) | 416 | u"- **"]) |
4158 | 406 | 417 | ||
4159 | 407 | def test_include_filelist_asterisk(self): | 418 | def test_include_filelist_asterisk(self): |
4160 | 408 | """Filelist glob test with * instead of 'testfiles'""" | 419 | """Filelist glob test with * instead of 'testfiles'""" |
4161 | 409 | # Thank you to Elifarley Cruz for this test case | 420 | # Thank you to Elifarley Cruz for this test case |
4162 | 410 | # (https://bugs.launchpad.net/duplicity/+bug/884371). | 421 | # (https://bugs.launchpad.net/duplicity/+bug/884371). |
4168 | 411 | self.ParseTest([("--include-filelist", "file")], | 422 | self.ParseTest([(u"--include-filelist", u"file")], |
4169 | 412 | [(), ('1',), ('1', '1'), ('1', '1', '1'), | 423 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"), |
4170 | 413 | ('1', '1', '2'), ('1', '1', '3')], | 424 | (u"1", u"1", u"2"), (u"1", u"1", u"3")], |
4171 | 414 | ["*/select/1/1\n" | 425 | [u"*/select/1/1\n" |
4172 | 415 | "- **"]) | 426 | u"- **"]) |
4173 | 416 | 427 | ||
4174 | 417 | def test_include_filelist_asterisk_2(self): | 428 | def test_include_filelist_asterisk_2(self): |
4183 | 418 | """Identical to test_filelist, but with the exclude 'select' replaced with '*'""" | 429 | """Identical to test_filelist, but with the exclude "select" replaced with '*'""" |
4184 | 419 | self.ParseTest([("--include-filelist", "file")], | 430 | self.ParseTest([(u"--include-filelist", u"file")], |
4185 | 420 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 431 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4186 | 421 | ('1', '1', '3')], | 432 | (u"1", u"1", u"3")], |
4187 | 422 | ["- testfiles/*/1/1/1\n" | 433 | [u"- testfiles/*/1/1/1\n" |
4188 | 423 | "testfiles/select/1/1\n" | 434 | u"testfiles/select/1/1\n" |
4189 | 424 | "- testfiles/select/1\n" | 435 | u"- testfiles/select/1\n" |
4190 | 425 | "- **"]) | 436 | u"- **"]) |
4191 | 426 | 437 | ||
4192 | 427 | def test_include_filelist_asterisk_3(self): | 438 | def test_include_filelist_asterisk_3(self): |
4194 | 428 | """Identical to test_filelist, but with the auto-include 'select' replaced with '*'""" | 439 | """Identical to test_filelist, but with the auto-include "select" replaced with '*'""" |
4195 | 429 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 440 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4203 | 430 | self.ParseTest([("--include-filelist", "file")], | 441 | self.ParseTest([(u"--include-filelist", u"file")], |
4204 | 431 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 442 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4205 | 432 | ('1', '1', '3')], | 443 | (u"1", u"1", u"3")], |
4206 | 433 | ["- testfiles/select/1/1/1\n" | 444 | [u"- testfiles/select/1/1/1\n" |
4207 | 434 | "testfiles/*/1/1\n" | 445 | u"testfiles/*/1/1\n" |
4208 | 435 | "- testfiles/select/1\n" | 446 | u"- testfiles/select/1\n" |
4209 | 436 | "- **"]) | 447 | u"- **"]) |
4210 | 437 | 448 | ||
4211 | 438 | def test_include_filelist_asterisk_4(self): | 449 | def test_include_filelist_asterisk_4(self): |
4213 | 439 | """Identical to test_filelist, but with a specific include 'select' replaced with '*'""" | 450 | """Identical to test_filelist, but with a specific include "select" replaced with '*'""" |
4214 | 440 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 451 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4222 | 441 | self.ParseTest([("--include-filelist", "file")], | 452 | self.ParseTest([(u"--include-filelist", u"file")], |
4223 | 442 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 453 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4224 | 443 | ('1', '1', '3')], | 454 | (u"1", u"1", u"3")], |
4225 | 444 | ["- testfiles/select/1/1/1\n" | 455 | [u"- testfiles/select/1/1/1\n" |
4226 | 445 | "+ testfiles/*/1/1\n" | 456 | u"+ testfiles/*/1/1\n" |
4227 | 446 | "- testfiles/select/1\n" | 457 | u"- testfiles/select/1\n" |
4228 | 447 | "- **"]) | 458 | u"- **"]) |
4229 | 448 | 459 | ||
4230 | 449 | def test_include_filelist_asterisk_5(self): | 460 | def test_include_filelist_asterisk_5(self): |
4231 | 450 | """Identical to test_filelist, but with all 'select's replaced with '*'""" | 461 | """Identical to test_filelist, but with all 'select's replaced with '*'""" |
4232 | 451 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 462 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4240 | 452 | self.ParseTest([("--include-filelist", "file")], | 463 | self.ParseTest([(u"--include-filelist", u"file")], |
4241 | 453 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 464 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4242 | 454 | ('1', '1', '3')], | 465 | (u"1", u"1", u"3")], |
4243 | 455 | ["- testfiles/*/1/1/1\n" | 466 | [u"- testfiles/*/1/1/1\n" |
4244 | 456 | "+ testfiles/*/1/1\n" | 467 | u"+ testfiles/*/1/1\n" |
4245 | 457 | "- testfiles/*/1\n" | 468 | u"- testfiles/*/1\n" |
4246 | 458 | "- **"]) | 469 | u"- **"]) |
4247 | 459 | 470 | ||
4248 | 460 | def test_include_filelist_asterisk_6(self): | 471 | def test_include_filelist_asterisk_6(self): |
4249 | 461 | """Identical to test_filelist, but with numerous excluded folders replaced with '*'""" | 472 | """Identical to test_filelist, but with numerous excluded folders replaced with '*'""" |
4257 | 462 | self.ParseTest([("--include-filelist", "file")], | 473 | self.ParseTest([(u"--include-filelist", u"file")], |
4258 | 463 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 474 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4259 | 464 | ('1', '1', '3')], | 475 | (u"1", u"1", u"3")], |
4260 | 465 | ["- */*/1/1/1\n" | 476 | [u"- */*/1/1/1\n" |
4261 | 466 | "+ testfiles/select/1/1\n" | 477 | u"+ testfiles/select/1/1\n" |
4262 | 467 | "- */*/1\n" | 478 | u"- */*/1\n" |
4263 | 468 | "- **"]) | 479 | u"- **"]) |
4264 | 469 | 480 | ||
4265 | 470 | def test_include_filelist_asterisk_7(self): | 481 | def test_include_filelist_asterisk_7(self): |
4266 | 471 | """Identical to test_filelist, but with numerous included/excluded folders replaced with '*'""" | 482 | """Identical to test_filelist, but with numerous included/excluded folders replaced with '*'""" |
4267 | 472 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 483 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4275 | 473 | self.ParseTest([("--include-filelist", "file")], | 484 | self.ParseTest([(u"--include-filelist", u"file")], |
4276 | 474 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 485 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4277 | 475 | ('1', '1', '3')], | 486 | (u"1", u"1", u"3")], |
4278 | 476 | ["- */*/1/1/1\n" | 487 | [u"- */*/1/1/1\n" |
4279 | 477 | "+ */*/1/1\n" | 488 | u"+ */*/1/1\n" |
4280 | 478 | "- */*/1\n" | 489 | u"- */*/1\n" |
4281 | 479 | "- **"]) | 490 | u"- **"]) |
4282 | 480 | 491 | ||
4283 | 481 | def test_include_filelist_double_asterisk_1(self): | 492 | def test_include_filelist_double_asterisk_1(self): |
4292 | 482 | """Identical to test_filelist, but with the exclude 'select' replaced with '**'""" | 493 | """Identical to test_filelist, but with the exclude "select' replaced with '**'""" |
4293 | 483 | self.ParseTest([("--include-filelist", "file")], | 494 | self.ParseTest([(u"--include-filelist", u"file")], |
4294 | 484 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 495 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4295 | 485 | ('1', '1', '3')], | 496 | (u"1", u"1", u"3")], |
4296 | 486 | ["- testfiles/**/1/1/1\n" | 497 | [u"- testfiles/**/1/1/1\n" |
4297 | 487 | "testfiles/select/1/1\n" | 498 | u"testfiles/select/1/1\n" |
4298 | 488 | "- testfiles/select/1\n" | 499 | u"- testfiles/select/1\n" |
4299 | 489 | "- **"]) | 500 | u"- **"]) |
4300 | 490 | 501 | ||
4301 | 491 | def test_include_filelist_double_asterisk_2(self): | 502 | def test_include_filelist_double_asterisk_2(self): |
4302 | 492 | """Identical to test_filelist, but with the include 'select' replaced with '**'""" | 503 | """Identical to test_filelist, but with the include 'select' replaced with '**'""" |
4303 | 493 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 504 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4311 | 494 | self.ParseTest([("--include-filelist", "file")], | 505 | self.ParseTest([(u"--include-filelist", u"file")], |
4312 | 495 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 506 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4313 | 496 | ('1', '1', '3')], | 507 | (u"1", u"1", u"3")], |
4314 | 497 | ["- testfiles/select/1/1/1\n" | 508 | [u"- testfiles/select/1/1/1\n" |
4315 | 498 | "**ct/1/1\n" | 509 | u"**ct/1/1\n" |
4316 | 499 | "- testfiles/select/1\n" | 510 | u"- testfiles/select/1\n" |
4317 | 500 | "- **"]) | 511 | u"- **"]) |
4318 | 501 | 512 | ||
4319 | 502 | def test_include_filelist_double_asterisk_3(self): | 513 | def test_include_filelist_double_asterisk_3(self): |
4320 | 503 | """Identical to test_filelist, but with the exclude 'testfiles/select' replaced with '**'""" | 514 | """Identical to test_filelist, but with the exclude 'testfiles/select' replaced with '**'""" |
4328 | 504 | self.ParseTest([("--include-filelist", "file")], | 515 | self.ParseTest([(u"--include-filelist", u"file")], |
4329 | 505 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 516 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4330 | 506 | ('1', '1', '3')], | 517 | (u"1", u"1", u"3")], |
4331 | 507 | ["- **/1/1/1\n" | 518 | [u"- **/1/1/1\n" |
4332 | 508 | "testfiles/select/1/1\n" | 519 | u"testfiles/select/1/1\n" |
4333 | 509 | "- testfiles/select/1\n" | 520 | u"- testfiles/select/1\n" |
4334 | 510 | "- **"]) | 521 | u"- **"]) |
4335 | 511 | 522 | ||
4336 | 512 | def test_include_filelist_double_asterisk_4(self): | 523 | def test_include_filelist_double_asterisk_4(self): |
4337 | 513 | """Identical to test_filelist, but with the include 'testfiles/select' replaced with '**'""" | 524 | """Identical to test_filelist, but with the include 'testfiles/select' replaced with '**'""" |
4338 | 514 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 525 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4346 | 515 | self.ParseTest([("--include-filelist", "file")], | 526 | self.ParseTest([(u"--include-filelist", u"file")], |
4347 | 516 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 527 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4348 | 517 | ('1', '1', '3')], | 528 | (u"1", u"1", u"3")], |
4349 | 518 | ["- testfiles/select/1/1/1\n" | 529 | [u"- testfiles/select/1/1/1\n" |
4350 | 519 | "**t/1/1\n" | 530 | u"**t/1/1\n" |
4351 | 520 | "- testfiles/select/1\n" | 531 | u"- testfiles/select/1\n" |
4352 | 521 | "- **"]) | 532 | u"- **"]) |
4353 | 522 | 533 | ||
4354 | 523 | def test_include_filelist_double_asterisk_5(self): | 534 | def test_include_filelist_double_asterisk_5(self): |
4355 | 524 | """Identical to test_filelist, but with all 'testfiles/select's replaced with '**'""" | 535 | """Identical to test_filelist, but with all 'testfiles/select's replaced with '**'""" |
4356 | 525 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 536 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4364 | 526 | self.ParseTest([("--include-filelist", "file")], | 537 | self.ParseTest([(u"--include-filelist", u"file")], |
4365 | 527 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 538 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4366 | 528 | ('1', '1', '3')], | 539 | (u"1", u"1", u"3")], |
4367 | 529 | ["- **/1/1/1\n" | 540 | [u"- **/1/1/1\n" |
4368 | 530 | "**t/1/1\n" | 541 | u"**t/1/1\n" |
4369 | 531 | "- **t/1\n" | 542 | u"- **t/1\n" |
4370 | 532 | "- **"]) | 543 | u"- **"]) |
4371 | 533 | 544 | ||
4372 | 534 | def test_include_filelist_trailing_slashes(self): | 545 | def test_include_filelist_trailing_slashes(self): |
4373 | 535 | """Filelist glob test similar to globbing filelist, but with trailing slashes""" | 546 | """Filelist glob test similar to globbing filelist, but with trailing slashes""" |
4381 | 536 | self.ParseTest([("--include-filelist", "file")], | 547 | self.ParseTest([(u"--include-filelist", u"file")], |
4382 | 537 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 548 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4383 | 538 | ('1', '1', '3')], | 549 | (u"1", u"1", u"3")], |
4384 | 539 | ["- testfiles/select/1/1/1/\n" | 550 | [u"- testfiles/select/1/1/1/\n" |
4385 | 540 | "testfiles/select/1/1/\n" | 551 | u"testfiles/select/1/1/\n" |
4386 | 541 | "- testfiles/select/1/\n" | 552 | u"- testfiles/select/1/\n" |
4387 | 542 | "- **"]) | 553 | u"- **"]) |
4388 | 543 | 554 | ||
4389 | 544 | def test_include_filelist_trailing_slashes_and_single_asterisks(self): | 555 | def test_include_filelist_trailing_slashes_and_single_asterisks(self): |
4390 | 545 | """Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks""" | 556 | """Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks""" |
4391 | 546 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) | 557 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) |
4399 | 547 | self.ParseTest([("--include-filelist", "file")], | 558 | self.ParseTest([(u"--include-filelist", u"file")], |
4400 | 548 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 559 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4401 | 549 | ('1', '1', '3')], | 560 | (u"1", u"1", u"3")], |
4402 | 550 | ["- */select/1/1/1/\n" | 561 | [u"- */select/1/1/1/\n" |
4403 | 551 | "testfiles/select/1/1/\n" | 562 | u"testfiles/select/1/1/\n" |
4404 | 552 | "- testfiles/*/1/\n" | 563 | u"- testfiles/*/1/\n" |
4405 | 553 | "- **"]) | 564 | u"- **"]) |
4406 | 554 | 565 | ||
4407 | 555 | def test_include_filelist_trailing_slashes_and_double_asterisks(self): | 566 | def test_include_filelist_trailing_slashes_and_double_asterisks(self): |
4408 | 556 | """Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks""" | 567 | """Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks""" |
4409 | 557 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) | 568 | # Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) |
4417 | 558 | self.ParseTest([("--include-filelist", "file")], | 569 | self.ParseTest([(u"--include-filelist", u"file")], |
4418 | 559 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 570 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4419 | 560 | ('1', '1', '3')], | 571 | (u"1", u"1", u"3")], |
4420 | 561 | ["- **/1/1/1/\n" | 572 | [u"- **/1/1/1/\n" |
4421 | 562 | "testfiles/select/1/1/\n" | 573 | u"testfiles/select/1/1/\n" |
4422 | 563 | "- **t/1/\n" | 574 | u"- **t/1/\n" |
4423 | 564 | "- **"]) | 575 | u"- **"]) |
4424 | 565 | 576 | ||
4425 | 566 | def test_filelist_null_separator(self): | 577 | def test_filelist_null_separator(self): |
4426 | 567 | """test_filelist, but with null_separator set""" | 578 | """test_filelist, but with null_separator set""" |
4432 | 568 | self.set_global('null_separator', 1) | 579 | self.set_global(u"null_separator", 1) |
4433 | 569 | self.ParseTest([("--include-filelist", "file")], | 580 | self.ParseTest([(u"--include-filelist", u"file")], |
4434 | 570 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 581 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4435 | 571 | ('1', '1', '3')], | 582 | (u"1", u"1", u"3")], |
4436 | 572 | ["\0- testfiles/select/1/1/1\0testfiles/select/1/1\0- testfiles/select/1\0- **\0"]) | 583 | [u"\0- testfiles/select/1/1/1\0testfiles/select/1/1\0- testfiles/select/1\0- **\0"]) |
4437 | 573 | 584 | ||
4438 | 574 | def test_exclude_filelist(self): | 585 | def test_exclude_filelist(self): |
4439 | 575 | """Exclude version of test_filelist""" | 586 | """Exclude version of test_filelist""" |
4447 | 576 | self.ParseTest([("--exclude-filelist", "file")], | 587 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4448 | 577 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 588 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4449 | 578 | ('1', '1', '3')], | 589 | (u"1", u"1", u"3")], |
4450 | 579 | ["testfiles/select/1/1/1\n" | 590 | [u"testfiles/select/1/1/1\n" |
4451 | 580 | "+ testfiles/select/1/1\n" | 591 | u"+ testfiles/select/1/1\n" |
4452 | 581 | "testfiles/select/1\n" | 592 | u"testfiles/select/1\n" |
4453 | 582 | "- **"]) | 593 | u"- **"]) |
4454 | 583 | 594 | ||
4455 | 584 | def test_exclude_filelist_asterisk_1(self): | 595 | def test_exclude_filelist_asterisk_1(self): |
4456 | 585 | """Exclude version of test_include_filelist_asterisk""" | 596 | """Exclude version of test_include_filelist_asterisk""" |
4462 | 586 | self.ParseTest([("--exclude-filelist", "file")], | 597 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4463 | 587 | [(), ('1',), ('1', '1'), ('1', '1', '1'), | 598 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"1"), |
4464 | 588 | ('1', '1', '2'), ('1', '1', '3')], | 599 | (u"1", u"1", u"2"), (u"1", u"1", u"3")], |
4465 | 589 | ["+ */select/1/1\n" | 600 | [u"+ */select/1/1\n" |
4466 | 590 | "- **"]) | 601 | u"- **"]) |
4467 | 591 | 602 | ||
4468 | 592 | def test_exclude_filelist_asterisk_2(self): | 603 | def test_exclude_filelist_asterisk_2(self): |
4477 | 593 | """Identical to test_exclude_filelist, but with the exclude 'select' replaced with '*'""" | 604 | """Identical to test_exclude_filelist, but with the exclude "select" replaced with '*'""" |
4478 | 594 | self.ParseTest([("--exclude-filelist", "file")], | 605 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4479 | 595 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 606 | [(), (u"1",), (u"1", "1"), (u"1", u"1", u"2"), |
4480 | 596 | ('1', '1', '3')], | 607 | (u"1", u"1", u"3")], |
4481 | 597 | ["testfiles/*/1/1/1\n" | 608 | [u"testfiles/*/1/1/1\n" |
4482 | 598 | "+ testfiles/select/1/1\n" | 609 | u"+ testfiles/select/1/1\n" |
4483 | 599 | "testfiles/select/1\n" | 610 | u"testfiles/select/1\n" |
4484 | 600 | "- **"]) | 611 | u"- **"]) |
4485 | 601 | 612 | ||
4486 | 602 | def test_exclude_filelist_asterisk_3(self): | 613 | def test_exclude_filelist_asterisk_3(self): |
4488 | 603 | """Identical to test_exclude_filelist, but with the include 'select' replaced with '*'""" | 614 | """Identical to test_exclude_filelist, but with the include "select" replaced with '*'""" |
4489 | 604 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 615 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4497 | 605 | self.ParseTest([("--exclude-filelist", "file")], | 616 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4498 | 606 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 617 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4499 | 607 | ('1', '1', '3')], | 618 | (u"1", u"1", u"3")], |
4500 | 608 | ["testfiles/select/1/1/1\n" | 619 | [u"testfiles/select/1/1/1\n" |
4501 | 609 | "+ testfiles/*/1/1\n" | 620 | u"+ testfiles/*/1/1\n" |
4502 | 610 | "testfiles/select/1\n" | 621 | u"testfiles/select/1\n" |
4503 | 611 | "- **"]) | 622 | u"- **"]) |
4504 | 612 | 623 | ||
4505 | 613 | def test_exclude_filelist_asterisk_4(self): | 624 | def test_exclude_filelist_asterisk_4(self): |
4506 | 614 | """Identical to test_exclude_filelist, but with numerous excluded folders replaced with '*'""" | 625 | """Identical to test_exclude_filelist, but with numerous excluded folders replaced with '*'""" |
4514 | 615 | self.ParseTest([("--exclude-filelist", "file")], | 626 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4515 | 616 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 627 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4516 | 617 | ('1', '1', '3')], | 628 | (u"1", u"1", u"3")], |
4517 | 618 | ["*/select/1/1/1\n" | 629 | [u"*/select/1/1/1\n" |
4518 | 619 | "+ testfiles/select/1/1\n" | 630 | u"+ testfiles/select/1/1\n" |
4519 | 620 | "*/*/1\n" | 631 | u"*/*/1\n" |
4520 | 621 | "- **"]) | 632 | u"- **"]) |
4521 | 622 | 633 | ||
4522 | 623 | def test_exclude_filelist_asterisk_5(self): | 634 | def test_exclude_filelist_asterisk_5(self): |
4523 | 624 | """Identical to test_exclude_filelist, but with numerous included/excluded folders replaced with '*'""" | 635 | """Identical to test_exclude_filelist, but with numerous included/excluded folders replaced with '*'""" |
4524 | 625 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 636 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4532 | 626 | self.ParseTest([("--exclude-filelist", "file")], | 637 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4533 | 627 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 638 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4534 | 628 | ('1', '1', '3')], | 639 | (u"1", u"1", u"3")], |
4535 | 629 | ["*/select/1/1/1\n" | 640 | [u"*/select/1/1/1\n" |
4536 | 630 | "+ */*/1/1\n" | 641 | u"+ */*/1/1\n" |
4537 | 631 | "*/*/1\n" | 642 | u"*/*/1\n" |
4538 | 632 | "- **"]) | 643 | u"- **"]) |
4539 | 633 | 644 | ||
4540 | 634 | def test_exclude_filelist_double_asterisk(self): | 645 | def test_exclude_filelist_double_asterisk(self): |
4541 | 635 | """Identical to test_exclude_filelist, but with all included/excluded folders replaced with '**'""" | 646 | """Identical to test_exclude_filelist, but with all included/excluded folders replaced with '**'""" |
4542 | 636 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 647 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4550 | 637 | self.ParseTest([("--exclude-filelist", "file")], | 648 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4551 | 638 | [(), ('1',), ('1', '1'), ('1', '1', '2'), | 649 | [(), (u"1",), (u"1", u"1"), (u"1", u"1", u"2"), |
4552 | 639 | ('1', '1', '3')], | 650 | (u"1", u"1", u"3")], |
4553 | 640 | ["**/1/1/1\n" | 651 | [u"**/1/1/1\n" |
4554 | 641 | "+ **t/1/1\n" | 652 | u"+ **t/1/1\n" |
4555 | 642 | "**t/1\n" | 653 | u"**t/1\n" |
4556 | 643 | "- **"]) | 654 | u"- **"]) |
4557 | 644 | 655 | ||
4558 | 645 | def test_exclude_filelist_single_asterisk_at_beginning(self): | 656 | def test_exclude_filelist_single_asterisk_at_beginning(self): |
4559 | 646 | """Exclude filelist testing limited functionality of functional test""" | 657 | """Exclude filelist testing limited functionality of functional test""" |
4560 | 647 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) | 658 | # Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371) |
4568 | 648 | self.root = Path("testfiles/select/1") | 659 | self.root = Path(u"testfiles/select/1") |
4569 | 649 | self.ParseTest([("--exclude-filelist", "file")], | 660 | self.ParseTest([(u"--exclude-filelist", u"file")], |
4570 | 650 | [(), ('2',), ('2', '1')], | 661 | [(), (u"2",), (u"2", u"1")], |
4571 | 651 | ["+ */select/1/2/1\n" | 662 | [u"+ */select/1/2/1\n" |
4572 | 652 | "- testfiles/select/1/2\n" | 663 | u"- testfiles/select/1/2\n" |
4573 | 653 | "- testfiles/*/1/1\n" | 664 | u"- testfiles/*/1/1\n" |
4574 | 654 | "- testfiles/select/1/3"]) | 665 | u"- testfiles/select/1/3"]) |
4575 | 655 | 666 | ||
4576 | 656 | def test_commandline_asterisks_double_both(self): | 667 | def test_commandline_asterisks_double_both(self): |
4577 | 657 | """Unit test the functional test TestAsterisks.test_commandline_asterisks_double_both""" | 668 | """Unit test the functional test TestAsterisks.test_commandline_asterisks_double_both""" |
4584 | 658 | self.root = Path("testfiles/select/1") | 669 | self.root = Path(u"testfiles/select/1") |
4585 | 659 | self.ParseTest([("--include", "**/1/2/1"), | 670 | self.ParseTest([(u"--include", u"**/1/2/1"), |
4586 | 660 | ("--exclude", "**t/1/2"), | 671 | (u"--exclude", u"**t/1/2"), |
4587 | 661 | ("--exclude", "**t/1/1"), | 672 | (u"--exclude", u"**t/1/1"), |
4588 | 662 | ("--exclude", "**t/1/3")], | 673 | (u"--exclude", u"**t/1/3")], |
4589 | 663 | [(), ('2',), ('2', '1')]) | 674 | [(), (u"2",), (u"2", u"1")]) |
4590 | 664 | 675 | ||
4591 | 665 | def test_includes_files(self): | 676 | def test_includes_files(self): |
4592 | 666 | """Unit test the functional test test_includes_files""" | 677 | """Unit test the functional test test_includes_files""" |
4593 | 667 | # Test for Bug 1624725 | 678 | # Test for Bug 1624725 |
4594 | 668 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 679 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
4600 | 669 | self.root = Path("testfiles/select2/1/1sub1") | 680 | self.root = Path(u"testfiles/select2/1/1sub1") |
4601 | 670 | self.ParseTest([("--include", "testfiles/select2/1/1sub1/1sub1sub1"), | 681 | self.ParseTest([(u"--include", u"testfiles/select2/1/1sub1/1sub1sub1"), |
4602 | 671 | ("--exclude", "**")], | 682 | (u"--exclude", u"**")], |
4603 | 672 | [(), ('1sub1sub1',), ('1sub1sub1', | 683 | [(), (u"1sub1sub1",), (u"1sub1sub1", |
4604 | 673 | '1sub1sub1_file.txt')]) | 684 | u"1sub1sub1_file.txt")]) |
4605 | 674 | 685 | ||
4606 | 675 | def test_includes_files_trailing_slash(self): | 686 | def test_includes_files_trailing_slash(self): |
4607 | 676 | """Unit test the functional test test_includes_files_trailing_slash""" | 687 | """Unit test the functional test test_includes_files_trailing_slash""" |
4608 | 677 | # Test for Bug 1624725 | 688 | # Test for Bug 1624725 |
4609 | 678 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 689 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
4615 | 679 | self.root = Path("testfiles/select2/1/1sub1") | 690 | self.root = Path(u"testfiles/select2/1/1sub1") |
4616 | 680 | self.ParseTest([("--include", "testfiles/select2/1/1sub1/1sub1sub1/"), | 691 | self.ParseTest([(u"--include", u"testfiles/select2/1/1sub1/1sub1sub1/"), |
4617 | 681 | ("--exclude", "**")], | 692 | (u"--exclude", u"**")], |
4618 | 682 | [(), ('1sub1sub1',), ('1sub1sub1', | 693 | [(), (u"1sub1sub1",), (u"1sub1sub1", |
4619 | 683 | '1sub1sub1_file.txt')]) | 694 | u"1sub1sub1_file.txt")]) |
4620 | 684 | 695 | ||
4621 | 685 | def test_includes_files_trailing_slash_globbing_chars(self): | 696 | def test_includes_files_trailing_slash_globbing_chars(self): |
4622 | 686 | """Unit test functional test_includes_files_trailing_slash_globbing_chars""" | 697 | """Unit test functional test_includes_files_trailing_slash_globbing_chars""" |
4623 | 687 | # Test for Bug 1624725 | 698 | # Test for Bug 1624725 |
4624 | 688 | # https://bugs.launchpad.net/duplicity/+bug/1624725 | 699 | # https://bugs.launchpad.net/duplicity/+bug/1624725 |
4630 | 689 | self.root = Path("testfiles/select2/1/1sub1") | 700 | self.root = Path(u"testfiles/select2/1/1sub1") |
4631 | 690 | self.ParseTest([("--include", "testfiles/s?lect2/1/1sub1/1sub1sub1/"), | 701 | self.ParseTest([(u"--include", u"testfiles/s?lect2/1/1sub1/1sub1sub1/"), |
4632 | 691 | ("--exclude", "**")], | 702 | (u"--exclude", u"**")], |
4633 | 692 | [(), ('1sub1sub1',), ('1sub1sub1', | 703 | [(), (u"1sub1sub1",), (u"1sub1sub1", |
4634 | 693 | '1sub1sub1_file.txt')]) | 704 | u"1sub1sub1_file.txt")]) |
4635 | 694 | 705 | ||
4636 | 695 | def test_glob(self): | 706 | def test_glob(self): |
4637 | 696 | """Test globbing expression""" | 707 | """Test globbing expression""" |
4664 | 697 | self.ParseTest([("--exclude", "**[3-5]"), | 708 | self.ParseTest([(u"--exclude", u"**[3-5]"), |
4665 | 698 | ("--include", "testfiles/select/1"), | 709 | (u"--include", u"testfiles/select/1"), |
4666 | 699 | ("--exclude", "**")], | 710 | (u"--exclude", u"**")], |
4667 | 700 | [(), ('1',), ('1', '1'), | 711 | [(), (u"1",), (u"1", u"1"), |
4668 | 701 | ('1', '1', '1'), ('1', '1', '2'), | 712 | (u"1", u"1", u"1"), (u"1", u"1", u"2"), |
4669 | 702 | ('1', '2'), ('1', '2', '1'), ('1', '2', '2')]) | 713 | (u"1", u"2"), (u"1", u"2", u"1"), (u"1", u"2", u"2")]) |
4670 | 703 | self.ParseTest([("--include", "testfiles/select**/2"), | 714 | self.ParseTest([(u"--include", u"testfiles/select**/2"), |
4671 | 704 | ("--exclude", "**")], | 715 | (u"--exclude", u"**")], |
4672 | 705 | [(), ('1',), ('1', '1'), | 716 | [(), (u"1",), (u"1", u"1"), |
4673 | 706 | ('1', '1', '2'), | 717 | (u"1", u"1", u"2"), |
4674 | 707 | ('1', '2'), | 718 | (u"1", u"2"), |
4675 | 708 | ('1', '2', '1'), ('1', '2', '2'), ('1', '2', '3'), | 719 | (u"1", u"2", u"1"), (u"1", u"2", u"2"), (u"1", u"2", u"3"), |
4676 | 709 | ('1', '3'), | 720 | (u"1", u"3"), |
4677 | 710 | ('1', '3', '2'), | 721 | (u"1", u"3", u"2"), |
4678 | 711 | ('2',), ('2', '1'), | 722 | (u"2",), (u"2", u"1"), |
4679 | 712 | ('2', '1', '1'), ('2', '1', '2'), ('2', '1', '3'), | 723 | (u"2", u"1", u"1"), (u"2", u"1", u"2"), (u"2", u"1", u"3"), |
4680 | 713 | ('2', '2'), | 724 | (u"2", u"2"), |
4681 | 714 | ('2', '2', '1'), ('2', '2', '2'), ('2', '2', '3'), | 725 | (u"2", u"2", u"1"), (u"2", u"2", u"2"), (u"2", u"2", u"3"), |
4682 | 715 | ('2', '3'), | 726 | (u"2", u"3"), |
4683 | 716 | ('2', '3', '1'), ('2', '3', '2'), ('2', '3', '3'), | 727 | (u"2", u"3", u"1"), (u"2", u"3", u"2"), (u"2", u"3", u"3"), |
4684 | 717 | ('3',), ('3', '1'), | 728 | (u"3",), (u"3", u"1"), |
4685 | 718 | ('3', '1', '2'), | 729 | (u"3", u"1", u"2"), |
4686 | 719 | ('3', '2'), | 730 | (u"3", u"2"), |
4687 | 720 | ('3', '2', '1'), ('3', '2', '2'), ('3', '2', '3'), | 731 | (u"3", u"2", u"1"), (u"3", u"2", u"2"), (u"3", u"2", u"3"), |
4688 | 721 | ('3', '3'), | 732 | (u"3", u"3"), |
4689 | 722 | ('3', '3', '2')]) | 733 | (u"3", u"3", u"2")]) |
4690 | 723 | 734 | ||
4691 | 724 | def test_filelist2(self): | 735 | def test_filelist2(self): |
4692 | 725 | """Filelist glob test similar to above testGlob""" | 736 | """Filelist glob test similar to above testGlob""" |
4698 | 726 | self.ParseTest([("--exclude-filelist", "asoeuth")], | 737 | self.ParseTest([(u"--exclude-filelist", u"asoeuth")], |
4699 | 727 | [(), ('1',), ('1', '1'), | 738 | [(), (u"1",), (u"1", u"1"), |
4700 | 728 | ('1', '1', '1'), ('1', '1', '2'), | 739 | (u"1", u"1", u"1"), (u"1", u"1", u"2"), |
4701 | 729 | ('1', '2'), ('1', '2', '1'), ('1', '2', '2')], | 740 | (u"1", u"2"), (u"1", u"2", u"1"), (u"1", u"2", u"2")], |
4702 | 730 | [""" | 741 | [u""" |
4703 | 731 | **[3-5] | 742 | **[3-5] |
4704 | 732 | + testfiles/select/1 | 743 | + testfiles/select/1 |
4705 | 733 | ** | 744 | ** |
4706 | 734 | """]) | 745 | """]) |
4727 | 735 | self.ParseTest([("--include-filelist", "file")], | 746 | self.ParseTest([(u"--include-filelist", u"file")], |
4728 | 736 | [(), ('1',), ('1', '1'), | 747 | [(), (u"1",), (u"1", u"1"), |
4729 | 737 | ('1', '1', '2'), | 748 | (u"1", u"1", u"2"), |
4730 | 738 | ('1', '2'), | 749 | (u"1", u"2"), |
4731 | 739 | ('1', '2', '1'), ('1', '2', '2'), ('1', '2', '3'), | 750 | (u"1", u"2", u"1"), (u"1", u"2", u"2"), (u"1", u"2", u"3"), |
4732 | 740 | ('1', '3'), | 751 | (u"1", u"3"), |
4733 | 741 | ('1', '3', '2'), | 752 | (u"1", u"3", u"2"), |
4734 | 742 | ('2',), ('2', '1'), | 753 | (u"2",), (u"2", u"1"), |
4735 | 743 | ('2', '1', '1'), ('2', '1', '2'), ('2', '1', '3'), | 754 | (u"2", u"1", u"1"), (u"2", u"1", u"2"), (u"2", u"1", u"3"), |
4736 | 744 | ('2', '2'), | 755 | (u"2", u"2"), |
4737 | 745 | ('2', '2', '1'), ('2', '2', '2'), ('2', '2', '3'), | 756 | (u"2", u"2", u"1"), (u"2", u"2", u"2"), (u"2", u"2", u"3"), |
4738 | 746 | ('2', '3'), | 757 | (u"2", u"3"), |
4739 | 747 | ('2', '3', '1'), ('2', '3', '2'), ('2', '3', '3'), | 758 | (u"2", u"3", u"1"), (u"2", u"3", u"2"), (u"2", u"3", u"3"), |
4740 | 748 | ('3',), ('3', '1'), | 759 | (u"3",), (u"3", u"1"), |
4741 | 749 | ('3', '1', '2'), | 760 | (u"3", u"1", u"2"), |
4742 | 750 | ('3', '2'), | 761 | (u"3", u"2"), |
4743 | 751 | ('3', '2', '1'), ('3', '2', '2'), ('3', '2', '3'), | 762 | (u"3", u"2", u"1"), (u"3", u"2", u"2"), (u"3", u"2", u"3"), |
4744 | 752 | ('3', '3'), | 763 | (u"3", u"3"), |
4745 | 753 | ('3', '3', '2')], | 764 | (u"3", u"3", u"2")], |
4746 | 754 | [""" | 765 | [u""" |
4747 | 755 | testfiles/select**/2 | 766 | testfiles/select**/2 |
4748 | 756 | - ** | 767 | - ** |
4749 | 757 | """]) | 768 | """]) |
4750 | 758 | 769 | ||
4751 | 759 | def test_glob2(self): | 770 | def test_glob2(self): |
4752 | 760 | """Test more globbing functions""" | 771 | """Test more globbing functions""" |
4763 | 761 | self.ParseTest([("--include", "testfiles/select/*foo*/p*"), | 772 | self.ParseTest([(u"--include", u"testfiles/select/*foo*/p*"), |
4764 | 762 | ("--exclude", "**")], | 773 | (u"--exclude", u"**")], |
4765 | 763 | [(), ('efools',), ('efools', 'ping'), | 774 | [(), (u"efools",), (u"efools", u"ping"), |
4766 | 764 | ('foobar',), ('foobar', 'pong')]) | 775 | (u"foobar",), (u"foobar", u"pong")]) |
4767 | 765 | self.ParseTest([("--exclude", "testfiles/select/1/1/*"), | 776 | self.ParseTest([(u"--exclude", u"testfiles/select/1/1/*"), |
4768 | 766 | ("--exclude", "testfiles/select/1/2/**"), | 777 | (u"--exclude", u"testfiles/select/1/2/**"), |
4769 | 767 | ("--exclude", "testfiles/select/1/3**"), | 778 | (u"--exclude", u"testfiles/select/1/3**"), |
4770 | 768 | ("--include", "testfiles/select/1"), | 779 | (u"--include", u"testfiles/select/1"), |
4771 | 769 | ("--exclude", "**")], | 780 | (u"--exclude", u"**")], |
4772 | 770 | [(), ('1',), ('1', '1'), ('1', '2')]) | 781 | [(), (u"1",), (u"1", u"1"), (u"1", u"2")]) |
4773 | 771 | 782 | ||
4774 | 772 | def test_glob3(self): | 783 | def test_glob3(self): |
4775 | 773 | """ regression test for bug 25230 """ | 784 | """ regression test for bug 25230 """ |
4797 | 774 | self.ParseTest([("--include", "testfiles/select/**1"), | 785 | self.ParseTest([(u"--include", u"testfiles/select/**1"), |
4798 | 775 | ("--include", "testfiles/select/**2"), | 786 | (u"--include", u"testfiles/select/**2"), |
4799 | 776 | ("--exclude", "**")], | 787 | (u"--exclude", u"**")], |
4800 | 777 | [(), ('1',), ('1', '1'), | 788 | [(), (u"1",), (u"1", u"1"), |
4801 | 778 | ('1', '1', '1'), ('1', '1', '2'), ('1', '1', '3'), | 789 | (u"1", u"1", u"1"), (u"1", u"1", u"2"), (u"1", u"1", u"3"), |
4802 | 779 | ('1', '2'), | 790 | (u"1", u"2"), |
4803 | 780 | ('1', '2', '1'), ('1', '2', '2'), ('1', '2', '3'), | 791 | (u"1", u"2", u"1"), (u"1", u"2", u"2"), (u"1", u"2", u"3"), |
4804 | 781 | ('1', '3'), | 792 | (u"1", u"3"), |
4805 | 782 | ('1', '3', '1'), ('1', '3', '2'), ('1', '3', '3'), | 793 | (u"1", u"3", u"1"), (u"1", u"3", u"2"), (u"1", u"3", u"3"), |
4806 | 783 | ('2',), ('2', '1'), | 794 | (u"2",), (u"2", u"1"), |
4807 | 784 | ('2', '1', '1'), ('2', '1', '2'), ('2', '1', '3'), | 795 | (u"2", u"1", u"1"), (u"2", u"1", u"2"), (u"2", u"1", u"3"), |
4808 | 785 | ('2', '2'), | 796 | (u"2", u"2"), |
4809 | 786 | ('2', '2', '1'), ('2', '2', '2'), ('2', '2', '3'), | 797 | (u"2", u"2", u"1"), (u"2", u"2", u"2"), (u"2", u"2", u"3"), |
4810 | 787 | ('2', '3'), | 798 | (u"2", u"3"), |
4811 | 788 | ('2', '3', '1'), ('2', '3', '2'), ('2', '3', '3'), | 799 | (u"2", u"3", u"1"), (u"2", u"3", u"2"), (u"2", u"3", u"3"), |
4812 | 789 | ('3',), ('3', '1'), | 800 | (u"3",), (u"3", u"1"), |
4813 | 790 | ('3', '1', '1'), ('3', '1', '2'), ('3', '1', '3'), | 801 | (u"3", u"1", u"1"), (u"3", u"1", u"2"), (u"3", u"1", u"3"), |
4814 | 791 | ('3', '2'), | 802 | (u"3", u"2"), |
4815 | 792 | ('3', '2', '1'), ('3', '2', '2'), ('3', '2', '3'), | 803 | (u"3", u"2", u"1"), (u"3", u"2", u"2"), (u"3", u"2", u"3"), |
4816 | 793 | ('3', '3'), | 804 | (u"3", u"3"), |
4817 | 794 | ('3', '3', '1'), ('3', '3', '2')]) | 805 | (u"3", u"3", u"1"), (u"3", u"3", u"2")]) |
4818 | 795 | 806 | ||
4819 | 796 | def test_alternate_root(self): | 807 | def test_alternate_root(self): |
4820 | 797 | """Test select with different root""" | 808 | """Test select with different root""" |
4824 | 798 | self.root = Path("testfiles/select/1") | 809 | self.root = Path(u"testfiles/select/1") |
4825 | 799 | self.ParseTest([("--exclude", "testfiles/select/1/[23]")], | 810 | self.ParseTest([(u"--exclude", u"testfiles/select/1/[23]")], |
4826 | 800 | [(), ('1',), ('1', '1'), ('1', '2'), ('1', '3')]) | 811 | [(), (u"1",), (u"1", u"1"), (u"1", u"2"), (u"1", u"3")]) |
4827 | 801 | 812 | ||
4833 | 802 | self.root = Path("/") | 813 | self.root = Path(u"/") |
4834 | 803 | self.ParseTest([("--exclude", "/tmp/*"), | 814 | self.ParseTest([(u"--exclude", u"/tmp/*"), |
4835 | 804 | ("--include", "/tmp"), | 815 | (u"--include", u"/tmp"), |
4836 | 805 | ("--exclude", "/")], | 816 | (u"--exclude", u"/")], |
4837 | 806 | [(), ("tmp",)]) | 817 | [(), (u"tmp",)]) |
4838 | 807 | 818 | ||
4839 | 808 | def test_exclude_after_scan(self): | 819 | def test_exclude_after_scan(self): |
4840 | 809 | """Test select with an exclude after a pattern that would return a scan for that file""" | 820 | """Test select with an exclude after a pattern that would return a scan for that file""" |
4848 | 810 | self.root = Path("testfiles/select2/3") | 821 | self.root = Path(u"testfiles/select2/3") |
4849 | 811 | self.ParseTest([("--include", "testfiles/select2/3/**file.txt"), | 822 | self.ParseTest([(u"--include", u"testfiles/select2/3/**file.txt"), |
4850 | 812 | ("--exclude", "testfiles/select2/3/3sub2"), | 823 | (u"--exclude", u"testfiles/select2/3/3sub2"), |
4851 | 813 | ("--include", "testfiles/select2/3/3sub1"), | 824 | (u"--include", u"testfiles/select2/3/3sub1"), |
4852 | 814 | ("--exclude", "**")], | 825 | (u"--exclude", u"**")], |
4853 | 815 | [(), ('3sub1',), ('3sub1', '3sub1sub1'), ('3sub1', '3sub1sub2'), ('3sub1', '3sub1sub3'), | 826 | [(), (u"3sub1",), (u"3sub1", u"3sub1sub1"), (u"3sub1", u"3sub1sub2"), (u"3sub1", u"3sub1sub3"), |
4854 | 816 | ('3sub3',), ('3sub3', '3sub3sub2'), ('3sub3', '3sub3sub2', '3sub3sub2_file.txt')]) | 827 | (u"3sub3",), (u"3sub3", u"3sub3sub2"), (u"3sub3", u"3sub3sub2", u"3sub3sub2_file.txt")]) |
4855 | 817 | 828 | ||
4856 | 818 | def test_include_exclude_basic(self): | 829 | def test_include_exclude_basic(self): |
4857 | 819 | """Test functional test test_include_exclude_basic as a unittest""" | 830 | """Test functional test test_include_exclude_basic as a unittest""" |
4878 | 820 | self.root = Path("testfiles/select2") | 831 | self.root = Path(u"testfiles/select2") |
4879 | 821 | self.ParseTest([("--include", "testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"), | 832 | self.ParseTest([(u"--include", u"testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt"), |
4880 | 822 | ("--exclude", "testfiles/select2/3/3sub3/3sub3sub2"), | 833 | (u"--exclude", u"testfiles/select2/3/3sub3/3sub3sub2"), |
4881 | 823 | ("--include", "testfiles/select2/3/3sub2/3sub2sub2"), | 834 | (u"--include", u"testfiles/select2/3/3sub2/3sub2sub2"), |
4882 | 824 | ("--include", "testfiles/select2/3/3sub3"), | 835 | (u"--include", u"testfiles/select2/3/3sub3"), |
4883 | 825 | ("--exclude", "testfiles/select2/3/3sub1"), | 836 | (u"--exclude", u"testfiles/select2/3/3sub1"), |
4884 | 826 | ("--exclude", "testfiles/select2/2/2sub1/2sub1sub3"), | 837 | (u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub3"), |
4885 | 827 | ("--exclude", "testfiles/select2/2/2sub1/2sub1sub2"), | 838 | (u"--exclude", u"testfiles/select2/2/2sub1/2sub1sub2"), |
4886 | 828 | ("--include", "testfiles/select2/2/2sub1"), | 839 | (u"--include", u"testfiles/select2/2/2sub1"), |
4887 | 829 | ("--exclude", "testfiles/select2/1/1sub3/1sub3sub2"), | 840 | (u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub2"), |
4888 | 830 | ("--exclude", "testfiles/select2/1/1sub3/1sub3sub1"), | 841 | (u"--exclude", u"testfiles/select2/1/1sub3/1sub3sub1"), |
4889 | 831 | ("--exclude", "testfiles/select2/1/1sub2/1sub2sub3"), | 842 | (u"--exclude", u"testfiles/select2/1/1sub2/1sub2sub3"), |
4890 | 832 | ("--include", "testfiles/select2/1/1sub2/1sub2sub1"), | 843 | (u"--include", u"testfiles/select2/1/1sub2/1sub2sub1"), |
4891 | 833 | ("--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt"), | 844 | (u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt"), |
4892 | 834 | ("--exclude", "testfiles/select2/1/1sub1/1sub1sub2"), | 845 | (u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub2"), |
4893 | 835 | ("--exclude", "testfiles/select2/1/1sub2"), | 846 | (u"--exclude", u"testfiles/select2/1/1sub2"), |
4894 | 836 | ("--include", "testfiles/select2/1.py"), | 847 | (u"--include", u"testfiles/select2/1.py"), |
4895 | 837 | ("--include", "testfiles/select2/3"), | 848 | (u"--include", u"testfiles/select2/3"), |
4896 | 838 | ("--include", "testfiles/select2/1"), | 849 | (u"--include", u"testfiles/select2/1"), |
4897 | 839 | ("--exclude", "testfiles/select2/**")], | 850 | (u"--exclude", u"testfiles/select2/**")], |
4898 | 840 | self.expected_restored_tree) | 851 | self.expected_restored_tree) |
4899 | 841 | 852 | ||
4900 | 842 | def test_globbing_replacement(self): | 853 | def test_globbing_replacement(self): |
4901 | 843 | """Test functional test test_globbing_replacement as a unittest""" | 854 | """Test functional test test_globbing_replacement as a unittest""" |
4918 | 844 | self.root = Path("testfiles/select2") | 855 | self.root = Path(u"testfiles/select2") |
4919 | 845 | self.ParseTest([("--include", "testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt"), | 856 | self.ParseTest([(u"--include", u"testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt"), |
4920 | 846 | ("--exclude", "testfiles/select2/*/3s*1"), | 857 | (u"--exclude", u"testfiles/select2/*/3s*1"), |
4921 | 847 | ("--exclude", "testfiles/select2/**/2sub1sub3"), | 858 | (u"--exclude", u"testfiles/select2/**/2sub1sub3"), |
4922 | 848 | ("--exclude", "ignorecase:testfiles/select2/2/2sub1/2Sub1Sub2"), | 859 | (u"--exclude", u"ignorecase:testfiles/select2/2/2sub1/2Sub1Sub2"), |
4923 | 849 | ("--include", "ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1"), | 860 | (u"--include", u"ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1"), |
4924 | 850 | ("--exclude", "testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2"), | 861 | (u"--exclude", u"testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2"), |
4925 | 851 | ("--exclude", "testfiles/select2/1/1sub[1-4]/1sub3sub1"), | 862 | (u"--exclude", u"testfiles/select2/1/1sub[1-4]/1sub3sub1"), |
4926 | 852 | ("--include", "testfiles/select2/1/1sub2/1sub2sub1"), | 863 | (u"--include", u"testfiles/select2/1/1sub2/1sub2sub1"), |
4927 | 853 | ("--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt"), | 864 | (u"--exclude", u"testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt"), |
4928 | 854 | ("--exclude", "testfiles/select2/1/1*1/1sub1sub2"), | 865 | (u"--exclude", u"testfiles/select2/1/1*1/1sub1sub2"), |
4929 | 855 | ("--exclude", "testfiles/select2/1/1sub2"), | 866 | (u"--exclude", u"testfiles/select2/1/1sub2"), |
4930 | 856 | ("--include", "testfiles/select[2-4]/*.py"), | 867 | (u"--include", u"testfiles/select[2-4]/*.py"), |
4931 | 857 | ("--include", "testfiles/*2/3"), | 868 | (u"--include", u"testfiles/*2/3"), |
4932 | 858 | ("--include", "**/select2/1"), | 869 | (u"--include", u"**/select2/1"), |
4933 | 859 | ("--exclude", "testfiles/select2/**")], | 870 | (u"--exclude", u"testfiles/select2/**")], |
4934 | 860 | self.expected_restored_tree) | 871 | self.expected_restored_tree) |
4935 | 861 | 872 | ||
4936 | 873 | def test_unicode_paths_non_globbing(self): | ||
4937 | 874 | """Test functional test test_unicode_paths_non_globbing as a unittest""" | ||
4938 | 875 | self.root = Path(u"testfiles/select-unicode") | ||
4939 | 876 | self.ParseTest([(u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/उदाहरण.txt"), | ||
4940 | 877 | (u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/Παράδειγμα/דוגמא.txt"), | ||
4941 | 878 | (u"--exclude", u"testfiles/select-unicode/прыклад/пример/例/მაგალითი/"), | ||
4942 | 879 | (u"--include", u"testfiles/select-unicode/прыклад/пример/例/"), | ||
4943 | 880 | (u"--exclude", u"testfiles/select-unicode/прыклад/пример/"), | ||
4944 | 881 | (u"--include", u"testfiles/select-unicode/прыклад/"), | ||
4945 | 882 | (u"--include", u"testfiles/select-unicode/օրինակ.txt"), | ||
4946 | 883 | (u"--exclude", u"testfiles/select-unicode/**")], | ||
4947 | 884 | [(), (u"прыклад",), (u"прыклад", u"пример"), (u"прыклад", u"пример", u"例"), | ||
4948 | 885 | (u"прыклад", u"пример", u"例", u"Παράδειγμα"), | ||
4949 | 886 | (u"прыклад", u"пример", u"例", u"Παράδειγμα", u"ઉદાહરણ.log"), | ||
4950 | 887 | (u"прыклад", u"উদাহরণ"), (u"օրինակ.txt",)]) | ||
4951 | 888 | |||
4952 | 862 | 889 | ||
4953 | 863 | class TestGlobGetNormalSf(UnitTestCase): | 890 | class TestGlobGetNormalSf(UnitTestCase): |
4954 | 864 | """Test glob parsing of the test_glob_get_normal_sf function. Indirectly test behaviour of glob_to_re.""" | 891 | """Test glob parsing of the test_glob_get_normal_sf function. Indirectly test behaviour of glob_to_re.""" |
4955 | @@ -877,152 +904,152 @@ | |||
4956 | 877 | path = Path(path) | 904 | path = Path(path) |
4957 | 878 | return selection_function(path) | 905 | return selection_function(path) |
4958 | 879 | 906 | ||
4960 | 880 | def include_glob_tester(self, path, glob_string, root_path="/"): | 907 | def include_glob_tester(self, path, glob_string, root_path=u"/"): |
4961 | 881 | return self.glob_tester(path, glob_string, 1, root_path) | 908 | return self.glob_tester(path, glob_string, 1, root_path) |
4962 | 882 | 909 | ||
4964 | 883 | def exclude_glob_tester(self, path, glob_string, root_path="/"): | 910 | def exclude_glob_tester(self, path, glob_string, root_path=u"/"): |
4965 | 884 | return self.glob_tester(path, glob_string, 0, root_path) | 911 | return self.glob_tester(path, glob_string, 0, root_path) |
4966 | 885 | 912 | ||
4967 | 886 | def test_glob_get_normal_sf_exclude(self): | 913 | def test_glob_get_normal_sf_exclude(self): |
4968 | 887 | """Test simple exclude.""" | 914 | """Test simple exclude.""" |
4971 | 888 | self.assertEqual(self.exclude_glob_tester("/testfiles/select2/3", "/testfiles/select2"), 0) | 915 | self.assertEqual(self.exclude_glob_tester(u"/testfiles/select2/3", u"/testfiles/select2"), 0) |
4972 | 889 | self.assertEqual(self.exclude_glob_tester("/testfiles/.git", "/testfiles"), 0) | 916 | self.assertEqual(self.exclude_glob_tester(u"/testfiles/.git", u"/testfiles"), 0) |
4973 | 890 | 917 | ||
4974 | 891 | def test_glob_get_normal_sf_exclude_root(self): | 918 | def test_glob_get_normal_sf_exclude_root(self): |
4975 | 892 | """Test simple exclude with / as the glob.""" | 919 | """Test simple exclude with / as the glob.""" |
4978 | 893 | self.assertEqual(self.exclude_glob_tester("/.git", "/"), 0) | 920 | self.assertEqual(self.exclude_glob_tester(u"/.git", u"/"), 0) |
4979 | 894 | self.assertEqual(self.exclude_glob_tester("/testfile", "/"), 0) | 921 | self.assertEqual(self.exclude_glob_tester(u"/testfile", u"/"), 0) |
4980 | 895 | 922 | ||
4981 | 896 | def test_glob_get_normal_sf_2(self): | 923 | def test_glob_get_normal_sf_2(self): |
4982 | 897 | """Test same behaviour as the functional test test_globbing_replacement.""" | 924 | """Test same behaviour as the functional test test_globbing_replacement.""" |
4983 | 898 | self.assertEqual(self.include_glob_tester("/testfiles/select2/3/3sub3/3sub3sub2/3sub3sub2_file.txt", | ||
4984 | 899 | "/testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt"), 1) | ||
4985 | 900 | self.assertEqual(self.include_glob_tester("/testfiles/select2/3/3sub1", "/testfiles/select2/*/3s*1"), 1) | ||
4986 | 901 | self.assertEqual(self.include_glob_tester("/testfiles/select2/2/2sub1/2sub1sub3", | ||
4987 | 902 | "/testfiles/select2/**/2sub1sub3"), 1) | ||
4988 | 903 | self.assertEqual(self.include_glob_tester("/testfiles/select2/2/2sub1", | ||
4989 | 904 | "/testfiles/sel[w,u,e,q]ct2/2/2s?b1"), 1) | ||
4990 | 905 | self.assertEqual(self.include_glob_tester("/testfiles/select2/1/1sub3/1sub3sub2", | ||
4991 | 906 | "/testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2"), 1) | ||
4992 | 907 | self.assertEqual(self.exclude_glob_tester("/testfiles/select2/1/1sub3/1sub3sub1", | ||
4993 | 908 | "/testfiles/select2/1/1sub[1-4]/1sub3sub1"), 0) | ||
4994 | 909 | self.assertEqual(self.include_glob_tester("/testfiles/select2/1/1sub2/1sub2sub1", | ||
4995 | 910 | "/testfiles/select2/*/1sub2/1s[w,u,p,q]b2sub1"), 1) | ||
4996 | 911 | self.assertEqual(self.include_glob_tester("/testfiles/select2/1/1sub1/1sub1sub3/1sub1sub3_file.txt", | ||
4997 | 912 | "/testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt"), 1) | ||
4998 | 913 | self.assertEqual(self.exclude_glob_tester("/testfiles/select2/1/1sub1/1sub1sub2", | ||
4999 | 914 | "/testfiles/select2/1/1*1/1sub1sub2"), 0) | ||
5000 | 915 | self.assertEqual(self.include_glob_tester("/testfiles/select2/1/1sub2", "/testfiles/select2/1/1sub2"), 1) |