|
37 | 37 | from ..core import Workflow |
38 | 38 | from ... import mark |
39 | 39 | from ..specs import SpecInfo, BaseSpec, ShellSpec |
| 40 | +from pydra.utils import exc_info_matches |
40 | 41 |
|
41 | 42 |
|
42 | 43 | def test_wf_no_input_spec(): |
@@ -102,13 +103,15 @@ def test_wf_dict_input_and_output_spec(): |
102 | 103 | wf.inputs.a = "any-string" |
103 | 104 | wf.inputs.b = {"foo": 1, "bar": False} |
104 | 105 |
|
105 | | - with pytest.raises(TypeError, match="Cannot coerce 1.0 into <class 'str'>"): |
| 106 | + with pytest.raises(TypeError) as exc_info: |
106 | 107 | wf.inputs.a = 1.0 |
107 | | - with pytest.raises( |
108 | | - TypeError, |
109 | | - match=("Could not coerce object, 'bad-value', to any of the union types "), |
110 | | - ): |
| 108 | + assert exc_info_matches(exc_info, "Cannot coerce 1.0 into <class 'str'>") |
| 109 | + |
| 110 | + with pytest.raises(TypeError) as exc_info: |
111 | 111 | wf.inputs.b = {"foo": 1, "bar": "bad-value"} |
| 112 | + assert exc_info_matches( |
| 113 | + exc_info, "Could not coerce object, 'bad-value', to any of the union types" |
| 114 | + ) |
112 | 115 |
|
113 | 116 | result = wf() |
114 | 117 | assert result.output.a == "any-string" |
@@ -5002,14 +5005,13 @@ def test_wf_input_output_typing(): |
5002 | 5005 | output_spec={"alpha": int, "beta": ty.List[int]}, |
5003 | 5006 | ) |
5004 | 5007 |
|
5005 | | - with pytest.raises( |
5006 | | - TypeError, match="Cannot coerce <class 'list'> into <class 'int'>" |
5007 | | - ): |
| 5008 | + with pytest.raises(TypeError) as exc_info: |
5008 | 5009 | list_mult_sum( |
5009 | 5010 | scalar=wf.lzin.y, |
5010 | 5011 | in_list=wf.lzin.y, |
5011 | 5012 | name="A", |
5012 | 5013 | ) |
| 5014 | + exc_info_matches(exc_info, "Cannot coerce <class 'list'> into <class 'int'>") |
5013 | 5015 |
|
5014 | 5016 | wf.add( # Split over workflow input "x" on "scalar" input |
5015 | 5017 | list_mult_sum( |
|
0 commit comments