summaryrefslogtreecommitdiff
path: root/funcs.py
diff options
context:
space:
mode:
Diffstat (limited to 'funcs.py')
-rw-r--r--funcs.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/funcs.py b/funcs.py
index 2172cc2..f028730 100644
--- a/funcs.py
+++ b/funcs.py
@@ -14,10 +14,10 @@ import yaml
def _run(ctx, argv):
p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate("")
- ctx['argv'] = argv
- ctx['stdout'] = stdout.decode('utf-8')
- ctx['stderr'] = stderr.decode('utf-8')
- ctx['exit'] = p.returncode
+ ctx["argv"] = argv
+ ctx["stdout"] = stdout.decode("utf-8")
+ ctx["stderr"] = stderr.decode("utf-8")
+ ctx["exit"] = p.returncode
# Return argv prefix to run contractor from source directory. This
@@ -25,13 +25,12 @@ def _run(ctx, argv):
# the address of the manager VM from CONTRACTOR_ADDRESS in the
# environment.
def _contractor():
- return [os.path.join(srcdir, 'contractor')]
+ return [os.path.join(srcdir, "contractor")]
# Return manager address.
def _manager_address():
- return os.environ['CONTRACTOR_ADDRESS']
-
+ return os.environ["CONTRACTOR_ADDRESS"]
#############################################################################
@@ -42,17 +41,18 @@ def _manager_address():
def nop(ctx, **kwargs):
pass
+
# Check that we can access the contractor VM.
# FIXME: this hardcodes some things.
def contractor_is_working(ctx):
- argv = _contractor() + ['status', '-m', _manager_address()]
+ argv = _contractor() + ["status", "-m", _manager_address()]
_run(ctx, argv)
- assert_eq(ctx['exit'], 0)
+ assert_eq(ctx["exit"], 0)
# Create a file from the files embedded in the input document.
def create_file(ctx, filename=None):
- with open(filename, 'wb') as f:
+ with open(filename, "wb") as f:
f.write(get_file(filename))
@@ -63,31 +63,31 @@ def file_exists(ctx, filename=None):
# Copy a file from srcdir.
def copy_file_from_srcdir(ctx, filename=None):
- shutil.copy(os.path.join(srcdir, './' + filename), '.')
+ shutil.copy(os.path.join(srcdir, "./" + filename), ".")
# Check that the subprocess we last ran ended with the expected exit
# code.
def exit_code_is(ctx, exit_code=None):
- assert_eq(ctx['exit'], int(exit_code))
+ assert_eq(ctx["exit"], int(exit_code))
# Run contractor dump
def run_contractor_dump(ctx, filename=None):
- argv = _contractor() + ['dump', filename]
+ argv = _contractor() + ["dump", filename]
_run(ctx, argv)
# Run the contractor to do a build.
def run_contractor_build(ctx, filename=None):
- argv = _contractor() + ['build', filename, '-m', _manager_address()]
+ argv = _contractor() + ["build", filename, "-m", _manager_address()]
_run(ctx, argv)
# Parse stdout from latest subprocess as JSON into a dict. Read the
# named YAML file, parse as a dict. Do the two dicts match?
def stdout_json_matches_yaml_file(ctx, filename=None):
- dict1 = json.loads(ctx['stdout'])
+ dict1 = json.loads(ctx["stdout"])
with open(filename) as f:
dict2 = yaml.safe_load(f)
assert_eq(dict1, dict2)