MCPcopy Index your code
hub / github.com/python/cpython / setUp

Method setUp

Lib/test/test_android.py:27–58  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

25 maxDiff = None
26
27 def setUp(self):
28 self.logcat_process = subprocess.Popen(
29 ["logcat", "-v", "tag"], stdout=subprocess.PIPE,
30 errors="backslashreplace"
31 )
32 self.logcat_queue = queue.Queue()
33
34 def logcat_thread():
35 for line in self.logcat_process.stdout:
36 self.logcat_queue.put(line.rstrip("\n"))
37 self.logcat_process.stdout.close()
38
39 self.logcat_thread = Thread(target=logcat_thread)
40 self.logcat_thread.start()
41
42 try:
43 from ctypes import CDLL, c_char_p, c_int
44 android_log_write = getattr(CDLL("liblog.so"), "__android_log_write")
45 android_log_write.argtypes = (c_int, c_char_p, c_char_p)
46 ANDROID_LOG_INFO = 4
47
48 # Separate tests using a marker line with a different tag.
49 tag, message = "python.test", f"{self.id()} {time()}"
50 android_log_write(
51 ANDROID_LOG_INFO, tag.encode("UTF-8"), message.encode("UTF-8"))
52 self.assert_log("I", tag, message, skip=True)
53 except:
54 # If setUp throws an exception, tearDown is not automatically
55 # called. Avoid leaving a dangling thread which would keep the
56 # Python process alive indefinitely.
57 self.tearDown()
58 raise
59
60 def assert_logs(self, level, tag, expected, **kwargs):
61 for line in expected:

Callers

nothing calls this directly

Calls 9

assert_logMethod · 0.95
tearDownMethod · 0.95
ThreadClass · 0.90
CDLLClass · 0.90
timeClass · 0.90
QueueMethod · 0.80
startMethod · 0.45
idMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected