/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2009, 2010, 2011, 2016 Canonical Ltd
4010.2.1 by James Westby
Handle files that are not present in the tree when exporting (#174539)
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
4010.2.1 by James Westby
Handle files that are not present in the tree when exporting (#174539)
16
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
17
"""Tests for breezy.export."""
5718.5.12 by Jelmer Vernooij
Add test for export_tarball.
18
7240.8.1 by Jelmer Vernooij
Use tree timestamp when exporting.
19
import gzip
4010.2.1 by James Westby
Handle files that are not present in the tree when exporting (#174539)
20
import os
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
21
import tarfile
4996.1.1 by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily.
22
import time
5718.5.14 by Jelmer Vernooij
Add test for per-file-timestamp zipfiles.
23
import zipfile
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
24
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
25
from .. import (
4576.1.1 by Alexander Belchenko
Fixed export to existing empty directory.
26
    errors,
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
27
    export,
28
    tests,
29
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
30
from ..export import get_root_name
6968.2.7 by Jelmer Vernooij
Add breezy.archive.
31
from ..archive.tar import tarball_generator
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
32
from ..sixish import (
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
33
    BytesIO,
34
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
35
from . import features
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
36
37
5718.5.9 by Jelmer Vernooij
Add test for export zip to stdout.
38
class TestDirExport(tests.TestCaseWithTransport):
4010.2.1 by James Westby
Handle files that are not present in the tree when exporting (#174539)
39
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
40
    def test_missing_file(self):
4010.2.1 by James Westby
Handle files that are not present in the tree when exporting (#174539)
41
        self.build_tree(['a/', 'a/b', 'a/c'])
42
        wt = self.make_branch_and_tree('.')
43
        wt.add(['a', 'a/b', 'a/c'])
44
        os.unlink('a/c')
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
45
        export.export(wt, 'target', format="dir")
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
46
        self.assertPathExists('target/a/b')
47
        self.assertPathDoesNotExist('target/a/c')
4241.9.5 by Vincent Ladeuil
Fix unicode related OSX failures.
48
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
49
    def test_empty(self):
50
        wt = self.make_branch_and_tree('.')
51
        export.export(wt, 'target', format="dir")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
52
        self.assertEqual([], os.listdir("target"))
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
53
54
    def test_symlink(self):
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
55
        self.requireFeature(features.SymlinkFeature)
4562.1.1 by Jelmer Vernooij
Support exporting symlinks when exporting from a working tree.
56
        wt = self.make_branch_and_tree('.')
57
        os.symlink('source', 'link')
58
        wt.add(['link'])
59
        export.export(wt, 'target', format="dir")
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
60
        self.assertPathExists('target/link')
4576.1.1 by Alexander Belchenko
Fixed export to existing empty directory.
61
6964.1.1 by Jelmer Vernooij
Support exporting nested trees.
62
    def test_nested_tree(self):
63
        wt = self.make_branch_and_tree('.', format='development-subtree')
64
        subtree = self.make_branch_and_tree('subtree')
65
        self.build_tree(['subtree/file'])
66
        subtree.add(['file'])
67
        wt.add(['subtree'])
68
        export.export(wt, 'target', format="dir")
69
        self.assertPathExists('target/subtree')
70
        # TODO(jelmer): Once iter_entries_by_dir supports nested tree iteration:
71
        # self.assertPathExists('target/subtree/file')
72
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
73
    def test_to_existing_empty_dir_success(self):
4576.1.1 by Alexander Belchenko
Fixed export to existing empty directory.
74
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
75
        wt = self.make_branch_and_tree('source')
76
        wt.add(['a', 'b', 'b/c'])
77
        wt.commit('1')
78
        self.build_tree(['target/'])
79
        export.export(wt, 'target', format="dir")
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
80
        self.assertPathExists('target/a')
81
        self.assertPathExists('target/b')
82
        self.assertPathExists('target/b/c')
4576.1.1 by Alexander Belchenko
Fixed export to existing empty directory.
83
5809.3.1 by Aaron Bentley
Switch to iter_entries_by_dir.
84
    def test_empty_subdir(self):
85
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
86
        wt = self.make_branch_and_tree('source')
87
        wt.add(['a', 'b', 'b/c'])
88
        wt.commit('1')
89
        self.build_tree(['target/'])
90
        export.export(wt, 'target', format="dir", subdir='')
91
        self.assertPathExists('target/a')
92
        self.assertPathExists('target/b')
93
        self.assertPathExists('target/b/c')
94
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
95
    def test_to_existing_nonempty_dir_fail(self):
4576.1.1 by Alexander Belchenko
Fixed export to existing empty directory.
96
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
97
        wt = self.make_branch_and_tree('source')
98
        wt.add(['a', 'b', 'b/c'])
99
        wt.commit('1')
100
        self.build_tree(['target/', 'target/foo'])
5967.6.2 by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions.
101
        self.assertRaises(errors.BzrError,
7143.15.2 by Jelmer Vernooij
Run autopep8.
102
                          export.export, wt, 'target', format="dir")
4988.10.1 by michal
- bug #511987 fixed, export of single file
103
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
104
    def test_existing_single_file(self):
5967.6.2 by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions.
105
        self.build_tree([
106
            'dir1/', 'dir1/dir2/', 'dir1/first', 'dir1/dir2/second'])
4988.10.1 by michal
- bug #511987 fixed, export of single file
107
        wtree = self.make_branch_and_tree('dir1')
108
        wtree.add(['dir2', 'first', 'dir2/second'])
109
        wtree.commit('1')
110
        export.export(wtree, 'target1', format='dir', subdir='first')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
111
        self.assertPathExists('target1/first')
4988.10.1 by michal
- bug #511987 fixed, export of single file
112
        export.export(wtree, 'target2', format='dir', subdir='dir2/second')
5784.1.3 by Martin Pool
Switch away from using failUnlessExists and failIfExists
113
        self.assertPathExists('target2/second')
5718.5.7 by Jelmer Vernooij
Support bzr zip exporting to stdout.
114
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
115
    def test_files_same_timestamp(self):
4996.1.1 by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily.
116
        builder = self.make_branch_builder('source')
117
        builder.start_series()
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
118
        builder.build_snapshot(None, [
6973.11.1 by Jelmer Vernooij
Fix export_pot.
119
            ('add', ('', b'root-id', 'directory', '')),
120
            ('add', ('a', b'a-id', 'file', b'content\n'))])
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
121
        builder.build_snapshot(None, [
6973.11.1 by Jelmer Vernooij
Fix export_pot.
122
            ('add', ('b', b'b-id', 'file', b'content\n'))])
4996.1.1 by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily.
123
        builder.finish_series()
124
        b = builder.get_branch()
125
        b.lock_read()
126
        self.addCleanup(b.unlock)
127
        tree = b.basis_tree()
128
        orig_iter_files_bytes = tree.iter_files_bytes
5967.6.2 by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions.
129
4996.1.1 by Robert Collins
Set the file mtime when exporting to a directory to prevent triggering make rebuilds unnecessarily.
130
        # Make iter_files_bytes slower, so we provoke mtime skew
131
        def iter_files_bytes(to_fetch):
132
            for thing in orig_iter_files_bytes(to_fetch):
133
                yield thing
134
                time.sleep(1)
135
        tree.iter_files_bytes = iter_files_bytes
136
        export.export(tree, 'target', format='dir')
137
        t = self.get_transport('target')
138
        st_a = t.stat('a')
139
        st_b = t.stat('b')
140
        # All files must be given the same mtime.
141
        self.assertEqual(st_a.st_mtime, st_b.st_mtime)
5076.2.1 by Jelmer Vernooij
Add use_tree_timestamp argument to exporters.
142
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
143
    def test_files_per_file_timestamps(self):
5076.2.1 by Jelmer Vernooij
Add use_tree_timestamp argument to exporters.
144
        builder = self.make_branch_builder('source')
145
        builder.start_series()
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
146
        # Earliest allowable date on FAT32 filesystems is 1980-01-01
147
        a_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0))
6619.3.14 by Jelmer Vernooij
Convert some octal numbers to new notations.
148
        b_time = time.mktime((1980, 0o1, 0o1, 0, 0, 0, 0, 0, 0))
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
149
        builder.build_snapshot(None, [
6973.11.1 by Jelmer Vernooij
Fix export_pot.
150
            ('add', ('', b'root-id', 'directory', '')),
151
            ('add', ('a', b'a-id', 'file', b'content\n'))],
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
152
            timestamp=a_time)
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
153
        builder.build_snapshot(None, [
6973.11.1 by Jelmer Vernooij
Fix export_pot.
154
            ('add', ('b', b'b-id', 'file', b'content\n'))],
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
155
            timestamp=b_time)
5076.2.1 by Jelmer Vernooij
Add use_tree_timestamp argument to exporters.
156
        builder.finish_series()
157
        b = builder.get_branch()
158
        b.lock_read()
159
        self.addCleanup(b.unlock)
160
        tree = b.basis_tree()
5076.2.3 by Jelmer Vernooij
Review comments from Rob.
161
        export.export(tree, 'target', format='dir', per_file_timestamps=True)
5076.2.1 by Jelmer Vernooij
Add use_tree_timestamp argument to exporters.
162
        t = self.get_transport('target')
5151.3.1 by Martin
Fix os.utime test failures, three on FAT filesystems and one with readonly files
163
        self.assertEqual(a_time, t.stat('a').st_mtime)
164
        self.assertEqual(b_time, t.stat('b').st_mtime)
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
165
5966.1.1 by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps.
166
    def test_subdir_files_per_timestamps(self):
167
        builder = self.make_branch_builder('source')
168
        builder.start_series()
169
        foo_time = time.mktime((1999, 12, 12, 0, 0, 0, 0, 0, 0))
6816.2.1 by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument.
170
        builder.build_snapshot(None, [
6973.11.1 by Jelmer Vernooij
Fix export_pot.
171
            ('add', ('', b'root-id', 'directory', '')),
172
            ('add', ('subdir', b'subdir-id', 'directory', '')),
173
            ('add', ('subdir/foo.txt', b'foo-id', 'file', b'content\n'))],
5966.1.1 by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps.
174
            timestamp=foo_time)
175
        builder.finish_series()
176
        b = builder.get_branch()
177
        b.lock_read()
178
        self.addCleanup(b.unlock)
179
        tree = b.basis_tree()
180
        export.export(tree, 'target', format='dir', subdir='subdir',
7143.15.2 by Jelmer Vernooij
Run autopep8.
181
                      per_file_timestamps=True)
5966.1.1 by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps.
182
        t = self.get_transport('target')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
183
        self.assertEqual(foo_time, t.stat('foo.txt').st_mtime)
5966.1.1 by Szilveszter Farkas
Fixed exporting subdirectories with per file timestamps.
184
5718.5.10 by Jelmer Vernooij
Support creating .tar.xz files.
185
186
class TarExporterTests(tests.TestCaseWithTransport):
187
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
188
    def test_xz(self):
5718.5.19 by Jelmer Vernooij
Use features.
189
        self.requireFeature(features.lzma)
190
        import lzma
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
191
        wt = self.make_branch_and_tree('.')
192
        self.build_tree(['a'])
193
        wt.add(["a"])
194
        wt.commit("1")
5718.5.19 by Jelmer Vernooij
Use features.
195
        export.export(wt, 'target.tar.xz', format="txz")
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
196
        tf = tarfile.open(fileobj=lzma.LZMAFile('target.tar.xz'))
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
197
        self.assertEqual(["target/a"], tf.getnames())
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
198
5718.5.17 by Jelmer Vernooij
Support tar.lzma.
199
    def test_lzma(self):
5718.5.19 by Jelmer Vernooij
Use features.
200
        self.requireFeature(features.lzma)
201
        import lzma
5718.5.17 by Jelmer Vernooij
Support tar.lzma.
202
        wt = self.make_branch_and_tree('.')
203
        self.build_tree(['a'])
204
        wt.add(["a"])
205
        wt.commit("1")
5718.5.19 by Jelmer Vernooij
Use features.
206
        export.export(wt, 'target.tar.lzma', format="tlzma")
5718.5.17 by Jelmer Vernooij
Support tar.lzma.
207
        tf = tarfile.open(fileobj=lzma.LZMAFile('target.tar.lzma'))
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
208
        self.assertEqual(["target/a"], tf.getnames())
5718.5.17 by Jelmer Vernooij
Support tar.lzma.
209
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
210
    def test_tgz(self):
211
        wt = self.make_branch_and_tree('.')
212
        self.build_tree(['a'])
213
        wt.add(["a"])
214
        wt.commit("1")
215
        export.export(wt, 'target.tar.gz', format="tgz")
216
        tf = tarfile.open('target.tar.gz')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
217
        self.assertEqual(["target/a"], tf.getnames())
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
218
7240.8.1 by Jelmer Vernooij
Use tree timestamp when exporting.
219
    def test_tgz_consistent_mtime(self):
220
        wt = self.make_branch_and_tree('.')
221
        self.build_tree(['a'])
222
        wt.add(["a"])
223
        timestamp = 1547400500
224
        revid = wt.commit("1", timestamp=timestamp)
225
        revtree = wt.branch.repository.revision_tree(revid)
226
        export.export(revtree, 'target.tar.gz', format="tgz")
227
        with gzip.GzipFile('target.tar.gz', 'r') as f:
228
            f.read()
229
            self.assertEqual(int(f.mtime), timestamp)
230
5718.5.15 by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file.
231
    def test_tgz_ignores_dest_path(self):
232
        # The target path should not be a part of the target file.
233
        # (bug #102234)
234
        wt = self.make_branch_and_tree('.')
235
        self.build_tree(['a'])
236
        wt.add(["a"])
237
        wt.commit("1")
238
        os.mkdir("testdir1")
239
        os.mkdir("testdir2")
240
        export.export(wt, 'testdir1/target.tar.gz', format="tgz",
7143.15.2 by Jelmer Vernooij
Run autopep8.
241
                      per_file_timestamps=True)
5718.5.15 by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file.
242
        export.export(wt, 'testdir2/target.tar.gz', format="tgz",
7143.15.2 by Jelmer Vernooij
Run autopep8.
243
                      per_file_timestamps=True)
6973.11.1 by Jelmer Vernooij
Fix export_pot.
244
        file1 = open('testdir1/target.tar.gz', 'rb')
5718.5.15 by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file.
245
        self.addCleanup(file1.close)
6973.11.1 by Jelmer Vernooij
Fix export_pot.
246
        file2 = open('testdir1/target.tar.gz', 'rb')
5718.5.15 by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file.
247
        self.addCleanup(file2.close)
248
        content1 = file1.read()
249
        content2 = file2.read()
250
        self.assertEqualDiff(content1, content2)
251
        # the gzip module doesn't have a way to read back to the original
252
        # filename, but it's stored as-is in the tarfile.
6973.11.1 by Jelmer Vernooij
Fix export_pot.
253
        self.assertFalse(b"testdir1" in content1)
254
        self.assertFalse(b"target.tar.gz" in content1)
255
        self.assertTrue(b"target.tar" in content1)
5718.5.15 by Jelmer Vernooij
Only write out basename of the tarfile to the gzip file.
256
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
257
    def test_tbz2(self):
258
        wt = self.make_branch_and_tree('.')
259
        self.build_tree(['a'])
260
        wt.add(["a"])
261
        wt.commit("1")
262
        export.export(wt, 'target.tar.bz2', format="tbz2")
263
        tf = tarfile.open('target.tar.bz2')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
264
        self.assertEqual(["target/a"], tf.getnames())
5718.5.11 by Jelmer Vernooij
Tests, tests, tests.
265
5967.6.2 by Martin Pool
Delete fairly useless and repetitive per-format export single-call functions.
266
    def test_export_tarball_generator(self):
5718.5.12 by Jelmer Vernooij
Add test for export_tarball.
267
        wt = self.make_branch_and_tree('.')
268
        self.build_tree(['a'])
269
        wt.add(["a"])
270
        wt.commit("1", timestamp=42)
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
271
        target = BytesIO()
6968.2.7 by Jelmer Vernooij
Add breezy.archive.
272
        with wt.lock_read():
273
            target.writelines(tarball_generator(wt, "bar"))
5967.6.3 by Martin Pool
Further shrink export code
274
        # Ball should now be closed.
275
        target.seek(0)
276
        ball2 = tarfile.open(None, "r", target)
277
        self.addCleanup(ball2.close)
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
278
        self.assertEqual(["bar/a"], ball2.getnames())
5718.5.14 by Jelmer Vernooij
Add test for per-file-timestamp zipfiles.
279
280
281
class ZipExporterTests(tests.TestCaseWithTransport):
282
283
    def test_per_file_timestamps(self):
284
        tree = self.make_branch_and_tree('.')
6855.4.1 by Jelmer Vernooij
Yet more bees.
285
        self.build_tree_contents([('har', b'foo')])
5718.5.14 by Jelmer Vernooij
Add test for per-file-timestamp zipfiles.
286
        tree.add('har')
287
        # Earliest allowable date on FAT32 filesystems is 1980-01-01
5718.5.26 by Jelmer Vernooij
Work around zip info time zone issues.
288
        timestamp = 347151600
289
        tree.commit('setup', timestamp=timestamp)
5718.5.14 by Jelmer Vernooij
Add test for per-file-timestamp zipfiles.
290
        export.export(tree.basis_tree(), 'test.zip', format='zip',
7143.15.2 by Jelmer Vernooij
Run autopep8.
291
                      per_file_timestamps=True)
5718.5.14 by Jelmer Vernooij
Add test for per-file-timestamp zipfiles.
292
        zfile = zipfile.ZipFile('test.zip')
293
        info = zfile.getinfo("test/har")
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
294
        self.assertEqual(time.localtime(timestamp)[:6], info.date_time)
5718.5.18 by Jelmer Vernooij
Don't export to '-', but rather to ''.
295
296
297
class RootNameTests(tests.TestCase):
298
299
    def test_root_name(self):
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
300
        self.assertEqual('mytest', get_root_name('../mytest.tar'))
301
        self.assertEqual('mytar', get_root_name('mytar.tar'))
302
        self.assertEqual('mytar', get_root_name('mytar.tar.bz2'))
303
        self.assertEqual('tar.tar.tar', get_root_name('tar.tar.tar.tgz'))
304
        self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5.tar.gz'))
305
        self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5.zip'))
306
        self.assertEqual('bzr-0.0.5', get_root_name('bzr-0.0.5'))
307
        self.assertEqual('mytar', get_root_name('a/long/path/mytar.tgz'))
308
        self.assertEqual('other',
7143.15.2 by Jelmer Vernooij
Run autopep8.
309
                         get_root_name('../parent/../dir/other.tbz2'))
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
310
        self.assertEqual('', get_root_name('-'))