test_timeout: Skip test_timeout_warn on Python 3.11 for coverage issue.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-05-16 17:18:17 -07:00
committed by Tim Abbott
parent 480a2e2d64
commit 4b19863065
2 changed files with 5 additions and 2 deletions

View File

@@ -84,9 +84,9 @@ def timeout(timeout: float, func: Callable[[], ResultT]) -> ResultT:
# kill it), just raise from here; the thread _may still be # kill it), just raise from here; the thread _may still be
# running_ because it failed to see any of our exceptions, and # running_ because it failed to see any of our exceptions, and
# we just ignore it. # we just ignore it.
if thread.is_alive(): if thread.is_alive(): # nocoverage
logging.warning("Failed to time out backend thread") logging.warning("Failed to time out backend thread")
raise TimeoutExpiredError raise TimeoutExpiredError # nocoverage
if thread.exc_info[1] is not None: if thread.exc_info[1] is not None:
# Died with some other exception; re-raise it # Died with some other exception; re-raise it

View File

@@ -1,5 +1,7 @@
import sys
import time import time
import traceback import traceback
from unittest import skipIf
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timeout import TimeoutExpiredError, timeout from zerver.lib.timeout import TimeoutExpiredError, timeout
@@ -39,6 +41,7 @@ class TimeoutTestCase(ZulipTestCase):
self.assertIn("in something_exceptional", tb[-1]) self.assertIn("in something_exceptional", tb[-1])
self.assertIn("raise ValueError", tb[-1]) self.assertIn("raise ValueError", tb[-1])
@skipIf(sys.version_info >= (3, 11), "https://github.com/nedbat/coveragepy/issues/1626")
def test_timeout_warn(self) -> None: def test_timeout_warn(self) -> None:
# If the sleep is long enough, it will outlast the attempts to # If the sleep is long enough, it will outlast the attempts to
# kill it # kill it