From ceeacf4e5fea1c1e44ee6f40d34c4ad11d1bea35 Mon Sep 17 00:00:00 2001 From: Ogi Moore Date: Fri, 28 May 2021 16:40:50 -0700 Subject: [PATCH] Remove test_exit_crash.py This file contains two tests, one of which has been skipped forever, and the second (test_pg_exit) has been a flakey test that does not test in general, testing a use-case we likely do not see any more. So therefore I am removing this test from the library. --- tests/test_exit_crash.py | 79 ---------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 tests/test_exit_crash.py diff --git a/tests/test_exit_crash.py b/tests/test_exit_crash.py deleted file mode 100644 index e5661386..00000000 --- a/tests/test_exit_crash.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -import os -import sys -import subprocess -import tempfile -import pyqtgraph as pg -import pytest -import textwrap -import time - -code = """ -import sys -sys.path.insert(0, '{path}') -import pyqtgraph as pg -app = pg.mkQApp() -w = pg.{classname}({args}) -""" - -skipmessage = ('unclear why this test is failing. skipping until someone has' - ' time to fix it') - - -def call_with_timeout(*args, **kwargs): - """Mimic subprocess.call with timeout for python < 3.3""" - wait_per_poll = 0.1 - try: - timeout = kwargs.pop('timeout') - except KeyError: - timeout = 10 - - rc = None - p = subprocess.Popen(*args, **kwargs) - for i in range(int(timeout/wait_per_poll)): - rc = p.poll() - if rc is not None: - break - time.sleep(wait_per_poll) - return rc - - -@pytest.mark.skipif(True, reason=skipmessage) -def test_exit_crash(): - # For each Widget subclass, run a simple python script that creates an - # instance and then shuts down. The intent is to check for segmentation - # faults when each script exits. - tmp = tempfile.mktemp(".py") - path = os.path.dirname(pg.__file__) - - initArgs = { - 'CheckTable': "[]", - 'ProgressDialog': '"msg"', - 'VerticalLabel': '"msg"', - } - - for name in dir(pg): - obj = getattr(pg, name) - if not isinstance(obj, type) or not issubclass(obj, pg.QtGui.QWidget): - continue - - print(name) - argstr = initArgs.get(name, "") - with open(tmp, 'w') as f: - f.write(code.format(path=path, classname=name, args=argstr)) - proc = subprocess.Popen([sys.executable, tmp]) - assert proc.wait() == 0 - - os.remove(tmp) - -@pytest.mark.skipif(pg.Qt.QtVersion.startswith("5.9"), reason="Functionality not well supported, failing only on this config") -def test_pg_exit(): - # test the pg.exit() function - code = textwrap.dedent(""" - import pyqtgraph as pg - app = pg.mkQApp() - pg.plot() - pg.exit() - """) - rc = call_with_timeout([sys.executable, '-c', code], timeout=5, shell=False) - assert rc == 0