Debian Codegraph @

pycparser223/tests/test_examples.py

raw symbols SCIP
1 import os
2 import sys
3 import time
4 import unittest
5
6 sys.path.insert(0, '.')
7 from tests.test_util import run_exe, cpp_supported
8
9 # Runs all pycparser examples with no command-line arguments and makes sure they
10 # run successfully (return code = 0), without actually verifying their output.
11 class TestExamplesSucceed(unittest.TestCase):
12 @unittest.skipUnless(cpp_supported(), 'cpp only works on Unix')
13 def test_all_examples(self):
14 root = './examples'
15 for filename in os.listdir(root):
16 if os.path.splitext(filename)[1] == '.py':
17 with self.subTest(name=filename):
18 path = os.path.join(root, filename)
19 rc, stdout, stderr = run_exe(path)
20 self.assertEqual(
21 rc, 0, f'example "{filename}" failed with stdout =\n{stdout}\nstderr =\n{stderr}')
22
23 if __name__ == '__main__':
24 unittest.main()