Skip to content

Commit

Permalink
More tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Feb 23, 2019
1 parent 9710186 commit 6267ffd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion detools/apply_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def _read_header(fpatch):

if compression not in ['lzma', 'none']:
raise Error(
'Expected compression lzma or none, but got {}.'.format(
"Expected compression 'lzma' or 'none', but got '{}'.".format(
compression))

to_size = struct.unpack('>q', header[12:20])[0]
Expand Down
Binary file added tests/files/foo-bad-compression.patch
Binary file not shown.
12 changes: 12 additions & 0 deletions tests/test_detools.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ def test_apply_patch_foo_non_ascii_compression(self):
"Failed to decode the compression field in the header "
"(got b'\\xdczma').")

def test_apply_patch_foo_bad_compression(self):
fnew = BytesIO()

with open('tests/files/foo.old', 'rb') as fold:
with open('tests/files/foo-bad-compression.patch', 'rb') as fpatch:
with self.assertRaises(detools.Error) as cm:
detools.apply_patch(fold, fpatch, fnew)

self.assertEqual(
str(cm.exception),
"Expected compression 'lzma' or 'none', but got 'abcd'.")

def test_command_line_create_patch_foo(self):
foo_patch = 'foo.patch'
argv = [
Expand Down

0 comments on commit 6267ffd

Please sign in to comment.