Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Dec 4, 2023
1 parent ebb8480 commit c768295
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/tests/test_jsproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,47 @@ def test_jsarray_count(selenium):
)(a)


@run_in_pyodide
def test_jsarray_remove(selenium):
import pytest

from pyodide.code import run_js
from pyodide.ffi import create_proxy

l = [5, 7, 9, -1, 3, 5]
a = run_js(repr(l))
l.remove(5)
a.remove(5)
with pytest.raises(ValueError, match="is not in list"):
a.remove(78)
assert a.to_py() == l
l.append([]) # type:ignore[arg-type]
p = create_proxy([], roundtrip=False)
a.append(p)
assert a.to_py() == l
l.remove([]) # type:ignore[arg-type]
a.remove([])
p.destroy()
assert a.to_py() == l
a.push([])
with pytest.raises(ValueError, match="is not in list"):
a.remove([])


@run_in_pyodide
def test_jsarray_insert(selenium):
from pyodide.code import run_js

l = [5, 7, 9, -1, 3, 5]
a = run_js(repr(l))
l.insert(3, 66)
a.insert(3, 66)
assert a.to_py() == l
l.insert(-1, 97)
a.insert(-1, 97)
assert a.to_py() == l


@run_in_pyodide
def test_jsproxy_descr_get(selenium):
from pyodide.code import run_js
Expand Down

0 comments on commit c768295

Please sign in to comment.