From 55713da4fa749f8d2c0cd59101d722d67fe60eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Varl=C4=B1?= Date: Tue, 15 Nov 2022 11:13:14 +0000 Subject: [PATCH] Make sure to include Python `builtins` in tests --- .../aws-smithy-http-server-python/src/context/testing.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rust-runtime/aws-smithy-http-server-python/src/context/testing.rs b/rust-runtime/aws-smithy-http-server-python/src/context/testing.rs index f95f3aeda3e..31fbd3d8ee1 100644 --- a/rust-runtime/aws-smithy-http-server-python/src/context/testing.rs +++ b/rust-runtime/aws-smithy-http-server-python/src/context/testing.rs @@ -8,7 +8,7 @@ use http::{HeaderMap, HeaderValue}; use lambda_http::Context; use pyo3::{ - types::{IntoPyDict, PyDict}, + types::{PyDict, PyModule}, IntoPy, PyErr, Python, }; @@ -16,7 +16,8 @@ use super::{PyContext, PyLambdaContext}; pub fn get_context(code: &str) -> PyContext { let inner = Python::with_gil(|py| { - let globals = [("LambdaContext", py.get_type::())].into_py_dict(py); + let globals = PyModule::import(py, "__main__")?.dict(); + globals.set_item("LambdaContext", py.get_type::())?; let locals = PyDict::new(py); py.run(code, Some(globals), Some(locals))?; let context = locals