]> git.openstreetmap.org Git - nominatim.git/blob - test/bdd/steps/utils.py
Ported createCountryNames() to python and added tests
[nominatim.git] / test / bdd / steps / utils.py
1 """
2 Various smaller helps for step execution.
3 """
4 import logging
5 import subprocess
6
7 LOG = logging.getLogger(__name__)
8
9 def run_script(cmd, **kwargs):
10     """ Run the given command, check that it is successful and output
11         when necessary.
12     """
13     proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
14                             **kwargs)
15     (outp, outerr) = proc.communicate()
16     outp = outp.decode('utf-8')
17     outerr = outerr.decode('utf-8').replace('\\n', '\n')
18     LOG.debug("Run command: %s\n%s\n%s", cmd, outp, outerr)
19
20     assert proc.returncode == 0, "Script '{}' failed:\n{}\n{}\n".format(cmd[0], outp, outerr)
21
22     return outp, outerr