blob: cd58c9a459416410739639717ecb05798ba3e97c [file] [log] [blame]
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +00001import sys
2import os
3import shutil
Brett Cannon455ea532003-06-12 08:01:06 +00004import tempfile
Georg Brandl38c6a222006-05-10 16:26:03 +00005import StringIO
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +00006
7import unittest
8import tarfile
9
10from test import test_support
11
12# Check for our compression modules.
13try:
14 import gzip
Neal Norwitzae323192003-04-14 01:18:32 +000015 gzip.GzipFile
16except (ImportError, AttributeError):
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000017 gzip = None
18try:
19 import bz2
20except ImportError:
21 bz2 = None
22
23def path(path):
24 return test_support.findfile(path)
25
Brett Cannon455ea532003-06-12 08:01:06 +000026testtar = path("testtar.tar")
27tempdir = os.path.join(tempfile.gettempdir(), "testtar" + os.extsep + "dir")
28tempname = test_support.TESTFN
Georg Brandl38c6a222006-05-10 16:26:03 +000029membercount = 12
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000030
31def tarname(comp=""):
32 if not comp:
33 return testtar
Brett Cannon43e559a2003-06-12 19:16:58 +000034 return os.path.join(tempdir, "%s%s%s" % (testtar, os.extsep, comp))
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000035
36def dirname():
37 if not os.path.exists(tempdir):
38 os.mkdir(tempdir)
39 return tempdir
40
41def tmpname():
42 return tempname
43
44
45class BaseTest(unittest.TestCase):
46 comp = ''
47 mode = 'r'
48 sep = ':'
49
50 def setUp(self):
51 mode = self.mode + self.sep + self.comp
52 self.tar = tarfile.open(tarname(self.comp), mode)
53
54 def tearDown(self):
55 self.tar.close()
56
57class ReadTest(BaseTest):
58
59 def test(self):
60 """Test member extraction.
61 """
62 members = 0
63 for tarinfo in self.tar:
64 members += 1
65 if not tarinfo.isreg():
66 continue
67 f = self.tar.extractfile(tarinfo)
68 self.assert_(len(f.read()) == tarinfo.size,
69 "size read does not match expected size")
70 f.close()
71
72 self.assert_(members == membercount,
73 "could not find all members")
74
75 def test_sparse(self):
76 """Test sparse member extraction.
77 """
78 if self.sep != "|":
79 f1 = self.tar.extractfile("S-SPARSE")
Jack Jansen149a8992003-03-07 13:27:53 +000080 f2 = self.tar.extractfile("S-SPARSE-WITH-NULLS")
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000081 self.assert_(f1.read() == f2.read(),
82 "_FileObject failed on sparse file member")
83
84 def test_readlines(self):
85 """Test readlines() method of _FileObject.
86 """
87 if self.sep != "|":
Jack Jansen149a8992003-03-07 13:27:53 +000088 filename = "0-REGTYPE-TEXT"
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000089 self.tar.extract(filename, dirname())
Jack Jansenc7fcc2d2003-03-07 12:50:45 +000090 lines1 = file(os.path.join(dirname(), filename), "rU").readlines()
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +000091 lines2 = self.tar.extractfile(filename).readlines()
92 self.assert_(lines1 == lines2,
93 "_FileObject.readline() does not work correctly")
94
Martin v. Löwisdf241532005-03-03 08:17:42 +000095 def test_iter(self):
96 # Test iteration over ExFileObject.
97 if self.sep != "|":
98 filename = "0-REGTYPE-TEXT"
99 self.tar.extract(filename, dirname())
100 lines1 = file(os.path.join(dirname(), filename), "rU").readlines()
101 lines2 = [line for line in self.tar.extractfile(filename)]
102 self.assert_(lines1 == lines2,
103 "ExFileObject iteration does not work correctly")
104
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000105 def test_seek(self):
106 """Test seek() method of _FileObject, incl. random reading.
107 """
108 if self.sep != "|":
Jack Jansen149a8992003-03-07 13:27:53 +0000109 filename = "0-REGTYPE"
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000110 self.tar.extract(filename, dirname())
111 data = file(os.path.join(dirname(), filename), "rb").read()
112
113 tarinfo = self.tar.getmember(filename)
114 fobj = self.tar.extractfile(tarinfo)
115
116 text = fobj.read()
117 fobj.seek(0)
118 self.assert_(0 == fobj.tell(),
119 "seek() to file's start failed")
120 fobj.seek(2048, 0)
121 self.assert_(2048 == fobj.tell(),
122 "seek() to absolute position failed")
123 fobj.seek(-1024, 1)
124 self.assert_(1024 == fobj.tell(),
125 "seek() to negative relative position failed")
126 fobj.seek(1024, 1)
127 self.assert_(2048 == fobj.tell(),
128 "seek() to positive relative position failed")
129 s = fobj.read(10)
130 self.assert_(s == data[2048:2058],
131 "read() after seek failed")
132 fobj.seek(0, 2)
133 self.assert_(tarinfo.size == fobj.tell(),
134 "seek() to file's end failed")
135 self.assert_(fobj.read() == "",
136 "read() at file's end did not return empty string")
137 fobj.seek(-tarinfo.size, 2)
138 self.assert_(0 == fobj.tell(),
139 "relative seek() to file's start failed")
140 fobj.seek(512)
141 s1 = fobj.readlines()
142 fobj.seek(512)
143 s2 = fobj.readlines()
144 self.assert_(s1 == s2,
145 "readlines() after seek failed")
146 fobj.close()
147
Neal Norwitzf3396542005-10-28 05:52:22 +0000148 def test_old_dirtype(self):
149 """Test old style dirtype member (bug #1336623).
150 """
151 # Old tars create directory members using a REGTYPE
152 # header with a "/" appended to the filename field.
153
154 # Create an old tar style directory entry.
155 filename = tmpname()
156 tarinfo = tarfile.TarInfo("directory/")
157 tarinfo.type = tarfile.REGTYPE
158
159 fobj = file(filename, "w")
160 fobj.write(tarinfo.tobuf())
161 fobj.close()
162
163 try:
164 # Test if it is still a directory entry when
165 # read back.
166 tar = tarfile.open(filename)
167 tarinfo = tar.getmembers()[0]
168 tar.close()
169
170 self.assert_(tarinfo.type == tarfile.DIRTYPE)
171 self.assert_(tarinfo.name.endswith("/"))
172 finally:
173 try:
174 os.unlink(filename)
175 except:
176 pass
177
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000178class ReadStreamTest(ReadTest):
179 sep = "|"
180
181 def test(self):
182 """Test member extraction, and for StreamError when
183 seeking backwards.
184 """
185 ReadTest.test(self)
186 tarinfo = self.tar.getmembers()[0]
187 f = self.tar.extractfile(tarinfo)
188 self.assertRaises(tarfile.StreamError, f.read)
189
190 def test_stream(self):
191 """Compare the normal tar and the stream tar.
192 """
193 stream = self.tar
194 tar = tarfile.open(tarname(), 'r')
195
196 while 1:
197 t1 = tar.next()
198 t2 = stream.next()
199 if t1 is None:
200 break
201 self.assert_(t2 is not None, "stream.next() failed.")
202
203 if t2.islnk() or t2.issym():
204 self.assertRaises(tarfile.StreamError, stream.extractfile, t2)
205 continue
206 v1 = tar.extractfile(t1)
207 v2 = stream.extractfile(t2)
208 if v1 is None:
209 continue
210 self.assert_(v2 is not None, "stream.extractfile() failed")
211 self.assert_(v1.read() == v2.read(), "stream extraction failed")
212
213 stream.close()
214
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000215class ReadDetectTest(ReadTest):
216
217 def setUp(self):
218 self.tar = tarfile.open(tarname(self.comp), self.mode)
219
220class ReadDetectFileobjTest(ReadTest):
221
222 def setUp(self):
223 name = tarname(self.comp)
224 self.tar = tarfile.open(name, mode=self.mode, fileobj=file(name))
225
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000226class ReadAsteriskTest(ReadTest):
227
228 def setUp(self):
229 mode = self.mode + self.sep + "*"
230 self.tar = tarfile.open(tarname(self.comp), mode)
231
232class ReadStreamAsteriskTest(ReadStreamTest):
233
234 def setUp(self):
235 mode = self.mode + self.sep + "*"
236 self.tar = tarfile.open(tarname(self.comp), mode)
237
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000238class WriteTest(BaseTest):
239 mode = 'w'
240
241 def setUp(self):
242 mode = self.mode + self.sep + self.comp
243 self.src = tarfile.open(tarname(self.comp), 'r')
Martin v. Löwisc234a522004-08-22 21:28:33 +0000244 self.dstname = tmpname()
245 self.dst = tarfile.open(self.dstname, mode)
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000246
247 def tearDown(self):
248 self.src.close()
249 self.dst.close()
250
251 def test_posix(self):
252 self.dst.posix = 1
253 self._test()
254
255 def test_nonposix(self):
256 self.dst.posix = 0
257 self._test()
258
Martin v. Löwisc234a522004-08-22 21:28:33 +0000259 def test_small(self):
260 self.dst.add(os.path.join(os.path.dirname(__file__),"cfgparser.1"))
261 self.dst.close()
262 self.assertNotEqual(os.stat(self.dstname).st_size, 0)
263
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000264 def _test(self):
265 for tarinfo in self.src:
266 if not tarinfo.isreg():
267 continue
268 f = self.src.extractfile(tarinfo)
Georg Brandl38c6a222006-05-10 16:26:03 +0000269 if self.dst.posix and len(tarinfo.name) > tarfile.LENGTH_NAME and "/" not in tarinfo.name:
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000270 self.assertRaises(ValueError, self.dst.addfile,
271 tarinfo, f)
272 else:
273 self.dst.addfile(tarinfo, f)
274
Martin v. Löwis5dbdc592005-08-27 10:07:56 +0000275class WriteSize0Test(BaseTest):
276 mode = 'w'
277
278 def setUp(self):
279 self.tmpdir = dirname()
280 self.dstname = tmpname()
281 self.dst = tarfile.open(self.dstname, "w")
282
283 def tearDown(self):
284 self.dst.close()
285
286 def test_file(self):
287 path = os.path.join(self.tmpdir, "file")
288 file(path, "w")
289 tarinfo = self.dst.gettarinfo(path)
290 self.assertEqual(tarinfo.size, 0)
291 file(path, "w").write("aaa")
292 tarinfo = self.dst.gettarinfo(path)
293 self.assertEqual(tarinfo.size, 3)
294
295 def test_directory(self):
296 path = os.path.join(self.tmpdir, "directory")
297 os.mkdir(path)
298 tarinfo = self.dst.gettarinfo(path)
299 self.assertEqual(tarinfo.size, 0)
300
301 def test_symlink(self):
302 if hasattr(os, "symlink"):
303 path = os.path.join(self.tmpdir, "symlink")
304 os.symlink("link_target", path)
305 tarinfo = self.dst.gettarinfo(path)
306 self.assertEqual(tarinfo.size, 0)
307
308
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000309class WriteStreamTest(WriteTest):
310 sep = '|'
311
Neal Norwitz0662f8a2004-07-20 21:54:18 +0000312class WriteGNULongTest(unittest.TestCase):
313 """This testcase checks for correct creation of GNU Longname
314 and Longlink extensions.
315
316 It creates a tarfile and adds empty members with either
317 long names, long linknames or both and compares the size
318 of the tarfile with the expected size.
319
320 It checks for SF bug #812325 in TarFile._create_gnulong().
321
322 While I was writing this testcase, I noticed a second bug
323 in the same method:
324 Long{names,links} weren't null-terminated which lead to
325 bad tarfiles when their length was a multiple of 512. This
326 is tested as well.
327 """
328
329 def setUp(self):
330 self.tar = tarfile.open(tmpname(), "w")
331 self.tar.posix = False
332
333 def tearDown(self):
334 self.tar.close()
335
336 def _length(self, s):
337 blocks, remainder = divmod(len(s) + 1, 512)
338 if remainder:
339 blocks += 1
340 return blocks * 512
341
342 def _calc_size(self, name, link=None):
343 # initial tar header
344 count = 512
345
346 if len(name) > tarfile.LENGTH_NAME:
347 # gnu longname extended header + longname
348 count += 512
349 count += self._length(name)
350
351 if link is not None and len(link) > tarfile.LENGTH_LINK:
352 # gnu longlink extended header + longlink
353 count += 512
354 count += self._length(link)
355
356 return count
357
358 def _test(self, name, link=None):
359 tarinfo = tarfile.TarInfo(name)
360 if link:
361 tarinfo.linkname = link
362 tarinfo.type = tarfile.LNKTYPE
363
364 self.tar.addfile(tarinfo)
365
366 v1 = self._calc_size(name, link)
367 v2 = self.tar.offset
368 self.assertEqual(v1, v2, "GNU longname/longlink creation failed")
369
370 def test_longname_1023(self):
371 self._test(("longnam/" * 127) + "longnam")
372
373 def test_longname_1024(self):
374 self._test(("longnam/" * 127) + "longname")
375
376 def test_longname_1025(self):
377 self._test(("longnam/" * 127) + "longname_")
378
379 def test_longlink_1023(self):
380 self._test("name", ("longlnk/" * 127) + "longlnk")
381
382 def test_longlink_1024(self):
383 self._test("name", ("longlnk/" * 127) + "longlink")
384
385 def test_longlink_1025(self):
386 self._test("name", ("longlnk/" * 127) + "longlink_")
387
388 def test_longnamelink_1023(self):
389 self._test(("longnam/" * 127) + "longnam",
390 ("longlnk/" * 127) + "longlnk")
391
392 def test_longnamelink_1024(self):
393 self._test(("longnam/" * 127) + "longname",
394 ("longlnk/" * 127) + "longlink")
395
396 def test_longnamelink_1025(self):
397 self._test(("longnam/" * 127) + "longname_",
398 ("longlnk/" * 127) + "longlink_")
399
Georg Brandl38c6a222006-05-10 16:26:03 +0000400class ReadGNULongTest(unittest.TestCase):
401
402 def setUp(self):
403 self.tar = tarfile.open(tarname())
404
405 def tearDown(self):
406 self.tar.close()
407
408 def test_1471427(self):
409 """Test reading of longname (bug #1471427).
410 """
411 name = "test/" * 20 + "0-REGTYPE"
412 try:
413 tarinfo = self.tar.getmember(name)
414 except KeyError:
415 tarinfo = None
416 self.assert_(tarinfo is not None, "longname not found")
417 self.assert_(tarinfo.type != tarfile.DIRTYPE, "read longname as dirtype")
418
419 def test_read_name(self):
420 name = ("0-LONGNAME-" * 10)[:101]
421 try:
422 tarinfo = self.tar.getmember(name)
423 except KeyError:
424 tarinfo = None
425 self.assert_(tarinfo is not None, "longname not found")
426
427 def test_read_link(self):
428 link = ("1-LONGLINK-" * 10)[:101]
429 name = ("0-LONGNAME-" * 10)[:101]
430 try:
431 tarinfo = self.tar.getmember(link)
432 except KeyError:
433 tarinfo = None
434 self.assert_(tarinfo is not None, "longlink not found")
435 self.assert_(tarinfo.linkname == name, "linkname wrong")
436
437 def test_truncated_longname(self):
438 fobj = StringIO.StringIO(file(tarname()).read(1024))
439 tar = tarfile.open(name="foo.tar", fileobj=fobj)
440 self.assert_(len(tar.getmembers()) == 0, "")
441
442
Neal Norwitza4f651a2004-07-20 22:07:44 +0000443class ExtractHardlinkTest(BaseTest):
444
445 def test_hardlink(self):
446 """Test hardlink extraction (bug #857297)
447 """
448 # Prevent errors from being caught
449 self.tar.errorlevel = 1
450
451 self.tar.extract("0-REGTYPE", dirname())
452 try:
453 # Extract 1-LNKTYPE which is a hardlink to 0-REGTYPE
454 self.tar.extract("1-LNKTYPE", dirname())
455 except EnvironmentError, e:
456 import errno
457 if e.errno == errno.ENOENT:
458 self.fail("hardlink not extracted properly")
459
Neal Norwitzb0e32e22005-10-20 04:50:13 +0000460class CreateHardlinkTest(BaseTest):
461 """Test the creation of LNKTYPE (hardlink) members in an archive.
462 In this respect tarfile.py mimics the behaviour of GNU tar: If
463 a file has a st_nlink > 1, it will be added a REGTYPE member
464 only the first time.
465 """
466
467 def setUp(self):
468 self.tar = tarfile.open(tmpname(), "w")
469
470 self.foo = os.path.join(dirname(), "foo")
471 self.bar = os.path.join(dirname(), "bar")
472
473 if os.path.exists(self.foo):
474 os.remove(self.foo)
475 if os.path.exists(self.bar):
476 os.remove(self.bar)
477
478 file(self.foo, "w").write("foo")
479 self.tar.add(self.foo)
480
481 def test_add_twice(self):
482 # If st_nlink == 1 then the same file will be added as
483 # REGTYPE every time.
484 tarinfo = self.tar.gettarinfo(self.foo)
485 self.assertEqual(tarinfo.type, tarfile.REGTYPE,
486 "add file as regular failed")
487
488 def test_add_hardlink(self):
489 # If st_nlink > 1 then the same file will be added as
490 # LNKTYPE.
491 os.link(self.foo, self.bar)
492 tarinfo = self.tar.gettarinfo(self.foo)
493 self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
494 "add file as hardlink failed")
495
496 tarinfo = self.tar.gettarinfo(self.bar)
497 self.assertEqual(tarinfo.type, tarfile.LNKTYPE,
498 "add file as hardlink failed")
499
500 def test_dereference_hardlink(self):
501 self.tar.dereference = True
502 os.link(self.foo, self.bar)
503 tarinfo = self.tar.gettarinfo(self.bar)
504 self.assertEqual(tarinfo.type, tarfile.REGTYPE,
505 "dereferencing hardlink failed")
506
Neal Norwitza4f651a2004-07-20 22:07:44 +0000507
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000508# Gzip TestCases
509class ReadTestGzip(ReadTest):
510 comp = "gz"
511class ReadStreamTestGzip(ReadStreamTest):
512 comp = "gz"
513class WriteTestGzip(WriteTest):
514 comp = "gz"
515class WriteStreamTestGzip(WriteStreamTest):
516 comp = "gz"
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000517class ReadDetectTestGzip(ReadDetectTest):
518 comp = "gz"
519class ReadDetectFileobjTestGzip(ReadDetectFileobjTest):
520 comp = "gz"
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000521class ReadAsteriskTestGzip(ReadAsteriskTest):
522 comp = "gz"
523class ReadStreamAsteriskTestGzip(ReadStreamAsteriskTest):
524 comp = "gz"
525
Andrew M. Kuchlingd4f25522004-10-20 11:47:01 +0000526# Filemode test cases
527
528class FileModeTest(unittest.TestCase):
529 def test_modes(self):
530 self.assertEqual(tarfile.filemode(0755), '-rwxr-xr-x')
531 self.assertEqual(tarfile.filemode(07111), '---s--s--t')
532
Tim Peters8ceefc52004-10-25 03:19:41 +0000533
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000534if bz2:
535 # Bzip2 TestCases
536 class ReadTestBzip2(ReadTestGzip):
537 comp = "bz2"
538 class ReadStreamTestBzip2(ReadStreamTestGzip):
539 comp = "bz2"
540 class WriteTestBzip2(WriteTest):
541 comp = "bz2"
542 class WriteStreamTestBzip2(WriteStreamTestGzip):
543 comp = "bz2"
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000544 class ReadDetectTestBzip2(ReadDetectTest):
545 comp = "bz2"
546 class ReadDetectFileobjTestBzip2(ReadDetectFileobjTest):
547 comp = "bz2"
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000548 class ReadAsteriskTestBzip2(ReadAsteriskTest):
549 comp = "bz2"
550 class ReadStreamAsteriskTestBzip2(ReadStreamAsteriskTest):
551 comp = "bz2"
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000552
553# If importing gzip failed, discard the Gzip TestCases.
554if not gzip:
555 del ReadTestGzip
556 del ReadStreamTestGzip
557 del WriteTestGzip
558 del WriteStreamTestGzip
559
Neal Norwitz996acf12003-02-17 14:51:41 +0000560def test_main():
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000561 if gzip:
562 # create testtar.tar.gz
563 gzip.open(tarname("gz"), "wb").write(file(tarname(), "rb").read())
564 if bz2:
565 # create testtar.tar.bz2
566 bz2.BZ2File(tarname("bz2"), "wb").write(file(tarname(), "rb").read())
567
Walter Dörwald21d3a322003-05-01 17:45:56 +0000568 tests = [
Andrew M. Kuchlingd4f25522004-10-20 11:47:01 +0000569 FileModeTest,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000570 ReadTest,
571 ReadStreamTest,
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000572 ReadDetectTest,
573 ReadDetectFileobjTest,
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000574 ReadAsteriskTest,
575 ReadStreamAsteriskTest,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000576 WriteTest,
Martin v. Löwis5dbdc592005-08-27 10:07:56 +0000577 WriteSize0Test,
Neal Norwitz0662f8a2004-07-20 21:54:18 +0000578 WriteStreamTest,
579 WriteGNULongTest,
Georg Brandl38c6a222006-05-10 16:26:03 +0000580 ReadGNULongTest,
Walter Dörwald21d3a322003-05-01 17:45:56 +0000581 ]
582
Neal Norwitza4f651a2004-07-20 22:07:44 +0000583 if hasattr(os, "link"):
584 tests.append(ExtractHardlinkTest)
Neal Norwitzb0e32e22005-10-20 04:50:13 +0000585 tests.append(CreateHardlinkTest)
Neal Norwitza4f651a2004-07-20 22:07:44 +0000586
Walter Dörwald21d3a322003-05-01 17:45:56 +0000587 if gzip:
588 tests.extend([
589 ReadTestGzip, ReadStreamTestGzip,
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000590 WriteTestGzip, WriteStreamTestGzip,
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000591 ReadDetectTestGzip, ReadDetectFileobjTestGzip,
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000592 ReadAsteriskTestGzip, ReadStreamAsteriskTestGzip
Walter Dörwald21d3a322003-05-01 17:45:56 +0000593 ])
594
595 if bz2:
596 tests.extend([
597 ReadTestBzip2, ReadStreamTestBzip2,
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000598 WriteTestBzip2, WriteStreamTestBzip2,
Georg Brandl49c8f4c2006-05-15 19:30:35 +0000599 ReadDetectTestBzip2, ReadDetectFileobjTestBzip2,
Martin v. Löwis78be7df2005-03-05 12:47:42 +0000600 ReadAsteriskTestBzip2, ReadStreamAsteriskTestBzip2
Walter Dörwald21d3a322003-05-01 17:45:56 +0000601 ])
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000602 try:
Walter Dörwald21d3a322003-05-01 17:45:56 +0000603 test_support.run_unittest(*tests)
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000604 finally:
605 if gzip:
606 os.remove(tarname("gz"))
607 if bz2:
608 os.remove(tarname("bz2"))
Brett Cannon455ea532003-06-12 08:01:06 +0000609 if os.path.exists(dirname()):
610 shutil.rmtree(dirname())
611 if os.path.exists(tmpname()):
612 os.remove(tmpname())
Neal Norwitzb9ef4ae2003-01-05 23:19:43 +0000613
Neal Norwitz996acf12003-02-17 14:51:41 +0000614if __name__ == "__main__":
615 test_main()