Commit 055cae5c authored by Chris Lamb's avatar Chris Lamb 💬

PEP8: E302 - Add missing 2 blank lines.

parent 3c4a5e95
......@@ -126,6 +126,7 @@ class MozillaZipCommandMixin(object):
# which is fine to ignore.
return 0
class MozillaZipinfo(MozillaZipCommandMixin, Zipinfo):
pass
......
......@@ -34,6 +34,7 @@ bootimg2 = load_fixture('android2.img')
# Part of the bug: https://bugs.debian.org/725729
bearch = sys.byteorder == 'big'
def test_identification(bootimg1):
assert isinstance(bootimg1, AndroidBootImgFile)
......
......@@ -35,23 +35,29 @@ bzip2 = load_fixture('containers/b.tar.bz2')
TYPES = "gzip bzip2 xz".split()
@pytest.fixture
def set1(gzip1, bzip1, xz1):
return dict(zip(TYPES, [gzip1, bzip1, xz1]))
@pytest.fixture
def set2(gzip2, bzip2, xz2):
return dict(zip(TYPES, [gzip2, bzip2, xz2]))
def expected_magic_diff(ext1, ext2):
meta1 = get_data('containers/magic_%s' % ext1)
meta2 = get_data('containers/magic_%s' % ext2)
return "@@ -1 +1 @@\n" + "-" + meta1 + "+" + meta2
def expected_type_diff(ext1, ext2):
return "@@ -1 +1 @@\n-%sFile\n+%sFile\n" % (ext1.capitalize(), ext2.capitalize())
# Compares same content files, but with different extensions
@skip_unless_tools_exist('xz')
@skip_unless_file_version_is_at_least('5.33')
def test_equal(set1):
......@@ -65,6 +71,8 @@ def test_equal(set1):
assert differences[1].unified_diff == expected_type_diff(x, y)
# Compares different content files with different extensions
@skip_unless_tools_exist('xz')
@skip_unless_file_version_is_at_least('5.33')
def test_different(set1, set2):
......
......@@ -40,11 +40,13 @@ def test_no_differences(pdf1):
difference = pdf1.compare(pdf1)
assert difference is None
def test_differences_found_with_weird_encoding(pdf1a, pdf2a):
# diffoscope used to crash here due to weird encoding
difference = pdf1a.compare(pdf2a)
assert difference
@pytest.fixture
def differences(pdf1, pdf2):
return pdf1.compare(pdf2).details
......
......@@ -52,6 +52,7 @@ def test_no_differences(rlib1):
def differences(rlib1, rlib2):
return rlib1.compare(rlib2).details
@pytest.fixture
def rlib_dis_expected_diff():
actual_ver = llvm_version()
......
......@@ -26,21 +26,27 @@ re_diff_line_numbers = re.compile(r"(^|\n)@@ -(\d+),(\d+) \+(\d+),(\d+) @@(?=\n|
def diff_ignore_line_numbers(diff):
return re_diff_line_numbers.sub(r"\1@@ -XX,XX +XX,XX @@", diff)
def _collapse_line(line, escape=html.escape):
len_ = len(escape(line))
return str(len_ - 1) + "\n" if line[-1] == "\n" else str(len_)
def _diff_collapse_line(line):
return line[0] + _collapse_line(line[1:]) if line and line[0] in '+- ' else line
def _expand_line(line):
return (int(line[:-1]) * ".") + "\n" if line[-1] == "\n" else (int(line) * ".")
def _diff_expand_line(line):
return line[0] + _expand_line(line[1:]) if line and line[0] in '+- ' else line
def diff_collapse(diff):
return diff.map_lines(_diff_collapse_line, _collapse_line)
def diff_expand(diff):
return diff.map_lines(_diff_expand_line, _expand_line)
......@@ -26,6 +26,7 @@ import subprocess
from distutils.spawn import find_executable
from distutils.version import LooseVersion
def file_version():
return subprocess.check_output(
('file', '-v'),
......@@ -42,6 +43,7 @@ def skip_unless_tools_exist(*required):
reason="requires {}".format(" and ".join(required)),
)
def skip_if_tool_version_is(tool, actual_ver, target_ver, vcls=LooseVersion):
if tools_missing(tool):
return pytest.mark.skipif(True, reason="requires {}".format(tool))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment