Skip to content

Commit e67ea33

Browse files
committed
Mandelbrot test: minor refactoring
1 parent d7d9d47 commit e67ea33

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

plotpy/tests/items/test_mandelbrot.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from plotpy.config import _
1616
from plotpy.items import RawImageItem
1717
from plotpy.mandelbrot import mandelbrot
18-
from plotpy.tools.base import ToggleTool
18+
from plotpy.tools import ToggleTool
1919

2020

2121
class FullScale(ToggleTool):
@@ -64,20 +64,26 @@ def draw_image(self, painter, canvasRect, srcRect, dstRect, xMap, yMap):
6464
)
6565

6666

67+
def create_mandelbrot_window():
68+
"""Create a Mandelbrot set window"""
69+
win = make.window(
70+
toolbar=True,
71+
wintitle="Mandelbrot",
72+
yreverse=False,
73+
type="image",
74+
)
75+
mandel = MandelItem(-1.5, 0.5, -1.0, 1.0)
76+
fstool = win.manager.add_tool(FullScale, mandel)
77+
plot = win.get_plot()
78+
plot.set_aspect_ratio(lock=False)
79+
plot.add_item(mandel)
80+
return win, mandel, fstool
81+
82+
6783
def test_mandel():
84+
"""Test Mandelbrot set window"""
6885
with qt_app_context(exec_loop=True):
69-
win = make.dialog(
70-
edit=True,
71-
toolbar=True,
72-
wintitle="Mandelbrot",
73-
yreverse=False,
74-
type="image",
75-
)
76-
mandel = MandelItem(-1.5, 0.5, -1.0, 1.0)
77-
win.manager.add_tool(FullScale, mandel)
78-
plot = win.manager.get_plot()
79-
plot.set_aspect_ratio(lock=False)
80-
plot.add_item(mandel)
86+
win, _mandel, _fstool = create_mandelbrot_window()
8187
win.show()
8288

8389

0 commit comments

Comments
 (0)