diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-06-08 08:00:28 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-06-08 08:05:45 +0300 |
commit | c337d1d59526fb8dfe569d49bfd355c64bbf07eb (patch) | |
tree | a4b5eee22ac9a441405ed8b175e8d356f4f97383 | |
parent | bba22e1f86967feebf94ebac327f7489c1029afd (diff) | |
download | subplot-c337d1d59526fb8dfe569d49bfd355c64bbf07eb.tar.gz |
test(files): add binding and function for comparing file contents
This will be used soon by a program to extract data files from
subplots, but I expect it to be more generally useful in the future.
-rw-r--r-- | files.py | 9 | ||||
-rw-r--r-- | files.yaml | 3 |
2 files changed, 12 insertions, 0 deletions
@@ -50,6 +50,15 @@ def file_matches(ctx, filename=None, regex=None): assert_eq(bool(m), True) +# Check that two files have the same content +def files_match(ctx, filename1=None, filename2=None): + with open(filename1, "rb") as f: + data1 = f.read() + with open(filename2, "rb") as f: + data2 = f.read() + assert_eq(data1, data2) + + # Check that a file contains a fixed string. def file_contains(ctx, filename=None, pattern=None): with open(filename) as f: @@ -21,6 +21,9 @@ function: file_matches regex: true +- then: files {filename1} and {filename2} match + function: files_match + - then: file (?P<filename>\S+) contains "(?P<pattern>.+)" function: file_contains regex: true |