MCPcopy Create free account
hub / github.com/catboost/catboost / main

Function main

library/python/testing/import_test/import_test.py:123–184  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122
123def 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

Callers

nothing calls this directly

Calls 7

setup_test_environmentFunction · 0.85
hasattrFunction · 0.85
check_importsFunction · 0.85
registerMethod · 0.45
findMethod · 0.45
decodeMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected