Skip to content

Commit de1dc1b

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

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

tests/extractcode/test_archive.py

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

22-
import io
2322
import os
2423

2524
import pytest
2625

27-
import commoncode.date
26+
frmo 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
@@ -40,7 +39,6 @@
4039
from extractcode import ExtractErrorFailedToExtract
4140
from extractcode import libarchive2
4241
from extractcode import sevenzip
43-
from extractcode.libarchive2 import ArchiveError
4442

4543
"""
4644
For each archive type --when possible-- we are testing extraction of:
@@ -960,7 +958,7 @@ def test_extract_zip_with_timezone(self):
960958
]
961959
# DST sends a monkey wrench.... so we only test the date, not the time
962960
for loc, expected_date in expected:
963-
result = commoncode.date.get_file_mtime(loc)
961+
result = commoncode_date.get_file_mtime(loc)
964962
assert result.startswith(expected_date)
965963

966964
def test_extract_zip_with_timezone_2(self):
@@ -974,7 +972,7 @@ def test_extract_zip_with_timezone_2(self):
974972
(os.path.join(test_dir, 'primes2.txt'), ('2009-12-05', '2009-12-06',))
975973
]
976974
for loc, expected_date in expected:
977-
result = commoncode.date.get_file_mtime(loc)
975+
result = commoncode_date.get_file_mtime(loc)
978976
assert result.startswith(expected_date)
979977

980978
def test_extract_zip_with_backslash_in_path_1(self):
@@ -1268,7 +1266,7 @@ def test_extract_ar_verify_dates(self):
12681266
]
12691267
# DST sends a monkey wrench.... so we only test the date, not the time
12701268
for loc, expected_date in expected:
1271-
result = commoncode.date.get_file_mtime(loc)
1269+
result = commoncode_date.get_file_mtime(loc)
12721270
assert result.startswith(expected_date)
12731271

12741272
def test_extract_ar_broken_7z(self):
@@ -2318,7 +2316,7 @@ def test_extract_ar_with_weird_filenames_with_libarchive_win(self):
23182316
self.check_extract_weird_names(
23192317
libarchive2.extract, test_file, expected_warnings=[], expected_suffix='libarch')
23202318
self.fail('Exception not raised.')
2321-
except ArchiveError as ae:
2319+
except libarchive2.ArchiveError as ae:
23222320
assert str(ae).startswith('Incorrect file header signature')
23232321

23242322
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.xfail(not 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.xfail(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.xfail(not 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.xfail(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)