Re-organize the unrar test

This commit is contained in:
Kovid Goyal 2017-06-17 15:53:45 +05:30
parent d305656bb4
commit ca7a11a289
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -124,13 +124,6 @@ def test_basic():
c = comment(stream) c = comment(stream)
if c != b'some comment\n': if c != b'some comment\n':
raise ValueError('Comment not read: %r != %r' % (c, b'some comment\n')) raise ValueError('Comment not read: %r != %r' % (c, b'some comment\n'))
for name in tdata:
if name not in '1 2 symlink'.split():
d = extract_member(stream, name=name)[1]
if d != tdata[name]:
raise ValueError(
'Failed to extract %s %r != %r' % (name, d, tdata[name]))
if set(names(stream)) != { if set(names(stream)) != {
'1/sub-one', 'one.txt', '2/sub-two.txt', '诶比屁.txt', 'Füße.txt', '1/sub-one', 'one.txt', '2/sub-two.txt', '诶比屁.txt', 'Füße.txt',
'uncompressed', 'max-compressed'}: 'uncompressed', 'max-compressed'}:
@ -142,6 +135,12 @@ def test_basic():
with open(os.path.join(tdir, name), 'rb') as s: with open(os.path.join(tdir, name), 'rb') as s:
if s.read() != tdata[name]: if s.read() != tdata[name]:
raise ValueError('Did not extract %s properly' % name) raise ValueError('Did not extract %s properly' % name)
for name in tdata:
if name not in '1 2 symlink'.split():
d = extract_member(stream, name=name)
if d is None or d[1] != tdata[name]:
raise ValueError(
'Failed to extract %s %r != %r' % (name, d, tdata[name]))
do_test(stream) do_test(stream)
with PersistentTemporaryFile('test-unrar') as f: with PersistentTemporaryFile('test-unrar') as f: