Skip to content

Commit 43259b8

Browse files
committed
tests: add a test to ensure py-spy does not fails on cyrillic (ucs-2) strings
1 parent 3a754c8 commit 43259b8

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

tests/integration_test.rs

+21
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,27 @@ fn test_unicode() {
229229
assert!(!traces[0].owns_gil);
230230
}
231231

232+
#[test]
233+
fn test_cyrillic() {
234+
#[cfg(target_os = "macos")]
235+
{
236+
if unsafe { libc::geteuid() } != 0 {
237+
return;
238+
}
239+
}
240+
let mut runner = TestRunner::new(Config::default(), "./tests/scripts/cyrillic.py");
241+
242+
let traces = runner.spy.get_stack_traces().unwrap();
243+
assert_eq!(traces.len(), 1);
244+
let trace = &traces[0];
245+
246+
assert_eq!(trace.frames[0].name, "кириллица");
247+
assert_eq!(trace.frames[0].line, 4);
248+
249+
assert_eq!(trace.frames[1].name, "<module>");
250+
assert_eq!(trace.frames[1].line, 7);
251+
}
252+
232253
#[test]
233254
fn test_local_vars() {
234255
#[cfg(target_os = "macos")]

tests/scripts/cyrillic.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
import time
22

3-
4-
def f(seconds):
5-
time.sleep(seconds)
6-
7-
83
def кириллица(seconds):
9-
f(seconds)
10-
4+
time.sleep(seconds)
115

126
if __name__ == "__main__":
13-
f(3)
14-
кириллица(3)
15-
f(3)
7+
кириллица(10)

0 commit comments

Comments
 (0)