mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 02:37:41 -05:00
Bootstrap python tests (#697)
* move current integration tests to the integration folder * move pyscript.py into its own python folder * change the path for python unit testing files * change pyscript.py path * Update Makefile * remove echo * replace conda run with pytest directly * oops, add python test files I embarrassingly forgot to add Co-authored-by: Peter W <34256109+pww217@users.noreply.github.com>
This commit is contained in:
22
pyscriptjs/tests/py-unit/test_pyscript.py
Normal file
22
pyscriptjs/tests/py-unit/test_pyscript.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user