Debian Codegraph @

test/test_appexit.py

raw symbols SCIP
1 # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 # SPDX-License-Identifier: Apache-2.0.
3
4 import subprocess
5 import sys
6 import unittest
7
8
9 class TestAppExit(unittest.TestCase):
10 """Test that the application can exit with at any moment without native code somehow crashing python"""
11
12 def _run_to_stage(self, module_name, stage):
13 args = [sys.executable, '-m', module_name, stage.name]
14
15 process = subprocess.Popen(
16 args,
17 stdout=subprocess.PIPE,
18 stderr=subprocess.STDOUT)
19
20 output = process.communicate()[0]
21
22 # only print output if test failed
23 if process.returncode != 0:
24 print(subprocess.list2cmdline(args))
25
26 for line in output.splitlines():
27 print(line.decode())
28
29 self.assertEqual(0, process.returncode)
30
31 def test_http(self):
32 import test.appexit_http
33 for stage in test.appexit_http.Stage:
34 self._run_to_stage('test.appexit_http', stage)