Rework fetch_bytes and _fetch_pypi_json patches to make testing easier. Various improvements to test_micropip. The main feature is a new fixture
'mock_fetch' with an add_pkg method that takes a package name, a map
from version to requirements, and a choice of platform. This should
hopefully make writing more tests a lot easier (which is good because
we could use more micropip test coverage but we are limited by the
difficulty of writing good tests).

This also adds a fixture to create distinct dummy package names and
enables @pytest.mark.asyncio to handle the async calls rather than
using `asyncio.get_event_loop.run_until_complete`.
from pyodide_test_runner import run_in_pyodide


@run_in_pyodide(standalone=True, packages=["numpy", "imageio"])
def test_imageio():
    import imageio
    import numpy as np

    filename = "/tmp/foo.tif"
    image_in = np.random.randint(0, 65535, size=(100, 36), dtype=np.uint16)
    imageio.imwrite(filename, image_in)
    image_out = imageio.imread(filename)
    assert image_out.shape == (100, 36)
    np.testing.assert_equal(image_in, image_out)


@run_in_pyodide(packages=["numpy", "imageio"])
def test_jpg():
    import imageio
    import numpy as np

    img = np.zeros((5, 5), dtype=np.uint8)
    imageio.imsave("img.jpg", img)
    assert (imageio.imread("img.jpg") == img).all()

from pyodide_test_runner import run_in_pyodide


@run_in_pyodide(standalone=True, packages=["numpy", "imageio"])
def test_imageio():
    import imageio
    import numpy as np

    filename = "/tmp/foo.tif"
    image_in = np.random.randint(0, 65535, size=(100, 36), dtype=np.uint16)
    imageio.imwrite(filename, image_in)
    image_out = imageio.imread(filename)
    assert image_out.shape == (100, 36)
    np.testing.assert_equal(image_in, image_out)


@run_in_pyodide(packages=["numpy", "imageio"])
def test_jpg():
    import imageio
    import numpy as np

    img = np.zeros((5, 5), dtype=np.uint8)
    imageio.imsave("img.jpg", img)
    assert (imageio.imread("img.jpg") == img).all()
