Addon Manager: Improve unit tests for utlility

This commit is contained in:
Chris Hennes
2022-08-08 10:51:32 -05:00
parent b6e2fb17d0
commit 4def062fe2
3 changed files with 5 additions and 1 deletions

View File

@@ -22,6 +22,7 @@
# * *
# ***************************************************************************
import json
import unittest
import os
import tempfile
@@ -55,7 +56,7 @@ class TestWorkersStartup(unittest.TestCase):
# Populated when the addon list is created in the first test
self.package_cache = {}
self.macro_cache = {}
self.macro_cache = []
self.package_cache_file = tempfile.NamedTemporaryFile(mode='w', encoding="utf-8", delete=False)
self.macro_cache_file = tempfile.NamedTemporaryFile(mode='w', encoding="utf-8", delete=False)

View File

@@ -53,6 +53,7 @@ class TestWorkersUtility(unittest.TestCase):
worker.start()
while worker.isRunning():
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 50)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents)
self.assertEqual(self.last_result,"SUCCESS")
def test_connection_checker_thread_interrupt(self):
@@ -64,6 +65,7 @@ class TestWorkersUtility(unittest.TestCase):
worker.requestInterruption()
while worker.isRunning():
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents, 50)
QtCore.QCoreApplication.processEvents(QtCore.QEventLoop.AllEvents)
self.assertIsNone(self.last_result, "Requesting interruption of thread failed to interrupt")
def connection_succeeded(self):

View File

@@ -45,6 +45,7 @@ class ConnectionChecker(QtCore.QThread):
FreeCAD.Console.PrintLog("Checking network connection...\n")
result = self.check_network_connection()
if QtCore.QThread.currentThread().isInterruptionRequested():
FreeCAD.Console.PrintLog("Connection check cancelled\n")
return
if not result:
self.failure.emit(