Skip to content

Commit 6face80

Browse files
committed
TST: add manual user acceptance test
1 parent c7094a3 commit 6face80

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

UAT.py

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
import sys
2+
3+
import matplotlib as mpl
4+
import mpl_gui as mg
5+
from matplotlib.figure import Figure
6+
7+
assert sys.modules.get("matplotlib.pyplot", None) is None
8+
sys.modules["matplotlib.pyplot"] = None
9+
10+
11+
_, target = sys.argv
12+
13+
# this is how to force the right Qt binding
14+
if target.lower().startswith("qt5"):
15+
import PyQt5.QtWidgets # noqa
16+
elif target.lower().startswith("qt"):
17+
import PyQt6.QtWidgets # noqa
18+
19+
mpl.use(target, force=True)
20+
21+
fig1 = Figure(label="A Label!")
22+
23+
fig2 = Figure()
24+
25+
print(
26+
"""
27+
You should see two figures with window titles of
28+
29+
- "A Label!"
30+
- "Figure 0"
31+
32+
both should be empty and the process should block until both
33+
are closed (the keybinding 'q' should work).
34+
"""
35+
)
36+
mg.show([fig1, fig2])
37+
38+
mg.ion()
39+
fig = Figure()
40+
print(f"Interactive mode is on: {mg.is_interactive()}")
41+
mg.show([fig]) # will not block
42+
print("A (implicitly) non-blocking show was just called.")
43+
mg.ioff()
44+
print(mg.is_interactive())
45+
print(f"Interactive mode is on: {mg.is_interactive()}")
46+
print(
47+
"""
48+
You should see one open figure with the title
49+
50+
- Figure 2
51+
52+
and the process should again block until it is closed.
53+
"""
54+
)
55+
56+
mg.show([fig]) # will block!
57+
58+
fig = Figure(label="control blocking")
59+
60+
mg.show([fig], block=False) # will never block
61+
print("A (implicitly) non-blocking show was just called.")
62+
print(
63+
"""
64+
You should see one open figure with the title
65+
66+
- control blocking
67+
68+
and the process should again block until it is closed.
69+
"""
70+
)
71+
mg.show([fig], block=True) # will always block
72+
73+
74+
fig1 = mg.figure()
75+
fig2, axs = mg.subplots(2, 2)
76+
fig3, axd = mg.subplot_mosaic("AA\nBC")
77+
78+
print(
79+
"""
80+
You should see three open figure with the titles
81+
82+
- Figure 4
83+
- Figure 5
84+
- Figure 6
85+
86+
and the process should again block until it is closed. One will
87+
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
88+
"""
89+
)
90+
91+
mg.show([fig1, fig2, fig3])
92+
93+
94+
fr = mg.FigureRegistry()
95+
96+
fr.figure()
97+
fr.subplots(2, 2)
98+
fr.subplot_mosaic("AA\nBC")
99+
100+
print(
101+
"""
102+
You should see three open figure with the titles
103+
104+
- Figure 0
105+
- Figure 1
106+
- Figure 2
107+
108+
and the process should again block until it is closed. One will
109+
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
110+
"""
111+
)
112+
113+
fr.show_all() # will show all three figures
114+
# fr.show() # alias for pyplot compatibility
115+
116+
# fr.close_all() # will close all three figures
117+
# fr.close("all") # alias for pyplot compatibility
118+
119+
120+
plt = mg.FigureRegistry()
121+
122+
123+
with mg.FigureContext() as fc:
124+
fc.subplot_mosaic("AA\nBC")
125+
fc.figure()
126+
fc.subplots(2, 2)
127+
128+
print(
129+
"""
130+
You should see three open figure with the titles
131+
132+
- Figure 0
133+
- Figure 1
134+
- Figure 2
135+
136+
and the process should again block until it is closed. One will
137+
be empty, one will have a 2x2 grid, One will have `AA;BC` layout.
138+
"""
139+
)

0 commit comments

Comments
 (0)