Actually add object_keys and object_values to JsProxy (#1439)

This commit is contained in:
Hood Chatham 2021-04-08 05:25:59 -04:00 committed by GitHub
parent 6a44597a58
commit b342a39722
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -1311,6 +1311,8 @@ JsProxy_create_subtype(int flags)
methods[cur_method++] = JsProxy_Dir_MethodDef; methods[cur_method++] = JsProxy_Dir_MethodDef;
methods[cur_method++] = JsProxy_toPy_MethodDef; methods[cur_method++] = JsProxy_toPy_MethodDef;
methods[cur_method++] = JsProxy_object_entries_MethodDef; methods[cur_method++] = JsProxy_object_entries_MethodDef;
methods[cur_method++] = JsProxy_object_keys_MethodDef;
methods[cur_method++] = JsProxy_object_values_MethodDef;
PyTypeObject* base = &JsProxyType; PyTypeObject* base = &JsProxyType;
int tp_flags = Py_TPFLAGS_DEFAULT; int tp_flags = Py_TPFLAGS_DEFAULT;

View File

@ -476,6 +476,20 @@ def test_register_jsmodule_docs_example(selenium_standalone):
) )
def test_object_entries_keys_values(selenium):
selenium.run_js(
"""
window.x = { a : 2, b : 3, c : 4 };
pyodide.runPython(`
from js import x
assert x.object_entries().to_py() == [["a", 2], ["b", 3], ["c", 4]]
assert x.object_keys().to_py() == ["a", "b", "c"]
assert x.object_values().to_py() == [2, 3, 4]
`);
"""
)
def test_mixins_feature_presence(selenium): def test_mixins_feature_presence(selenium):
result = selenium.run_js( result = selenium.run_js(
""" """