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)
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()
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)
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
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
def test_insert(mocker, pps_main): mock = mocker.patch(mocks.make_target("shim", "insert")) pps_main("insert") mock.assert_called_once()
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
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
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)
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, )