Skip to content

Commit 1346efb

Browse files
committed
chore: simplify type inference test
1 parent d9ef9d8 commit 1346efb

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

numba_cuda/numba/cuda/tests/cudapy/test_typeinfer.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33

44
import itertools
55

6-
from numba.core import errors
6+
import pytest
7+
8+
from numba.cuda.core import config, errors
79
from numba.cuda import types, typing
810
from numba.cuda.typeconv import Conversion
911

10-
from numba.cuda.testing import CUDATestCase, skip_on_cudasim
12+
from numba.cuda.testing import CUDATestCase
1113
from numba.cuda.tests.cudapy.test_typeconv import CompatibilityTestMixin
1214
from numba.cuda.core.untyped_passes import TranslateByteCode, IRProcessing
1315
from numba.cuda.core.typed_passes import PartialTypeInference
@@ -511,28 +513,25 @@ def define_pipelines(self):
511513
return pipeline.state.typing_errors
512514

513515

514-
@skip_on_cudasim("not available on sim")
515-
class TestPartialTypingErrors(CUDATestCase):
516+
@pytest.mark.skipif(config.ENABLE_CUDASIM, reason="not enable in the simulator")
517+
def test_partial_typing_error():
516518
"""
517519
Make sure partial typing stores type errors in compiler state properly
518520
"""
519521

520-
def test_partial_typing_error(self):
521-
# example with type unification error
522-
def impl(flag):
523-
if flag:
524-
a = 1
525-
else:
526-
a = ""
527-
return a
528-
529-
self.assertRaisesRegex(
530-
errors.TypingError,
531-
r"Cannot unify Literal\[int]\(1\) and Literal\[str]\(\) for 'a'",
532-
get_func_typing_errs,
533-
impl,
534-
(types.bool_,),
535-
)
522+
# example with type unification error
523+
def impl(flag):
524+
if flag:
525+
a = 1
526+
else:
527+
a = ""
528+
return a
529+
530+
with pytest.raises(
531+
errors.TypingError,
532+
match=r"Cannot unify Literal\[int\]\(1\) and Literal\[str\]\(\) for 'a'",
533+
):
534+
get_func_typing_errs(impl, (types.bool_,))
536535

537536

538537
if __name__ == "__main__":

0 commit comments

Comments
 (0)