summaryrefslogtreecommitdiff
path: root/subplot/summain.py
diff options
context:
space:
mode:
Diffstat (limited to 'subplot/summain.py')
-rw-r--r--subplot/summain.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/subplot/summain.py b/subplot/summain.py
index 4efc8c4..e137ade 100644
--- a/subplot/summain.py
+++ b/subplot/summain.py
@@ -1,5 +1,7 @@
+import difflib
import logging
import os
+import socket
def install_summain(ctx):
@@ -21,6 +23,15 @@ def create_symlink(ctx, linkname=None, target=None):
os.symlink(target, linkname)
+def create_socket(ctx, filename=None):
+ fd = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ fd.bind(filename)
+
+
+def set_mode(ctx, filename=None, mode=None):
+ os.chmod(filename, int(mode, 8))
+
+
def set_atime(ctx, filename=None, timestamp=None):
st = os.lstat(filename)
os.utime(filename, (int(timestamp), int(st.st_mtime)), follow_symlinks=False)
@@ -38,7 +49,17 @@ def output_matches_file(ctx, filename=None):
actual = runcmd_get_stdout(ctx)
expected = get_file(filename).decode("UTF-8")
+ diff = "".join(
+ line.rstrip("\n") + "\n"
+ for line in difflib.unified_diff(
+ expected.splitlines(),
+ actual.splitlines(),
+ fromfile="expected",
+ tofile="actual",
+ )
+ )
logging.debug("output_matches:")
logging.debug(f" actual:\n{actual}")
logging.debug(f" expect:\n{expected}")
+ logging.debug(f" diff:\n{diff}")
assert_eq(actual, expected)