def test_parse_package_subset(): assert _parse_package_subset(None) is None # micropip is always included assert _parse_package_subset("numpy,pandas") == { "pyparsing", "packaging", "micropip", "numpy", "pandas", } # duplicates are removed assert _parse_package_subset("numpy,numpy") == { "pyparsing", "packaging", "micropip", "numpy", } # no empty package name included, spaces are handled assert _parse_package_subset("x, a, b, c ,,, d,,") == { "pyparsing", "packaging", "micropip", "x", "a", "b", "c", "d", }
def test_parse_package_subset(): assert _parse_package_subset(None) is None # micropip is always included assert _parse_package_subset("numpy,pandas") == { 'micropip', 'distlib', 'numpy', 'pandas' } # duplicates are removed assert _parse_package_subset("numpy,numpy") == { 'micropip', 'distlib', 'numpy' }
def test_parse_package_subset(): assert _parse_package_subset(None) is None # micropip is always included assert _parse_package_subset("numpy,pandas") == { "micropip", "distlib", "numpy", "pandas", } # duplicates are removed assert _parse_package_subset("numpy,numpy") == { "micropip", "distlib", "numpy" }
def test_import(name, selenium_standalone): # check that we can parse the meta.yaml meta = parse_package_config(PKG_DIR / name / "meta.yaml") if name in UNSUPPORTED_PACKAGES[selenium_standalone.browser]: pytest.xfail("{} fails to load and is not supported on {}.".format( name, selenium_standalone.browser)) built_packages = _parse_package_subset(os.environ.get("PYODIDE_PACKAGES")) # only a subset of packages were built if built_packages is not None and name not in built_packages: pytest.skip(f"{name} was skipped due to PYODIDE_PACKAGES") selenium_standalone.run("import glob, os") baseline_pyc = selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.9/site-packages/**/*.pyc', recursive=True) )) """) for import_name in meta.get("test", {}).get("imports", []): selenium_standalone.run_async("import %s" % import_name) # Make sure that even after importing, there are no additional .pyc # files assert (selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.9/site-packages/**/*.pyc', recursive=True) )) """) == baseline_pyc)
def test_import(name, selenium_standalone): # check that we can parse the meta.yaml meta = parse_package(PKG_DIR / name / 'meta.yaml') if name in UNSUPPORTED_PACKAGES[selenium_standalone.browser]: pytest.xfail('{} fails to load and is not supported on {}.'.format( name, selenium_standalone.browser)) built_packages = _parse_package_subset(os.environ.get('PYODIDE_PACKAGES')) # only a subset of packages were built if built_packages is not None and name not in built_packages: pytest.skip(f'{name} was skipped due to PYODIDE_PACKAGES') selenium_standalone.run("import glob, os") baseline_pyc = selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """) selenium_standalone.load_package(name) # Make sure there are no additional .pyc file assert selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """) == baseline_pyc loaded_packages = [] for import_name in meta.get('test', {}).get('imports', []): if name not in loaded_packages: selenium_standalone.load_package(name) loaded_packages.append(name) try: selenium_standalone.run('import %s' % import_name) except Exception: print(selenium_standalone.logs) raise # Make sure that even after importing, there are no additional .pyc # files assert selenium_standalone.run(""" len(list(glob.glob( '/lib/python3.7/site-packages/**/*.pyc', recursive=True) )) """) == baseline_pyc
def test_parse_package_subset(): assert (_parse_package_subset("numpy,pandas") == { "numpy", "pandas", } | UNVENDORED_STDLIB_MODULES | ALWAYS_PACKAGES) # duplicates are removed assert (_parse_package_subset("numpy,numpy") == { "numpy", } | UNVENDORED_STDLIB_MODULES | ALWAYS_PACKAGES) # no empty package name included, spaces are handled assert (_parse_package_subset("x, a, b, c ,,, d,,") == { "x", "a", "b", "c", "d", } | UNVENDORED_STDLIB_MODULES | ALWAYS_PACKAGES) assert (_parse_package_subset("core") == CORE_PACKAGES | UNVENDORED_STDLIB_MODULES | ALWAYS_PACKAGES) # by default core packages are built assert _parse_package_subset(None) == _parse_package_subset("core") assert (_parse_package_subset("min-scipy-stack") == CORE_SCIPY_PACKAGES | CORE_PACKAGES | UNVENDORED_STDLIB_MODULES | ALWAYS_PACKAGES) # reserved key words can be combined with other packages assert _parse_package_subset( "core, unknown") == _parse_package_subset("core") | {"unknown"}
def test_parse_package_subset(): # micropip is always included assert _parse_package_subset("numpy,pandas") == { "pyparsing", "packaging", "micropip", "numpy", "pandas", "test", "distutils", } # duplicates are removed assert _parse_package_subset("numpy,numpy") == { "pyparsing", "packaging", "micropip", "numpy", "test", "distutils", } # no empty package name included, spaces are handled assert _parse_package_subset("x, a, b, c ,,, d,,") == { "pyparsing", "packaging", "micropip", "test", "distutils", "x", "a", "b", "c", "d", } assert _parse_package_subset("core") == { "pyparsing", "packaging", "pytz", "Jinja2", "micropip", "regex", "fpcast-test", "test", "distutils", "sharedlib-test-py", "cpp-exceptions-test", } # by default core packages are built assert _parse_package_subset(None) == _parse_package_subset("core") assert _parse_package_subset("min-scipy-stack") == { "pyparsing", "packaging", "pytz", "Jinja2", "micropip", "regex", "fpcast-test", "numpy", "scipy", "pandas", "matplotlib", "scikit-learn", "joblib", "pytest", "test", "distutils", "sharedlib-test-py", "cpp-exceptions-test", } # reserved key words can be combined with other packages assert _parse_package_subset( "core, unknown") == _parse_package_subset("core") | {"unknown"}