Skip to content

Commit 6452507

Browse files
author
Guillaume Fraux
committed
Allow to pass multiple local variables to py_run_with!
1 parent 0a6d6cd commit 6452507

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/macros.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ macro_rules! create_instance {
77
}
88

99
macro_rules! py_run_with {
10-
($py: ident, $obj: ident; $($code: expr),+) => ({
10+
($py: ident, $($obj: ident),+; $($code: expr),+ $(,)*) => ({
1111
const ASSERT_RAISES_PY: &'static str = "
1212
def assert_raises(callable, *args, **kwargs):
1313
throw = True
@@ -20,7 +20,9 @@ def assert_raises(callable, *args, **kwargs):
2020
";
2121
use cpython::PyDict;
2222
let locals = PyDict::new($py);
23-
locals.set_item($py, stringify!($obj), $obj).unwrap();
23+
$(
24+
locals.set_item($py, stringify!($obj), $obj).unwrap();
25+
)+
2426

2527
let globals = PyDict::new($py);
2628
let error = $py.get_type::<$crate::error::LumolError>();

0 commit comments

Comments
 (0)