"`liblyrics/..` is into your PYTHONPATH.", file=sys.stderr) sys.exit(2) validdir = os.path.join(os.path.dirname(__file__), "valids") validfiles = [os.path.join(validdir, f) for f in os.listdir(validdir)] tmpdir = None try: tmpdir = tempfile.mkdtemp(prefix="liblyrics-test") for path in validfiles: filename = os.path.basename(path) # Parse file try: lyrics = Lyrics.from_file(path) except ParseException as ex: print("Unable to parse file {}: {}.".format(path, ex), file=sys.stderr) sys.exit(1) # Save file tmpfile = os.path.join(tmpdir, filename) lyrics.save_into(tmpfile) # Compare input and output if not filecmp.cmp(path, tmpfile, shallow=False): print("Error: {}: input and output does not match".format(filename), file=sys.stderr) sys.exit(1) print("{}: Test succeed".format(filename))
"`liblyrics/..` is into your PYTHONPATH.", file=sys.stderr) sys.exit(2) validdir = os.path.join(os.path.dirname(__file__), "valids") validfiles = [os.path.join(validdir, f) for f in os.listdir(validdir)] tmpdir = None try: tmpdir = tempfile.mkdtemp(prefix="liblyrics-test") for path in validfiles: filename = os.path.basename(path) # Parse file try: lyrics = Lyrics.from_file(path) except ParseException as ex: print("Unable to parse file {}: {}.".format(path, ex), file=sys.stderr) sys.exit(1) # Save file tmpfile = os.path.join(tmpdir, filename) lyrics.save_into(tmpfile) # Compare input and output if not filecmp.cmp(path, tmpfile, shallow=False): print( "Error: {}: input and output does not match".format(filename), file=sys.stderr) sys.exit(1)
"Unable to find liblyrics. Please ensure that the directory " "`liblyrics/..` is into your PYTHONPATH.", file=sys.stderr) sys.exit(2) validfiles = glob(os.path.join("valids", "*")) invalidfiles = glob(os.path.join("invalids", "*")) files = [(invalidfile, False) for invalidfile in invalidfiles] \ + [(validfile, True) for validfile in validfiles] for path, valid in files: # Parse file exception = None try: Lyrics.from_file(path) except ParseException as ex: exception = ex # Check result if (exception is None) != valid: print("Error: {}: {}valid, expected to be {}valid".format( path, "" if exception is None else "in", "" if valid else "in"), file=sys.stderr) if exception is not None: print("Parser output: {}".format(exception)) sys.exit(1) print("{}: {}valid as expected".format(path, "" if valid else "in")) # All tests are corrects
print("Unable to find liblyrics. Please ensure that the directory " "`liblyrics/..` is into your PYTHONPATH.", file=sys.stderr) sys.exit(2) validfiles = glob(os.path.join("valids", "*")) invalidfiles = glob(os.path.join("invalids", "*")) files = [(invalidfile, False) for invalidfile in invalidfiles] \ + [(validfile, True) for validfile in validfiles] for path, valid in files: # Parse file exception = None try: Lyrics.from_file(path) except ParseException as ex: exception = ex # Check result if (exception is None) != valid: print("Error: {}: {}valid, expected to be {}valid" .format(path, "" if exception is None else "in", "" if valid else "in"), file=sys.stderr) if exception is not None: print("Parser output: {}".format(exception)) sys.exit(1) print("{}: {}valid as expected".format(path, "" if valid else "in")) # All tests are corrects