-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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>
- Loading branch information
Showing
15 changed files
with
47 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""All data required for testing examples""" | ||
import pathlib | ||
import sys | ||
|
||
# current working directory | ||
base_path = pathlib.Path().absolute() | ||
python_source = base_path / "src" / "python" | ||
sys.path.append(str(python_source)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"""Mock module that emulates some of the pyodide js module features for the sake of tests""" | ||
from unittest.mock import Mock | ||
|
||
document = Mock() | ||
console = Mock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"""Mock module that emulates some of the pyodide js module features for the sake of tests""" | ||
from unittest.mock import Mock | ||
|
||
install = Mock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |