def test_dist()

in utils/build-dists.py [0:0]


def test_dist(dist):
    with set_tmp_dir() as tmp_dir:
        # Build the venv and install the dist
        run(("python", "-m", "venv", os.path.join(tmp_dir, "venv")))
        venv_python = os.path.join(tmp_dir, "venv/bin/python")
        run((venv_python, "-m", "pip", "install", "-U", "pip"))
        run((venv_python, "-m", "pip", "install", dist))

        # Test out importing from the package
        run(
            (
                venv_python,
                "-c",
                "from elastic_transport import Transport, Urllib3HttpNode, RequestsHttpNode",
            )
        )

        # Uninstall the dist, see that we can't import things anymore
        run((venv_python, "-m", "pip", "uninstall", "--yes", "elastic-transport"))
        run(
            (venv_python, "-c", "from elastic_transport import Transport"),
            expect_exit_code=256,
        )