let examples have a chance to exit normally
cleanup imported module 1) instantiate MainWindow class if present 2) delete attributes from imported module when done
This commit is contained in:
parent
2318f49bc4
commit
de11e6315c
@ -212,22 +212,23 @@ def testExamples(frontend, f):
|
|||||||
import2 = os.path.splitext(os.path.split(fn)[1])[0]
|
import2 = os.path.splitext(os.path.split(fn)[1])[0]
|
||||||
code = """
|
code = """
|
||||||
try:
|
try:
|
||||||
%s
|
{0}
|
||||||
import initExample
|
import initExample
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
import %s
|
import {1}
|
||||||
import sys
|
import sys
|
||||||
print("test complete")
|
print("test complete")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
import time
|
pg.Qt.QtCore.QTimer.singleShot(1000, pg.Qt.QtWidgets.QApplication.quit)
|
||||||
while True: ## run a little event loop
|
pg.Qt.QtWidgets.QApplication.instance().exec_()
|
||||||
pg.QtGui.QApplication.processEvents()
|
names = [x for x in dir({1}) if not x.startswith('_')]
|
||||||
time.sleep(0.01)
|
for name in names:
|
||||||
|
delattr({1}, name)
|
||||||
except:
|
except:
|
||||||
print("test failed")
|
print("test failed")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
""" % (import1, import2)
|
""".format(import1, import2)
|
||||||
if sys.platform.startswith('win'):
|
if sys.platform.startswith('win'):
|
||||||
process = subprocess.Popen([sys.executable],
|
process = subprocess.Popen([sys.executable],
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
@ -259,8 +260,13 @@ except:
|
|||||||
if output.endswith('test failed'):
|
if output.endswith('test failed'):
|
||||||
fail = True
|
fail = True
|
||||||
break
|
break
|
||||||
time.sleep(1)
|
start = time.time()
|
||||||
process.kill()
|
killed = False
|
||||||
|
while process.poll() is None:
|
||||||
|
time.sleep(0.1)
|
||||||
|
if time.time() - start > 2.0 and not killed:
|
||||||
|
process.kill()
|
||||||
|
killed = True
|
||||||
#res = process.communicate()
|
#res = process.communicate()
|
||||||
res = (process.stdout.read(), process.stderr.read())
|
res = (process.stdout.read(), process.stderr.read())
|
||||||
if (fail or
|
if (fail or
|
||||||
|
Loading…
Reference in New Issue
Block a user