|
|
|
|
@ -39,12 +39,23 @@ def test_compress(disconnect_signals, settings, tmpdir, method,
|
|
|
|
|
compress_suffix, test_import): |
|
|
|
|
if test_import: |
|
|
|
|
pytest.importorskip(test_import) |
|
|
|
|
compress_options = make_gallery(settings, tmpdir, method) |
|
|
|
|
|
|
|
|
|
suffixes = compress_options['suffixes'] |
|
|
|
|
# Compress twice to test compression skip based on mtime |
|
|
|
|
for _ in range(2): |
|
|
|
|
compress_options = make_gallery(settings, tmpdir, method) |
|
|
|
|
|
|
|
|
|
suffixes = compress_options['suffixes'] |
|
|
|
|
|
|
|
|
|
for path, dirs, files in os.walk(settings['destination']): |
|
|
|
|
for file in files: |
|
|
|
|
original_filename = os.path.join(path, file) |
|
|
|
|
compressed_filename = '{}.{}'.format(os.path.join(path, file), compress_suffix) |
|
|
|
|
path_exists = os.path.exists(compressed_filename) |
|
|
|
|
file_ext = os.path.splitext(file)[1][1:] |
|
|
|
|
if file_ext in suffixes: |
|
|
|
|
assert path_exists |
|
|
|
|
assert os.stat(original_filename).st_mtime <= os.stat(compressed_filename).st_mtime |
|
|
|
|
else: |
|
|
|
|
assert not path_exists |
|
|
|
|
assert path_exists if file_ext in suffixes else not path_exists |
|
|
|
|
|
|
|
|
|
for path, dirs, files in os.walk(settings['destination']): |
|
|
|
|
for file in files: |
|
|
|
|
path_exists = os.path.exists('{}.{}'.format(os.path.join(path, file), compress_suffix)) |
|
|
|
|
file_ext = os.path.splitext(file)[1][1:] |
|
|
|
|
assert path_exists if file_ext in suffixes else not path_exists |
|
|
|
|
|