Skip to content

Commit

Permalink
Make decorator [integration]
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking13 committed Dec 7, 2024
1 parent 60c726d commit eb000e4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
21 changes: 13 additions & 8 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@
# To prevent sending many requests to remote servers, these tests are disabled by default.
# To run these tests locally, invoke pytest with the `--integration` flag.

import pytest
from pytest_pyodide import run_in_pyodide


def test_integration_install_basic(selenium_standalone_micropip, pytestconfig):
pytestconfig.getoption("--integration", skip=True)
def integration_test_only(func):
def wrapper(selenium_standalone_micropip, pytestconfig):
if not pytestconfig.getoption("--integration"):
pytest.skip("Integration tests are skipped. Use --integration to run them.")
func(selenium_standalone_micropip, pytestconfig)
return wrapper


@integration_test_only
def test_integration_install_basic(selenium_standalone_micropip, pytestconfig):
@run_in_pyodide
async def _run(selenium):
import micropip
Expand All @@ -24,9 +32,8 @@ async def _run(selenium):
_run(selenium_standalone_micropip)


@integration_test_only
def test_integration_list_basic(selenium_standalone_micropip, pytestconfig):
pytestconfig.getoption("--integration", skip=True)

@run_in_pyodide
async def _run(selenium):
import micropip
Expand All @@ -39,9 +46,8 @@ async def _run(selenium):
_run(selenium_standalone_micropip)


@integration_test_only
def test_integration_uninstall_basic(selenium_standalone_micropip, pytestconfig):
pytestconfig.getoption("--integration", skip=True)

@run_in_pyodide
async def _run(selenium):
import micropip
Expand All @@ -60,9 +66,8 @@ async def _run(selenium):
_run(selenium_standalone_micropip)


@integration_test_only
def test_integration_freeze_basic(selenium_standalone_micropip, pytestconfig):
pytestconfig.getoption("--integration", skip=True)

@run_in_pyodide
async def _run(selenium):
import json
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_remote_indexes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file contains tests that actually query remote package indexes,
# to ensure that micropip works with real-world package indexes.
# Since running these tests will send many requests to remote servers,
# these tests are disabled by default in CI.
# these tests are disabled by default in CI and local testing.
#
# To run these tests, add `--run-remote-index-tests` flag, or
# these tests can also be run in Github Actions manually.
Expand Down
22 changes: 0 additions & 22 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
import micropip


def test_install_simple(selenium_standalone_micropip):
selenium = selenium_standalone_micropip
assert (
selenium.run_js(
"""
return await pyodide.runPythonAsync(`
import os
import micropip
from pyodide.ffi import to_js
# Package 'pyodide-micropip-test' has dependency on 'snowballstemmer'
# It is used to test markers support
await micropip.install('pyodide-micropip-test')
import snowballstemmer
stemmer = snowballstemmer.stemmer('english')
to_js(stemmer.stemWords('go going goes gone'.split()))
`);
"""
)
== ["go", "go", "goe", "gone"]
)


def test_install_custom_url(selenium_standalone_micropip, wheel_catalog):
selenium = selenium_standalone_micropip
snowball_wheel = wheel_catalog.get("snowballstemmer")
Expand Down

0 comments on commit eb000e4

Please sign in to comment.