mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
bdd: move external process execution in separate func
This commit is contained in:
22
test/bdd/steps/utils.py
Normal file
22
test/bdd/steps/utils.py
Normal file
@@ -0,0 +1,22 @@
|
||||
"""
|
||||
Various smaller helps for step execution.
|
||||
"""
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
def run_script(cmd, **kwargs):
|
||||
""" Run the given command, check that it is successful and output
|
||||
when necessary.
|
||||
"""
|
||||
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
**kwargs)
|
||||
(outp, outerr) = proc.communicate()
|
||||
outp = outp.decode('utf-8')
|
||||
outerr = outerr.decode('utf-8').replace('\\n', '\n')
|
||||
LOG.debug("Run command: %s\n%s\n%s", cmd, outp, outerr)
|
||||
|
||||
assert proc.returncode == 0, "Script '{}' failed:\n{}\n{}\n".format(cmd[0], outp, outerr)
|
||||
|
||||
return outp, outerr
|
||||
Reference in New Issue
Block a user