From 91593b7378f5480d0b95930d12e7d1874967ccfa Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sun, 14 Oct 2018 23:05:22 +0200 Subject: [PATCH] Add tests for prefer_gpu() and require_gpu() --- spacy/tests/test_misc.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spacy/tests/test_misc.py b/spacy/tests/test_misc.py index 33a02a4e4..4610f34ff 100644 --- a/spacy/tests/test_misc.py +++ b/spacy/tests/test_misc.py @@ -7,6 +7,7 @@ from .. import displacy from ..tokens import Span from .util import get_doc from .._ml import PrecomputableAffine +from .. import prefer_gpu, require_gpu from pathlib import Path import pytest @@ -101,3 +102,10 @@ def test_PrecomputableAffine(nO=4, nI=5, nF=3, nP=2): assert model.d_pad[0, 2, 0, 0] == 0. model._backprop_padding(dY, ids) assert model.d_pad[0, 2, 0, 0] == 3. + +def test_prefer_gpu(): + assert not prefer_gpu() + +def test_require_gpu(): + with pytest.raises(ValueError): + require_gpu()