Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap python tests #697

Merged
merged 9 commits into from
Aug 18, 2022
Merged

Bootstrap python tests #697

merged 9 commits into from
Aug 18, 2022

Conversation

fpliger
Copy link
Contributor

@fpliger fpliger commented Aug 17, 2022

Close #617

Supersede #665

Copy link
Member

@marimeireles marimeireles left a comment

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
Member

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
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
Member

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