MCPcopy Index your code
hub / github.com/RustPython/RustPython / setUp

Method setUp

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

Source from the content-addressed store, hash-verified

32 maxDiff = None
33
34 def setUp(self):
35 self.logcat_process = subprocess.Popen(
36 ["logcat", "-v", "tag"], stdout=subprocess.PIPE,
37 errors="backslashreplace"
38 )
39 self.logcat_queue = queue.Queue()
40
41 def logcat_thread():
42 for line in self.logcat_process.stdout:
43 self.logcat_queue.put(line.rstrip("\n"))
44 self.logcat_process.stdout.close()
45 self.logcat_thread = Thread(target=logcat_thread)
46 self.logcat_thread.start()
47
48 from ctypes import CDLL, c_char_p, c_int
49 android_log_write = getattr(CDLL("liblog.so"), "__android_log_write")
50 android_log_write.argtypes = (c_int, c_char_p, c_char_p)
51 ANDROID_LOG_INFO = 4
52
53 # Separate tests using a marker line with a different tag.
54 tag, message = "python.test", f"{self.id()} {time()}"
55 android_log_write(
56 ANDROID_LOG_INFO, tag.encode("UTF-8"), message.encode("UTF-8"))
57 self.assert_log("I", tag, message, skip=True, timeout=5)
58
59 def assert_logs(self, level, tag, expected, **kwargs):
60 for line in expected:

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected