From df5aa60049d32f93501b7983e4fabe7d317fc0a5 Mon Sep 17 00:00:00 2001 From: John Siirola Date: Tue, 4 Feb 2025 21:56:58 -0700 Subject: [PATCH 1/2] Remove the special handling for pypy; add a retry --- pyomo/common/tests/test_tee.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pyomo/common/tests/test_tee.py b/pyomo/common/tests/test_tee.py index d3bbccad96a..97760115a22 100644 --- a/pyomo/common/tests/test_tee.py +++ b/pyomo/common/tests/test_tee.py @@ -334,7 +334,7 @@ def test_buffered_stdout(self): if not ts.check(*baseline): self.fail(ts.error) - def test_buffered_stdout_flush(self): + def test_buffered_stdout_flush(self, retry=True): # Test 2: short messages to STDOUT that are flushed are flushed fd = self.capture_fd ts = timestamper() @@ -345,9 +345,14 @@ def test_buffered_stdout_flush(self): time.sleep(self.dt) ts.write(f"{time.time()}\n") if not ts.check([(0, 0), (0, 0), (0, 0), (1, 1)]): - # TODO: For some reason, some part of the flush logic is not - # reliable under pypy. - if not platform.python_implementation().lower().startswith('pypy'): + # FIXME: We don't know why, but this test will + # intermittently fail. For the moment, we will just wait a + # little and give it a second chance with a longer delay. + if retry: + time.sleep(self.dt) + self.dt *= 2.5 + self.test_buffered_stdout_flush(False) + else: self.fail(ts.error) def test_buffered_stdout_long_message(self): From 98fbb97d06b9e8b84d19a0d01d0e4a8f582365a8 Mon Sep 17 00:00:00 2001 From: John Siirola Date: Tue, 4 Feb 2025 23:32:47 -0700 Subject: [PATCH 2/2] Restoore test skip under pypy --- pyomo/common/tests/test_tee.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyomo/common/tests/test_tee.py b/pyomo/common/tests/test_tee.py index 97760115a22..e3740e39604 100644 --- a/pyomo/common/tests/test_tee.py +++ b/pyomo/common/tests/test_tee.py @@ -352,6 +352,10 @@ def test_buffered_stdout_flush(self, retry=True): time.sleep(self.dt) self.dt *= 2.5 self.test_buffered_stdout_flush(False) + elif platform.python_implementation().lower().startswith('pypy'): + # TODO: For some reason, some part of the flush logic is + # not reliable under pypy. + pass else: self.fail(ts.error)