diff --git a/tests/test_lib.py b/tests/test_lib.py index 1e49f549..68b04675 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -28,7 +28,6 @@ import signal import multiprocessing import unittest -from unittest import SkipTest # Given that this test is in the tests directory, the calibration data should be # in a sub directory. Use the path of this source file to find the calibration @@ -346,14 +345,6 @@ def check_args(Q, A, initial_chains=None, fixed_chains=None, restrict_chains=Non u, fullset)) & edgelord, "%s and %s are connected as variables but not as domains" % (u, v) -def skip_if(cond): - if cond: - def _skip(): - raise SkipTest - return lambda f: _skip - else: - return lambda f: f - class TestFindEmbedding(unittest.TestCase): @staticmethod @success_count(100, 5) @@ -848,34 +839,13 @@ def test_variable_components_many(): return find_embedding(K, C, tries=1, chainlength_patience=0) @staticmethod - @skip_if( - # there appears to be a bug in the osx, py3.8+ version of multiprocessing. - # this has turned into a yak-shaving exercise and I'm not doing any more here - # for the time being -- #TODO if anybody has a mac and they wanna dig in, please do - (sys.version_info[:2] >= (3, 8) and sys.platform == 'darwin') or - - # TODO this test seems to actually work on windows but it's doing something funky - # to our appveyor framework. Giving up on yak-shaving 'cause we're going to retire - # appveyor soon - (sys.platform == 'win32') - ) - @staticmethod + @unittest.skipIf(sys.platform == 'win32', 'Test may hang on win32, skipping out of caution') @success_perfect(1) def test_interactive_interrupt(): return run_interactive_interrupt(True) == 0 @staticmethod - @skip_if( - # there appears to be a bug in the osx, py3.8+ version of multiprocessing. - # this has turned into a yak-shaving exercise and I'm not doing any more here - # for the time being -- #TODO if anybody has a mac and they wanna dig in, please do - (sys.version_info[:2] >= (3, 8) and sys.platform == 'darwin') or - - # TODO this test seems to actually work on windows but it's doing something funky - # to our appveyor framework. Giving up on yak-shaving 'cause we're going to retire - # appveyor soon - (sys.platform == 'win32') - ) + @unittest.skipIf(sys.platform == 'win32', 'Test hangs on win32') @success_perfect(1) def test_headless_interrupt(): return run_interactive_interrupt(False) == 2 @@ -887,11 +857,11 @@ def _long_running_successful_problem(interactive): t0 = time.perf_counter() try: find_embedding_orig(C, C, chainlength_patience=1 << 20, - interactive=interactive, timeout=1) + interactive=interactive, timeout=2) except KeyboardInterrupt: sys.exit(2) - if time.perf_counter() - t0 > .5: - # be a little generous here... but the caller should kill this in way less than .5s + if time.perf_counter() - t0 > 1.5: + # be a little generous here... but the caller should kill this in way less than 1.5s sys.exit(1) @@ -904,7 +874,7 @@ def run_interactive_interrupt(interactive): p = multiprocessing.Process( target=_long_running_successful_problem, args=(interactive,)) p.start() - time.sleep(.1) + time.sleep(.1 if sys.platform == 'linux' else 1) os.kill(p.pid, ctrl_c) p.join() # exitcode 0: terminated successfully (interactive mode catches the interrupt)