예제 #1
0
def test_insert_with_file(mocker, pps_main):
    file = "file"
    mock = mocker.patch(mocks.make_target("shim", "insert"))

    pps_main("insert", file)

    mock.assert_called_once_with(file)
예제 #2
0
def test_uninstall(mocker):
    mock = mocker.patch(mocks.make_target("shim", "remove"))

    # although not specifically mocked, this will not uninstall pytorch-pip-shim since
    # it is outside the environment we are currently running in
    pip_uninstall(Package("pytorch-pip-shim", pps.__version__))

    mock.assert_called()
예제 #3
0
def test_detect(mocker, pps_main, generic_computation_backend):
    mocker.patch(
        mocks.make_target("cli", "commands", "detect"),
        return_value=generic_computation_backend,
    )

    out = pps_main("detect")

    assert out == str(generic_computation_backend)
예제 #4
0
def test_process_computation_backend(mocker, generic_computation_backend):
    string = "generic"
    mocker.patch(
        mocks.make_target("computation_backend", "ComputationBackend", "from_str"),
        return_value=generic_computation_backend,
    )
    opts = make_computation_backend_opts(computation_backend=string)

    assert utils.process_computation_backend(opts) == generic_computation_backend
예제 #5
0
def test_process_computation_backend_detect(
    mocker,
    generic_computation_backend,
):
    mocker.patch(
        mocks.make_target("computation_backend", "detect"),
        return_value=generic_computation_backend,
    )
    opts = make_computation_backend_opts()

    assert utils.process_computation_backend(opts) == generic_computation_backend
예제 #6
0
def test_insert(mocker, pps_main):
    mock = mocker.patch(mocks.make_target("shim", "insert"))

    pps_main("insert")

    mock.assert_called_once()
예제 #7
0
def test_status_quiet(mocker, pps_main, arg):
    mocker.patch(mocks.make_target("shim", "is_inserted"), return_value=True)

    out = pps_main("status", arg)

    assert not out
예제 #8
0
def test_status_stdout_smoke(mocker, pps_main):
    mocker.patch(mocks.make_target("shim", "is_inserted"), return_value=True)

    out = pps_main("status")

    assert out
예제 #9
0
def test_status(mocker, pps_main, is_inserted):
    mocker.patch(mocks.make_target("shim", "is_inserted"),
                 return_value=is_inserted)

    pps_main("status", error=not is_inserted)
예제 #10
0
def test_remove(mocker, pps_main):
    mock = mocker.patch(mocks.make_target("shim", "remove"))

    pps_main("remove")

    mock.assert_called_once()
 def patch_nvcc_call_(**kwargs):
     return mocker.patch(
         mocks.make_target("computation_backend.subprocess.check_output"),
         **kwargs,
     )