Skip to content

Commit

Permalink
Fix test_packages_common when no lockfile is found
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Feb 17, 2025
1 parent 41ec11c commit f3014ae
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/_tests/test_packages_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"matplotlib-inline": "circular dependency with IPython",
}

lockfile_path = ROOT_PATH / "dist" / "pyodide-lock.json"
LOCKFILE_PATH = ROOT_PATH / "dist" / "pyodide-lock.json"


class ImportTestCase(TypedDict):
Expand All @@ -35,9 +35,9 @@ class ImportTestCase(TypedDict):

def load_lockfile() -> PyodideLockSpec:
try:
return PyodideLockSpec.from_json(lockfile_path)
return PyodideLockSpec.from_json(LOCKFILE_PATH)
except Exception as e:
raise Exception(f"Failed to load lockfile from {lockfile_path}") from e
raise FileNotFoundError(f"Failed to load lockfile from {LOCKFILE_PATH}") from e


def normalize_import_name(name: str) -> str:
Expand All @@ -61,7 +61,10 @@ def generate_test_list(lockfile: PyodideLockSpec) -> list[ImportTestCase]:

@functools.cache
def build_testcases():
lockfile = load_lockfile()
try:
lockfile = load_lockfile()
except FileNotFoundError:
return [{"name": "no-lockfile-found"}]
return generate_test_list(lockfile)


Expand All @@ -75,6 +78,8 @@ def idfn(testcase: ImportTestCase) -> str:
@pytest.mark.parametrize("testcase", build_testcases(), ids=idfn)
def test_import(selenium_standalone: Any, testcase: ImportTestCase) -> None:
name = testcase["name"]
if name == "no-lockfile-found":
pytest.skip(f"Failed to load lockfile from {LOCKFILE_PATH}")
imports = testcase["imports"]

if name in XFAIL_PACKAGES:
Expand Down

0 comments on commit f3014ae

Please sign in to comment.