Skip to content

Commit 31b3a43

Browse files
committed
Improve test expected failures
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
1 parent bd36635 commit 31b3a43

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

tests/extractcode/test_archive.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
# limitations under the License.
2020
#
2121

22-
import io
2322
import os
2423

2524
import pytest
2625

27-
import commoncode.date
26+
from commoncode import date as commoncode_date
2827
from commoncode import fileutils
2928
from commoncode.system import on_linux
3029
from commoncode.system import on_mac
3130
from commoncode.system import on_windows
31+
from commoncode.testcase import is_same
3232

3333
from extractcode_assert_utils import BaseArchiveTestCase
3434
from extractcode_assert_utils import check_files
@@ -40,7 +40,6 @@
4040
from extractcode import ExtractErrorFailedToExtract
4141
from extractcode import libarchive2
4242
from extractcode import sevenzip
43-
from extractcode.libarchive2 import ArchiveError
4443

4544
"""
4645
For each archive type --when possible-- we are testing extraction of:
@@ -383,7 +382,7 @@ def test_extract_targz_with_trailing_data2(self):
383382
test_dir2 = self.get_temp_dir()
384383
test_file2 = self.get_test_loc('archive/tgz/no_trailing.tar.gz')
385384
archive.extract_tar(test_file2, test_dir2)
386-
assert commoncode.testcase.is_same(test_dir1, test_dir2)
385+
assert is_same(test_dir1, test_dir2)
387386

388387
def test_extract_targz_with_mixed_case_and_symlink(self):
389388
test_file = self.get_test_loc('archive/tgz/mixed_case_and_symlink.tgz')
@@ -960,7 +959,7 @@ def test_extract_zip_with_timezone(self):
960959
]
961960
# DST sends a monkey wrench.... so we only test the date, not the time
962961
for loc, expected_date in expected:
963-
result = commoncode.date.get_file_mtime(loc)
962+
result = commoncode_date.get_file_mtime(loc)
964963
assert result.startswith(expected_date)
965964

966965
def test_extract_zip_with_timezone_2(self):
@@ -974,7 +973,7 @@ def test_extract_zip_with_timezone_2(self):
974973
(os.path.join(test_dir, 'primes2.txt'), ('2009-12-05', '2009-12-06',))
975974
]
976975
for loc, expected_date in expected:
977-
result = commoncode.date.get_file_mtime(loc)
976+
result = commoncode_date.get_file_mtime(loc)
978977
assert result.startswith(expected_date)
979978

980979
def test_extract_zip_with_backslash_in_path_1(self):
@@ -1268,7 +1267,7 @@ def test_extract_ar_verify_dates(self):
12681267
]
12691268
# DST sends a monkey wrench.... so we only test the date, not the time
12701269
for loc, expected_date in expected:
1271-
result = commoncode.date.get_file_mtime(loc)
1270+
result = commoncode_date.get_file_mtime(loc)
12721271
assert result.startswith(expected_date)
12731272

12741273
def test_extract_ar_broken_7z(self):
@@ -2318,7 +2317,7 @@ def test_extract_ar_with_weird_filenames_with_libarchive_win(self):
23182317
self.check_extract_weird_names(
23192318
libarchive2.extract, test_file, expected_warnings=[], expected_suffix='libarch')
23202319
self.fail('Exception not raised.')
2321-
except ArchiveError as ae:
2320+
except libarchive2.ArchiveError as ae:
23222321
assert str(ae).startswith('Incorrect file header signature')
23232322

23242323
def test_extract_cpio_with_weird_filenames_with_libarchive_win(self):

tests/extractcode/test_sevenzip.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import os
2222
import json
2323
import posixpath
24-
from unittest.case import skipIf
2524

25+
import pytest
26+
27+
from commoncode import fileutils
2628
from commoncode.testcase import FileBasedTesting
2729
from commoncode.system import on_windows
28-
from commoncode import fileutils
2930

3031
from extractcode import ExtractErrorFailedToExtract
3132
from extractcode import sevenzip
@@ -135,7 +136,7 @@ def test_extract_of_tar_with_aboslute_path(self):
135136

136137
class TestSevenZipListEntries(TestSevenZip):
137138

138-
@skipIf(on_windows, 'Windows file-by-file extracton is not working well')
139+
@pytest.mark.skipif(on_windows, reason='Windows file-by-file extracton is not working well')
139140
def test_list_entries_of_special_tar(self):
140141
test_loc = self.get_test_loc('sevenzip/special.tar')
141142
expected_loc = test_loc + '-entries-expected.json'
@@ -145,7 +146,7 @@ def test_list_entries_of_special_tar(self):
145146
results = entries + errors
146147
self.check_results_with_expected_json(results, expected_loc, regen=False)
147148

148-
@skipIf(not on_windows, 'Windows file-by-file extracton is not working well')
149+
@pytest.mark.skipif(not on_windows, reason='Windows file-by-file extracton is not working well')
149150
def test_list_entries_of_special_tar_win(self):
150151
test_loc = self.get_test_loc('sevenzip/special.tar')
151152
expected_loc = test_loc + '-entries-expected-win.json'
@@ -155,7 +156,7 @@ def test_list_entries_of_special_tar_win(self):
155156
results = entries + errors
156157
self.check_results_with_expected_json(results, expected_loc, clean_dates=True, regen=False)
157158

158-
@skipIf(on_windows, 'Windows file-by-file extracton is not working well')
159+
@pytest.mark.skipif(on_windows, reason='Windows file-by-file extracton is not working well')
159160
def test_list_entries_with_weird_names_7z(self):
160161
test_loc = self.get_test_loc('sevenzip/weird_names.7z')
161162
expected_loc = test_loc + '-entries-expected.json'
@@ -165,7 +166,7 @@ def test_list_entries_with_weird_names_7z(self):
165166
results = entries + errors
166167
self.check_results_with_expected_json(results, expected_loc, regen=False)
167168

168-
@skipIf(not on_windows, 'Windows file-by-file extracton is not working well')
169+
@pytest.mark.skipif(not on_windows, reason='Windows file-by-file extracton is not working well')
169170
def test_list_entries_with_weird_names_7z_win(self):
170171
test_loc = self.get_test_loc('sevenzip/weird_names.7z')
171172
expected_loc = test_loc + '-entries-expected-win.json'
@@ -288,6 +289,7 @@ def test_extract_file_by_file_with_weird_names_7z(self):
288289
def test_extract_file_by_file_weird_names_zip(self):
289290
self.check_extract_file_by_file('sevenzip/weird_names.zip', regen=False)
290291

292+
@pytest.mark.xfail(on_windows, reason='Fails on Windows becasue it has file names that cannot be extracted there')
291293
def test_extract_file_by_file_weird_names_ar(self):
292294
self.check_extract_file_by_file('sevenzip/weird_names.ar', regen=False)
293295

0 commit comments

Comments
 (0)