OLD | NEW |
1 import sys | 1 import sys |
2 import os | 2 import os |
3 import io | 3 import io |
4 from hashlib import md5 | 4 from hashlib import md5 |
5 | 5 |
6 import unittest | 6 import unittest |
7 import tarfile | 7 import tarfile |
8 | 8 |
9 from test import support, script_helper | 9 from test import support, script_helper |
10 | 10 |
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1998 def test_create_command_dot_started_filename(self): | 1998 def test_create_command_dot_started_filename(self): |
1999 tar_name = os.path.join(TEMPDIR, ".testtar") | 1999 tar_name = os.path.join(TEMPDIR, ".testtar") |
2000 files = [support.findfile('tokenize_tests.txt')] | 2000 files = [support.findfile('tokenize_tests.txt')] |
2001 try: | 2001 try: |
2002 out = self.tarfilecmd('-c', tar_name, *files) | 2002 out = self.tarfilecmd('-c', tar_name, *files) |
2003 self.assertEqual(out, b'') | 2003 self.assertEqual(out, b'') |
2004 with tarfile.open(tar_name) as tar: | 2004 with tarfile.open(tar_name) as tar: |
2005 tar.getmembers() | 2005 tar.getmembers() |
2006 finally: | 2006 finally: |
2007 support.unlink(tar_name) | 2007 support.unlink(tar_name) |
| 2008 |
| 2009 def test_create_command_filetype(self): |
| 2010 files = [support.findfile('tokenize_tests.txt'), |
| 2011 support.findfile('tokenize_tests-no-coding-cookie-' |
| 2012 'and-utf8-bom-sig-only.txt')] |
| 2013 |
| 2014 for filetype in (GzipTest, Bz2Test, LzmaTest): |
| 2015 if not filetype.open: |
| 2016 continue |
| 2017 try: |
| 2018 filename = tmpname + '.' + filetype.suffix |
| 2019 out = self.tarfilecmd('-c', filename, *files) |
| 2020 with filetype.taropen(filename, 'r') as tar: |
| 2021 pass |
| 2022 finally: |
| 2023 support.unlink(filename) |
2008 | 2024 |
2009 def test_extract_command(self): | 2025 def test_extract_command(self): |
2010 self.make_simple_tarfile(tmpname) | 2026 self.make_simple_tarfile(tmpname) |
2011 for opt in '-e', '--extract': | 2027 for opt in '-e', '--extract': |
2012 try: | 2028 try: |
2013 with support.temp_cwd(tarextdir): | 2029 with support.temp_cwd(tarextdir): |
2014 out = self.tarfilecmd(opt, tmpname) | 2030 out = self.tarfilecmd(opt, tmpname) |
2015 self.assertEqual(out, b'') | 2031 self.assertEqual(out, b'') |
2016 finally: | 2032 finally: |
2017 support.rmtree(tarextdir) | 2033 support.rmtree(tarextdir) |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 testtarnames.append(c.tarname) | 2199 testtarnames.append(c.tarname) |
2184 with c.open(c.tarname, "wb") as tar: | 2200 with c.open(c.tarname, "wb") as tar: |
2185 tar.write(data) | 2201 tar.write(data) |
2186 | 2202 |
2187 def tearDownModule(): | 2203 def tearDownModule(): |
2188 if os.path.exists(TEMPDIR): | 2204 if os.path.exists(TEMPDIR): |
2189 support.rmtree(TEMPDIR) | 2205 support.rmtree(TEMPDIR) |
2190 | 2206 |
2191 if __name__ == "__main__": | 2207 if __name__ == "__main__": |
2192 unittest.main() | 2208 unittest.main() |
OLD | NEW |