diff --git a/Scripts/GenBank/check_output.py b/Scripts/GenBank/check_output.py index 9431d564011..fa5fcf49365 100644 --- a/Scripts/GenBank/check_output.py +++ b/Scripts/GenBank/check_output.py @@ -33,13 +33,9 @@ def do_comparison(good_record, test_record): good_handle = StringIO(good_record) test_handle = StringIO(test_record) - while True: - good_line = good_handle.readline() - test_line = test_handle.readline() - - if not(good_line) and not(test_line): - break - + good_line = good_handle.readline() + test_line = test_handle.readline() + while good_line or test_line: if not(good_line): if good_line.strip(): raise AssertionError("Extra info in Test: `%s`" % test_line) @@ -51,12 +47,16 @@ def do_comparison(good_record, test_record): assert test_line == good_line, \ "Expected does not match Test.\nExpect:`%s`\nTest :`%s`\n" % \ (good_line, test_line) + + good_line = good_handle.readline() + test_line = test_handle.readline() def write_format(file): record_parser = GenBank.RecordParser(debug_level=2) print("Testing GenBank writing for %s..." % os.path.basename(file)) + # be able to handle gzipped files if '.gz' in file: cur_handle = gzip.open(file, "r") @@ -68,15 +68,9 @@ def write_format(file): iterator = GenBank.Iterator(cur_handle, record_parser) compare_iterator = GenBank.Iterator(compare_handle) - while True: - cur_record = next(iterator) - compare_record = next(compare_iterator) - - if cur_record is None or compare_record is None: - break - - # print("\tTesting for %s" % cur_record.version) - + cur_record = next(iterator) + compare_record = next(compare_iterator) + while cur_record != None and compare_record != None: output_record = str(cur_record) + "\n" try: do_comparison(compare_record, output_record) @@ -84,6 +78,9 @@ def write_format(file): print("\tTesting for %s" % cur_record.version) print(msg) + cur_record = next(iterator) + compare_record = next(compare_iterator) + cur_handle.close() compare_handle.close()