summaryrefslogtreecommitdiff
path: root/subplot.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-24 08:13:02 +0000
committerLars Wirzenius <liw@liw.fi>2020-05-24 08:13:02 +0000
commit738c90cec0fd257334ec9e6e61314277286ea4e9 (patch)
tree0f09e6d77880b3673d6760e78642280d5de0c662 /subplot.py
parent576aa3bcbb6615f4fef73264029fc22af78fdfdc (diff)
parentf039dc7fcb3e9dd20166ecfe64d5428a812d5990 (diff)
downloadsubplot-738c90cec0fd257334ec9e6e61314277286ea4e9.tar.gz
Merge branch 'kinnison/fix-52' into 'master'
Support JSON output in `sp-meta` Closes #52 See merge request larswirzenius/subplot!45
Diffstat (limited to 'subplot.py')
-rw-r--r--subplot.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/subplot.py b/subplot.py
index 9e16168..bf6415f 100644
--- a/subplot.py
+++ b/subplot.py
@@ -1,3 +1,4 @@
+import json
import os
import re
import subprocess
@@ -54,6 +55,12 @@ def run_meta(ctx, filename=None):
exit_code_is(ctx, 0)
+def run_meta_json(ctx, filename=None):
+ meta = binary("sp-meta")
+ runcmd(ctx, [meta, filename, "-o", "json"])
+ exit_code_is(ctx, 0)
+
+
def run_pandoc_with_filter(ctx, filename=None, output=None):
sp_filter = binary("sp-filter")
runcmd(ctx, ["pandoc", "--filter", sp_filter, filename, "-o", output])
@@ -94,5 +101,11 @@ def cleanup_was_not_run(ctx, keyword=None, name=None):
stdout_does_not_contain(ctx, pattern="\n cleanup: {} {}\n".format(keyword, name))
+def json_output_matches_file(ctx, filename=None):
+ actual = json.loads(ctx["stdout"])
+ expected = json.load(open(filename))
+ assert_dict_eq(actual, expected)
+
+
def binary(basename):
return os.path.join(srcdir, "target", "debug", basename)