Commit 4727cce3 authored by Ximin Luo's avatar Ximin Luo

skip_unless_tool_is_older_than => skip_unless_tool_is_at_least

parent 6e7d6b3f
......@@ -23,7 +23,7 @@ from diffoscope.config import Config
from diffoscope.comparators.dex import DexFile
from diffoscope.comparators.binary import NonExistingFile
from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_older_than
from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_at_least
from test_java import javap_version
......@@ -42,7 +42,7 @@ def differences(dex1, dex2):
return dex1.compare(dex2).details
@skip_unless_tools_exist('enjarify', 'zipinfo', 'javap')
@skip_unless_tool_is_older_than('javap', javap_version, '1.8')
@skip_unless_tool_is_at_least('javap', javap_version, '1.8')
def test_differences(differences):
assert differences[0].source1 == 'test1.jar'
assert differences[0].source2 == 'test2.jar'
......
......@@ -24,7 +24,7 @@ from diffoscope.config import Config
from diffoscope.comparators.java import ClassFile
from diffoscope.comparators.binary import NonExistingFile
from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_older_than
from utils import skip_unless_tools_exist, data, load_fixture, skip_unless_tool_is_at_least
class1 = load_fixture(data('Test1.class'))
class2 = load_fixture(data('Test2.class'))
......@@ -47,7 +47,7 @@ def test_no_differences(class1):
def differences(class1, class2):
return class1.compare(class2).details
@skip_unless_tool_is_older_than('javap', javap_version, '1.8')
@skip_unless_tool_is_at_least('javap', javap_version, '1.8')
def test_diff(differences):
expected_diff = open(data('class_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
......
......@@ -24,7 +24,7 @@ import subprocess
from diffoscope.comparators.ppu import PpuFile
from utils import skip_unless_tools_exist, data, load_fixture, \
assert_non_existing, skip_unless_tool_is_older_than
assert_non_existing, skip_unless_tool_is_at_least
# These test files were taken from two different builds of the Debian package
# fp-units-castle-game-engine (version 5.1.1-2 on amd64) on the Debian
......@@ -53,12 +53,12 @@ def test_no_differences(file1):
def differences(file1, file2):
return file1.compare(file2).details
@skip_unless_tool_is_older_than('ppudump', ppudump_version, '3.0.0')
@skip_unless_tool_is_at_least('ppudump', ppudump_version, '3.0.0')
def test_diff(differences):
print(differences[0].unified_diff)
expected_diff = open(data('ppu_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
@skip_unless_tool_is_older_than('ppudump', ppudump_version, '3.0.0')
@skip_unless_tool_is_at_least('ppudump', ppudump_version, '3.0.0')
def test_compare_non_existing(monkeypatch, file1):
assert_non_existing(monkeypatch, file1, has_null_source=False)
......@@ -24,7 +24,7 @@ import subprocess
from diffoscope.comparators.ar import ArFile
from diffoscope.comparators.utils import diff_ignore_line_numbers
from utils import skip_unless_tools_exist, skip_unless_tool_is_older_than, \
from utils import skip_unless_tools_exist, skip_unless_tool_is_at_least, \
skip_unless_tools_exist, data, load_fixture, assert_non_existing
rlib1 = load_fixture(data('test1.rlib'))
......@@ -68,7 +68,7 @@ def test_item2_rust_metadata_bin(differences):
assert differences[2].source2 == 'rust.metadata.bin'
@skip_unless_tools_exist('llvm-dis')
@skip_unless_tool_is_older_than('llvm-config', llvm_version, '3.8')
@skip_unless_tool_is_at_least('llvm-config', llvm_version, '3.8')
def test_item3_deflate_llvm_bitcode(differences):
assert differences[3].source1 == 'alloc_system-d16b8f0e.0.bytecode.deflate'
assert differences[3].source2 == 'alloc_system-d16b8f0e.0.bytecode.deflate'
......
......@@ -23,7 +23,7 @@ import subprocess
from diffoscope.comparators.squashfs import SquashfsFile
from utils import skip_unless_tools_exist, data, load_fixture, \
assert_non_existing, skip_unless_tool_is_older_than
assert_non_existing, skip_unless_tool_is_at_least
def unsquashfs_version():
# first line of 'unsquashfs -version' looks like:
......@@ -53,7 +53,7 @@ def test_no_warnings(capfd, squashfs1, squashfs2):
def differences(squashfs1, squashfs2):
return squashfs1.compare(squashfs2).details
@skip_unless_tool_is_older_than('unsquashfs', unsquashfs_version, '4.3')
@skip_unless_tool_is_at_least('unsquashfs', unsquashfs_version, '4.3')
def test_superblock(differences):
expected_diff = open(data('squashfs_superblock_expected_diff')).read()
assert differences[0].unified_diff == expected_diff
......
......@@ -25,7 +25,7 @@ from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from utils import tools_missing, skip_unless_tools_exist, data, load_fixture, \
skip_unless_tool_is_older_than
skip_unless_tool_is_at_least
try:
import tlsh # noqa
......@@ -51,8 +51,8 @@ def test_skip_unless_tools_exist_empty():
def test_skip_unless_tools_exist_missing():
pytest.xfail("Test should always be skipped")
def skip_unless_tool_is_older_than():
func = skip_unless_tool_is_older_than
def skip_unless_tool_is_at_least():
func = skip_unless_tool_is_at_least
assert func('/missing', 1, 1).name is 'skip'
# pytest.skipif().args[0] contains the evaluated statement
assert func('cat', 1, 1).args[0] is False
......
......@@ -44,7 +44,7 @@ def skip_unless_tools_exist(*required):
reason="requires {}".format(" and ".join(required)),
)
def skip_unless_tool_is_older_than(tool, actual_ver, min_ver, vcls=LooseVersion):
def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion):
if tools_missing(tool):
return pytest.mark.skipif(True, reason="requires {}".format(tool))
if callable(actual_ver):
......
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