Skip to content

Commit add49bd

Browse files
author
Michiel de Hoon
committed
simplify test
1 parent 99086de commit add49bd

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

Lib/test/test_tkinter/test_vwait_busyloop_stdin.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
@unittest.skipUnless(support.has_subprocess_support, "test requires subprocess")
13+
@unittest.skipIf(sys.platform == "win32", "test not supported on Windows")
1314
class TkVwaitMainloopStdinTest(unittest.TestCase):
1415

1516
def run_child(self):
@@ -27,15 +28,11 @@ def do_vwait():
2728
end_cpu = time.process_time()
2829
end_wall = time.time()
2930
cpu_frac = (end_cpu - start_cpu) / (end_wall - start_wall)
30-
print(f"CPU fraction during vwait: {cpu_frac:.2f}", flush=True)
31+
print(cpu_frac)
3132
3233
# Schedule vwait and release
3334
interp.after(100, do_vwait)
3435
interp.after(500, lambda: interp.setvar("myvar", "done"))
35-
# Schedule quit to stop mainloop
36-
interp.after(1000, interp.quit)
37-
38-
interp.mainloop()
3936
"""
4037

4138
# Start child in interactive mode, but use -c to execute code immediately
@@ -54,12 +51,10 @@ def test_vwait_stdin_busy_loop(self):
5451
time.sleep(0.15)
5552

5653
# Send input to stdin to trigger the bug
57-
proc.stdin.write(b"x\n")
58-
proc.stdin.flush()
54+
proc.stdin.write(b"\n")
5955

6056
# Ensure child exits cleanly
6157
proc.stdin.write(b"exit()\n")
62-
proc.stdin.flush()
6358

6459
stdout, stderr = proc.communicate()
6560
out = stdout.decode("utf-8", errors="replace")
@@ -69,13 +64,7 @@ def test_vwait_stdin_busy_loop(self):
6964
self.fail(f"Child exited with {proc.returncode}\nSTDOUT:\n{out}\nSTDERR:\n{err}")
7065

7166
# Extract CPU fraction printed by child
72-
cpu_frac = None
73-
for line in out.splitlines():
74-
if line.startswith("CPU fraction during vwait:"):
75-
cpu_frac = float(line.split(":")[1].strip())
76-
break
77-
78-
self.assertIsNotNone(cpu_frac, "CPU fraction not printed by child")
67+
cpu_frac = float(out)
7968

8069
# Fail if CPU fraction is too high (indicative of busy-loop)
8170
self.assertLess(cpu_frac, 0.5,

0 commit comments

Comments
 (0)