Skip to content

Commit 2222d3d

Browse files
committed
fix: server errors handling tests
1 parent c7906e3 commit 2222d3d

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

tests/test_server_errors.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,31 @@
2222

2323
import pytest
2424
import sys
25-
26-
from ansys import dpf
25+
import ansys.dpf.core as dpf
2726
from ansys.dpf.core import errors, operators as ops
2827

2928
def test_server_exception_from_operator():
30-
ds = dpf.core.DataSources(r"dummy/file.rst")
29+
ds = dpf.DataSources(r"dummy/file.rst")
3130
op = ops.result.displacement(data_sources=ds)
3231
with pytest.raises(errors.DPFServerException) as exception_note:
3332
op.eval()
34-
35-
assert hasattr(exception_note, '__notes__'), "The exception does not contain any note"
36-
assert exception_note.__notes__
33+
34+
exception = exception_note.value
35+
assert hasattr(exception, '__notes__'), "The exception does not contain any note"
36+
assert exception.__notes__
3737

3838
def test_server_exception_from_workflow():
39-
disp = ops.result.displacement()
40-
workflow = dpf.Workflow()
41-
42-
workflow.add_operator(disp)
43-
workflow.set_output_name("displacement", disp.outputs.fields_container)
44-
workflow.eval()
39+
op = dpf.operators.result.displacement(data_sources=dpf.DataSources("toto.rst"))
40+
41+
wf = dpf.Workflow()
42+
wf.add_operator(op)
43+
wf.set_output_name("out", op.outputs.fields_container)
44+
45+
with pytest.raises(errors.DPFServerException) as exception_note:
46+
wf.get_output("out", output_type=dpf.FieldsContainer)
47+
48+
print(type(exception_note))
49+
exception = exception_note.value
50+
assert hasattr(exception, '__notes__'), "The exception does not contain any note"
51+
assert exception.__notes__
4552

0 commit comments

Comments
 (0)