repo2docker/tests/conda/py2/verify

34 wiersze
986 B
Python
Executable File

#!/usr/bin/env python
import sys
assert sys.version_info[:2] == (3, 7), sys.version
# verify that we have Python 2 and Python 3 kernelspecs
from jupyter_client.kernelspec import KernelSpecManager
ksm = KernelSpecManager()
specs = ksm.get_all_specs()
assert sorted(specs) == ["python2", "python3"], specs.keys()
# verify that we created the kernel env
import json
from subprocess import check_output
envs = json.loads(check_output(["micromamba", "env", "list", "--json"]).decode("utf8"))
assert envs == {
"envs": ["/srv/conda", "/srv/conda/envs/kernel", "/srv/conda/envs/notebook"]
}, envs
pkgs = json.loads(
check_output(["micromamba", "list", "-n", "kernel", "--json"]).decode("utf8")
)
pkg_names = [pkg["name"] for pkg in pkgs]
assert "ipykernel" in pkg_names, pkg_names
assert "numpy" in pkg_names
for pkg in pkgs:
if pkg["name"] == "python":
assert pkg["version"].startswith("2.7.")
break
else:
assert False, f"python not found in {pkg_names}"