example_test.py 490 Bytes
Newer Older
root's avatar
root committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
import subprocess
import sys


def run_example(path, *args):
    examples_path = os.path.join(
        os.path.dirname(__file__), '..', '..', 'examples')
    fullpath = os.path.join(examples_path, path)

    try:
        return subprocess.check_output(
            (sys.executable, fullpath) + args,
            stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as e:
        print('Original error message:')
        print(e.output.decode('utf-8'))
        raise