Ejemplo n.º 1
0
def test_remove_with_file(shimmed_pip_main_file, unshimmed_pip_main_file):
    file, _ = shimmed_pip_main_file
    _, md5 = unshimmed_pip_main_file

    shim.remove(file)
    assert not shim.is_inserted(file)
    assert compute_md5_checksum(file) == md5
Ejemplo n.º 2
0
def test_remove(patch_default_pip_main_file, shimmed_pip_main_file,
                unshimmed_pip_main_file):
    file, _ = shimmed_pip_main_file
    _, md5 = unshimmed_pip_main_file
    patch_default_pip_main_file(file)

    shim.remove()
    assert not shim.is_inserted()
    assert compute_md5_checksum(file) == md5
Ejemplo n.º 3
0
import subprocess

import pytest

from pytorch_pip_shim import shim

__all__ = ["skip_if_cuda_unavailable", "skip_if_pip_is_not_shimmed"]

try:
    subprocess.check_call(
        "nvcc --version",
        shell=True,
        stdout=subprocess.DEVNULL,
        stderr=subprocess.DEVNULL,
    )
    CUDA_AVAILABLE = True
except subprocess.CalledProcessError:
    CUDA_AVAILABLE = False

skip_if_cuda_unavailable = pytest.mark.skipif(not CUDA_AVAILABLE,
                                              reason="Requires CUDA.")

skip_if_pip_is_not_shimmed = pytest.mark.skipif(
    not shim.is_inserted(), reason="pytorch-pip-shim is not inserted.")
Ejemplo n.º 4
0
def test_is_not_inserted(patch_default_pip_main_file,
                         mocked_unshimmed_pip_main_file):
    file, _ = mocked_unshimmed_pip_main_file
    patch_default_pip_main_file(file)

    assert not shim.is_inserted()
Ejemplo n.º 5
0
def test_is_inserted_with_file(mocked_shimmed_pip_main_file):
    file, _ = mocked_shimmed_pip_main_file

    assert shim.is_inserted(file)
Ejemplo n.º 6
0
def test_insert_with_file(unshimmed_pip_main_file):
    file, _ = unshimmed_pip_main_file

    shim.insert(file)
    assert shim.is_inserted(file)
Ejemplo n.º 7
0
def test_insert(patch_default_pip_main_file, unshimmed_pip_main_file):
    file, _ = unshimmed_pip_main_file
    patch_default_pip_main_file(file)

    shim.insert()
    assert shim.is_inserted()