File: test_example.py

package info (click to toggle)
pygccxml 3.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,444 kB
  • sloc: xml: 29,841; python: 13,914; cpp: 2,671; makefile: 163; ansic: 59
file content (33 lines) | stat: -rw-r--r-- 1,094 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright 2014-2017 Insight Software Consortium.
# Copyright 2004-2009 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt

import os
import fnmatch
import subprocess


def test_example():
    """Runs the example in the docs directory"""

    env = os.environ.copy()

    # Get the path to current directory
    path = os.path.dirname(os.path.realpath(__file__))
    # Set the COVERAGE_PROCESS_START env. variable.
    # Allows to cover files run in a subprocess
    # http://nedbatchelder.com/code/coverage/subprocess.html
    env["COVERAGE_PROCESS_START"] = path + "/../.coveragerc"

    # Find all the examples files
    file_paths = []
    for root, _, filenames in os.walk(path + "/../docs/examples"):
        for file_path in fnmatch.filter(filenames, '*.py'):
            file_paths.append(os.path.join(root, file_path))

    for file_path in file_paths:
        return_code = subprocess.call(
            ["python", path + "/example_tester_wrap.py", file_path],
            env=env)
        assert return_code == 0