Skip to content

Commit c8dc5c6

Browse files
committed
test_get_*: handling when canceling dialog
1 parent 2392e81 commit c8dc5c6

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

plotpy/tests/gui/test_get_rectangle.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ def test_get_rectangle():
2525
shape = select_with_shape_tool(
2626
None, RectangleTool, image, "Test", tooldialogclass=PatchedSelectDialog
2727
)
28-
rect = shape.get_rect()
29-
if execenv.unattended:
30-
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
31-
elif rect is not None:
32-
print("Area:", rect)
28+
if shape is not None:
29+
rect = shape.get_rect()
30+
if execenv.unattended:
31+
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
32+
elif rect is not None:
33+
print("Area:", rect)
3334

3435

3536
if __name__ == "__main__":

plotpy/tests/gui/test_get_rectangle_with_svg.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ def test_get_rectangle_with_svg():
4343
shape = select_with_shape_tool(
4444
None, SVGToolExample, image, "Test", tooldialogclass=PatchedSelectDialog
4545
)
46-
rect = shape.get_rect()
47-
if execenv.unattended:
48-
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
49-
elif rect is not None:
50-
print("Area:", rect)
46+
if shape is not None:
47+
rect = shape.get_rect()
48+
if execenv.unattended:
49+
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
50+
elif rect is not None:
51+
print("Area:", rect)
5152

5253

5354
if __name__ == "__main__":

plotpy/tests/gui/test_get_segment.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ def test_get_segment():
5050
"Test",
5151
tooldialogclass=PatchedSelectDialog,
5252
)
53-
rect = shape.get_rect()
54-
if execenv.unattended:
55-
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
56-
elif rect is not None:
57-
distance = np.sqrt((rect[2] - rect[0]) ** 2 + (rect[3] - rect[1]) ** 2)
58-
print("Distance:", distance)
53+
if shape is not None:
54+
rect = shape.get_rect()
55+
if execenv.unattended:
56+
assert [round(i) for i in list(rect)] == SEG_AXES_COORDS
57+
elif rect is not None:
58+
distance = np.sqrt((rect[2] - rect[0]) ** 2 + (rect[3] - rect[1]) ** 2)
59+
print("Distance:", distance)
5960

6061

6162
if __name__ == "__main__":

0 commit comments

Comments
 (0)