Files
pyscript/pyscriptjs/tests/py-unit/test_pyscript.py
Fabio Pliger 24a70a8273 fix error management bug and improve examples automation (#717)
* add build to the make examples cmd so that it automates more to the user

* temporarily improve error managament when executing eval until we properly refactor the whole io and error workflow

* add minimal test for format_mime
2022-08-23 17:12:30 -05:00

31 lines
892 B
Python

from unittest.mock import Mock
import pyscript
class TestElement:
def test_id_is_correct(self):
el = pyscript.Element("something")
assert el.id == "something"
def test_element(self, monkeypatch):
el = pyscript.Element("something")
document_mock = Mock()
call_result = "some_result"
document_mock.querySelector = Mock(return_value=call_result)
monkeypatch.setattr(pyscript, "document", document_mock)
assert not el._element
real_element = el.element
assert real_element
assert pyscript.document.querySelector.call_count == 1
pyscript.document.querySelector.assert_called_with("#something")
assert real_element == call_result
def test_format_mime_str():
obj = "just a string"
res = pyscript.format_mime(obj)
assert res[0] == obj
assert res[1] == "text/plain"