Skip to content

Commit

Permalink
Disable GC, shorten switchinterval to improve test determinism
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiirola committed Nov 8, 2024
1 parent 9b249bf commit 23919b1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pyomo/common/tests/test_tee.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# This software is distributed under the 3-clause BSD License.
# ___________________________________________________________________________

import gc
import os
import time
import sys
Expand All @@ -23,6 +24,20 @@


class TestTeeStream(unittest.TestCase):
def setUp(self):
self.reenable_gc = gc.isenabled()
gc.disable()
# Set a short switch interval so that the threading tests behave
# as expected
self.switchinterval = sys.getswitchinterval()
sys.setswitchinterval(tee._poll_interval / 100)

def tearDown(self):
sys.setswitchinterval(self.switchinterval)
if self.reenable_gc:
gc.enable()
gc.collect()

def test_stdout(self):
a = StringIO()
b = StringIO()
Expand Down

0 comments on commit 23919b1

Please sign in to comment.