Skip to content

Bootstrap python tests #697

Merged
fpliger merged 9 commits into
mainfrom
fpliger/663_bootstrap_py_tests_2
Aug 18, 2022
Merged

Bootstrap python tests #697
fpliger merged 9 commits into
mainfrom
fpliger/663_bootstrap_py_tests_2

Conversation

@fpliger

@fpliger fpliger commented Aug 17, 2022

Copy link
Copy Markdown
Contributor

Close #617

Supersede #665

@fpliger fpliger requested review from marimeireles and pww217 August 17, 2022 18:34

@marimeireles marimeireles left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding these @fpliger!
I'm curious about these two Mock files you added, but other than that LGMT.

Comment on lines +1 to +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()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this code is for (same for the micropip.py file).
The other parts of tests we're using console are here for example:

            <py-script>import js; js.console.info('one')</py-script>
            <py-script>js.console.info('two')</py-script>
            <py-script>js.console.info('three')</py-script>
            <py-script>js.console.info('four')</py-script>

But it's not using this object, as far as I understand.
Can you please explain it?
Thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are fixtures for the the apis that are pyodide specific. The tests/integration tests run a web server that actually run the code in pyodide while the python tests are actually running python unit tests in local python. So the js and micropip modules are not there. We can potentially think of running the tests in pyodide at some point but even then, I think it makes sense for us to mock their API to make sure that we are calling them correctly...

In general, we'll be supporting other runtimes that are not pyodide so I think that it's important that we decouple our Python higher level API and test the interface itself.

Makes sense?

(given your comment, I think it actually makes sense for us to put js.py and micropip.py in a fixtures folder but we can do it in a separate follow up PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense =)
Thanks for the explanation.

@fpliger fpliger merged commit fa7a97c into main Aug 18, 2022
@fpliger fpliger deleted the fpliger/663_bootstrap_py_tests_2 branch August 18, 2022 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Create infrastructure and write the first Python unit test

4 participants