MCPcopy Create free account
hub / github.com/cpmech/plotpy / call_python3_twice_works

Function call_python3_twice_works

src/fileio.rs:86–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84
85 #[test]
86 fn call_python3_twice_works() {
87 let path = Path::new(OUT_DIR).join("call_python3_twice_works.py");
88 // first
89 let commands_first = "print(\"Python says: Hello World!\")".to_string();
90 let output_first = call_python3("python3", &commands_first, &path).unwrap();
91 let data_first = fs::read_to_string(&path).map_err(|_| "cannot read test file").unwrap();
92 let correct_first = "print(\"Python says: Hello World!\")".to_string();
93 assert_eq!(data_first, correct_first);
94 assert_eq!(output_first, "Python says: Hello World!\n");
95 // second
96 let commands_second = "print(\"Python says: Hello World! again\")".to_string();
97 let output_second = call_python3("python3", &commands_second, &path).unwrap();
98 let data_second = fs::read_to_string(&path).map_err(|_| "cannot read test file").unwrap();
99 let correct_second = "print(\"Python says: Hello World! again\")".to_string();
100 assert_eq!(data_second, correct_second);
101 assert_eq!(output_second, "Python says: Hello World! again\n");
102 }
103}

Callers

nothing calls this directly

Calls 1

call_python3Function · 0.85

Tested by

no test coverage detected