def test_singularity_gpu_fail(): SINGULARITY_FAIL.reset_mock() GPU_WRAP_SINGULARITY.reset_mock() kwargs = dict(args='exec -B /path:/path c.img'.split()) with pytest.raises(SystemExit) as excinfo: cli.singularity_gpu(**kwargs) assert excinfo.value.code == FAKE_ERROR_RETURN_CODE.exit_code
def test_manage_env(value): with mock.patch.object(cli, 'gpu_wrap_singularity', GPU_WRAP_SINGULARITY): GPU_WRAP_SINGULARITY.reset_mock() test_env = {'GPUCRATE_MANAGE_ENVIRONMENT': value} with mock.patch.dict(os.environ, test_env): cli.singularity_gpu() if config._TRUTH[value]: assert GPU_WRAP_SINGULARITY.call_args[0] is not None else: assert GPU_WRAP_SINGULARITY.call_args[0] is () env_file = mock.MagicMock() cli.gpu_wrap_singularity(env_file) assert env_file.write.call_args[0][0] == cli.NVENV
def test_singularity_gpu_volume_dne(): with pytest.raises(SystemExit): with testfixtures.LogCapture() as log_capture: with testfixtures.TempDirectory() as d: vroot = os.path.join(d.path, 'vroot') vol = os.path.join(vroot, TEST_DRIVER_VERSION) d.write('config', 'volume_root: {vroot}'.format(vroot=vroot)) config.load(path=os.path.join(d.path, 'config')) SINGULARITY.reset_mock() cli.singularity_gpu( args='exec -B /some/path:/some/path c.img'.split()) log_capture.check( ('gpucrate', 'ERROR', 'volume {vol} does not exist - run "gpucrate create"'.format( vol=vol)))
def test_singularity_gpu_failure(): SINGULARITY.reset_mock() kwargs = dict(args='exec -B /some/path:/some/path c.img'.split()) cli.singularity_gpu(**kwargs) assert SINGULARITY.call_count == 1