diff --git a/cwltest/__init__.py b/cwltest/__init__.py index eb0aae9..9a71357 100755 --- a/cwltest/__init__.py +++ b/cwltest/__init__.py @@ -21,7 +21,7 @@ from concurrent.futures import ThreadPoolExecutor from six.moves import range from six.moves import zip -from typing import Any, Dict, List +from typing import Any, Dict, List, Text from cwltest.utils import compare, CompareFail, TestResult @@ -39,7 +39,9 @@ templock = threading.Lock() + def prepare_test_command(args, i, tests): + # type: (argparse.Namespace, int, List[Dict[str, str]]) -> List[str] t = tests[i] test_command = [args.tool] test_command.extend(args.args) @@ -82,7 +84,7 @@ def run_test(args, i, tests, timeout): else: suffix = "\n" try: - test_command=prepare_test_command(args, i, tests) + test_command = prepare_test_command(args, i, tests) sys.stderr.write("%sTest [%i/%i] %s\n" % (prefix, i + 1, len(tests), suffix)) sys.stderr.flush() @@ -146,6 +148,7 @@ def run_test(args, i, tests, timeout): return TestResult((1 if fail_message else 0), outstr, outerr, duration, args.classname, fail_message) + def arg_parser(): # type: () -> argparse.ArgumentParser parser = argparse.ArgumentParser(description='Compliance tests for cwltool') parser.add_argument("--test", type=str, help="YAML file describing test cases", required=True) @@ -169,6 +172,7 @@ def arg_parser(): # type: () -> argparse.ArgumentParser "Defaults to 900 sec (15 minutes)") return parser + def main(): # type: () -> int args = arg_parser().parse_args(sys.argv[1:]) diff --git a/mypy.ini b/mypy.ini index 7985b20..225366b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,2 +1,4 @@ +[mypy] + [mypy-ruamel.*] ignore_errors = True diff --git a/tests/test_compare.py b/tests/test_compare.py new file mode 100644 index 0000000..74ae644 --- /dev/null +++ b/tests/test_compare.py @@ -0,0 +1,28 @@ +import unittest +from cwltest import CompareFail +from cwltest.utils import compare_file + + +class TestCompareFile(unittest.TestCase): + + def test_general(self): + expected = { + "location": "cores.txt", + "size": 2, + "class": "File", + "checksum": "sha1$7448d8798a4380162d4b56f9b452e2f6f9e24e7a" + } + + actual = { + "basename": "cores.txt", + "checksum": "sha1$7448d8798a4380162d4b56f9b452e2f6f9e24e7a", + "class": "File", + "location": "file:///var/folders/8x/2df05_7j20j6r8y81w4qf43r0000gn/T/tmpG0EkrS/cores.txt", + "path": "/var/folders/8x/2df05_7j20j6r8y81w4qf43r0000gn/T/tmpG0EkrS/cores.txt", + "size": 2 + } + + try: + compare_file(expected, actual) + except CompareFail: + self.fail("File comparison failed unexpectedly") \ No newline at end of file