()
| 121 | |
| 122 | |
| 123 | def main(): |
| 124 | setup_test_environment() |
| 125 | |
| 126 | skip_names = sys.argv[1:] |
| 127 | |
| 128 | # SIGUSR2 is used by test_tool to teardown tests |
| 129 | if hasattr(signal, "SIGUSR2"): |
| 130 | # Dump python import tracing |
| 131 | import library.python.import_tracing.lib.regulator as regulator |
| 132 | |
| 133 | # get the original handler to return control to it after dumping |
| 134 | signum = signal.SIGUSR2 |
| 135 | orig_handler = signal.getsignal(signum) |
| 136 | |
| 137 | if not hasattr(signal, 'raise_signal'): |
| 138 | # Only available for Python 3.8+ |
| 139 | def raise_signal(signum): |
| 140 | os.kill(os.getpid(), signum) |
| 141 | else: |
| 142 | raise_signal = signal.raise_signal |
| 143 | |
| 144 | def stop_tracing_handler(s, f): |
| 145 | regulator.disable(close_not_finished=True) |
| 146 | signal.signal(signal.SIGUSR2, orig_handler) |
| 147 | raise_signal(signum) |
| 148 | |
| 149 | signal.signal(signal.SIGUSR2, stop_tracing_handler) |
| 150 | |
| 151 | try: |
| 152 | import faulthandler |
| 153 | except ImportError: |
| 154 | faulthandler = None |
| 155 | |
| 156 | if faulthandler: |
| 157 | # Dump python backtrace in case of any errors |
| 158 | faulthandler.enable() |
| 159 | if hasattr(signal, "SIGUSR2"): |
| 160 | # SIGUSR2 is used by test_tool to teardown tests |
| 161 | faulthandler.register(signal.SIGUSR2, chain=True) |
| 162 | |
| 163 | os.environ['Y_PYTHON_IMPORT_TEST'] = '' |
| 164 | |
| 165 | # We should initialize Django before importing any applications |
| 166 | if os.getenv('DJANGO_SETTINGS_MODULE'): |
| 167 | try: |
| 168 | import django |
| 169 | except ImportError: |
| 170 | pass |
| 171 | else: |
| 172 | django.setup() |
| 173 | |
| 174 | py_main = __res.find('PY_MAIN') |
| 175 | |
| 176 | if py_main: |
| 177 | py_main_module = py_main.split(b':', 1)[0].decode('UTF-8') |
| 178 | else: |
| 179 | py_main_module = None |
| 180 |
nothing calls this directly
no test coverage detected