Skip to content

Commit

Permalink
Fix python repl tests
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
  • Loading branch information
zhiburt committed Dec 11, 2021
1 parent a15854d commit 627d9a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
10 changes: 8 additions & 2 deletions tests/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,10 @@ fn check_macro() {
fn check_macro_eof() {
let mut session = spawn("echo 'Hello World'").unwrap();

assert_eq!(WaitStatus::Exited(session.pid(), 0), session.wait().unwrap());
assert_eq!(
WaitStatus::Exited(session.pid(), 0),
session.wait().unwrap()
);

expectrl::check!(
session,
Expand All @@ -273,7 +276,10 @@ fn check_macro_eof() {
fn check_macro_eof() {
let mut session = spawn("echo 'Hello World'").unwrap();

assert_eq!(WaitStatus::Exited(session.pid(), 0), session.wait().unwrap());
assert_eq!(
WaitStatus::Exited(session.pid(), 0),
session.wait().unwrap()
);

futures_lite::future::block_on(async {
expectrl::check!(
Expand Down
13 changes: 8 additions & 5 deletions tests/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,22 @@ fn python() {
fn python() {
let mut p = spawn_python().unwrap();

p.execute("print('Hello World')").unwrap();
let mut msg = String::new();
p.read_line(&mut msg).unwrap();
assert_eq!(msg, "Hello World\r\n");
let prompt = p.execute("print('Hello World')").unwrap();
assert_eq!(prompt, b"Hello World\r\n");

thread::sleep(Duration::from_millis(300));
p.send_control(ControlCode::EndOfText).unwrap();
thread::sleep(Duration::from_millis(300));

let mut msg = String::new();
p.read_line(&mut msg).unwrap();
assert_eq!(msg, "\r\n");

let mut msg = String::new();
p.read_line(&mut msg).unwrap();
assert_eq!(msg, ">>> \r\nKeyboardInterrupt\r\n");
assert_eq!(msg, "KeyboardInterrupt\r\n");

p.expect_prompt().unwrap();

p.send_control(ControlCode::EndOfTransmission).unwrap();

Expand Down

0 comments on commit 627d9a5

Please sign in to comment.