-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adf3d5f
commit b68a9f0
Showing
7 changed files
with
81 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Author: Matt Clifford <[email protected]> | ||
# License: BSD 3-Clause License | ||
import pytest | ||
from PyQt6 import QtTest, QtWidgets, QtCore | ||
from pytestqt.plugin import QtBot | ||
import IQM_Vis | ||
|
||
|
||
def default_UI(): | ||
app = IQM_Vis.make_UI(test=True) | ||
return app | ||
|
||
|
||
# building and closing function of UI for testing | ||
class BotTester: | ||
def __init__(self, get_UI=default_UI, wait_time=100, final_wait=False): | ||
self.get_UI = get_UI | ||
self.wait_time = wait_time | ||
self.final_wait = final_wait | ||
|
||
@pytest.fixture(scope='function') | ||
def build_IQM_Vis(self): | ||
# Setup | ||
test_window = self.get_UI() | ||
qtbotbis = QtBot(test_window.window) | ||
|
||
yield test_window, qtbotbis | ||
|
||
# Clean up | ||
QtTest.QTest.qWait(1000) | ||
|
||
# need to handle the closing dialog | ||
def handle_dialog(): | ||
messagebox = QtWidgets.QApplication.activeWindow() | ||
yes_button = messagebox.button( | ||
QtWidgets.QMessageBox.StandardButton.Yes) | ||
qtbotbis.mouseClick( | ||
yes_button, QtCore.Qt.MouseButton.LeftButton, delay=1) | ||
|
||
QtCore.QTimer.singleShot(100, handle_dialog) | ||
|
||
test_window.window.main.close() | ||
# if self.final_wait: | ||
QtTest.QTest.qWait(1000) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
# Author: Matt Clifford <[email protected]> | ||
# License: BSD 3-Clause License | ||
|
||
import pytest | ||
from PyQt6 import QtTest, QtWidgets, QtCore | ||
from pytestqt.plugin import QtBot | ||
import IQM_Vis | ||
import sys | ||
import os | ||
sys.path.append(os.path.abspath('..')) | ||
from tests.QtBot_utils import BotTester | ||
|
||
|
||
def get_UI(): | ||
|
@@ -49,33 +49,8 @@ def get_UI(): | |
return test_app | ||
|
||
|
||
# building and closing function of UI for testing | ||
@pytest.fixture(scope='function') | ||
def build_IQM_Vis(): | ||
# QtTest.QTest.qWait(5000) | ||
# Setup | ||
test_window = get_UI() | ||
qtbotbis = QtBot(test_window.window) | ||
|
||
yield test_window, qtbotbis | ||
|
||
# Clean up | ||
QtTest.QTest.qWait(100) | ||
|
||
# need to handle the closing dialog | ||
def handle_dialog(): | ||
messagebox = QtWidgets.QApplication.activeWindow() | ||
yes_button = messagebox.button( | ||
QtWidgets.QMessageBox.StandardButton.Yes) | ||
qtbotbis.mouseClick( | ||
yes_button, QtCore.Qt.MouseButton.LeftButton, delay=1) | ||
|
||
QtCore.QTimer.singleShot(100, handle_dialog) | ||
|
||
# test_window.window.quit() | ||
test_window.window.main.close() | ||
# QtTest.QTest.qWait(5000) | ||
|
||
build_IQM_Vis = BotTester(get_UI=get_UI, wait_time=1000, | ||
final_wait=True).build_IQM_Vis | ||
|
||
def test_sliders(build_IQM_Vis): | ||
test_window, qtbotbis = build_IQM_Vis | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,19 @@ | ||
# Author: Matt Clifford <[email protected]> | ||
# License: BSD 3-Clause License | ||
|
||
import pytest | ||
from PyQt6 import QtTest, QtWidgets, QtCore | ||
from pytestqt.plugin import QtBot | ||
import IQM_Vis | ||
|
||
import sys | ||
import os | ||
sys.path.append(os.path.abspath('..')) | ||
from tests.QtBot_utils import BotTester | ||
|
||
def get_UI(): | ||
app = IQM_Vis.make_UI(test=True) | ||
return app | ||
|
||
|
||
# building and closing function of UI for testing | ||
@pytest.fixture(scope='function') | ||
def build_IQM_Vis(): | ||
# Setup | ||
test_window = get_UI() | ||
qtbotbis = QtBot(test_window.window) | ||
|
||
yield test_window, qtbotbis | ||
|
||
# Clean up | ||
QtTest.QTest.qWait(100) | ||
|
||
# need to handle the closing dialog | ||
def handle_dialog(): | ||
messagebox = QtWidgets.QApplication.activeWindow() | ||
yes_button = messagebox.button( | ||
QtWidgets.QMessageBox.StandardButton.Yes) | ||
qtbotbis.mouseClick( | ||
yes_button, QtCore.Qt.MouseButton.LeftButton, delay=1) | ||
|
||
QtCore.QTimer.singleShot(100, handle_dialog) | ||
|
||
# test_window.window.quit() | ||
test_window.window.main.close() | ||
# QtTest.QTest.qWait(1000) | ||
build_IQM_Vis = BotTester(get_UI=get_UI).build_IQM_Vis | ||
|
||
|
||
def test_build_1(build_IQM_Vis): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
# Author: Matt Clifford <[email protected]> | ||
# License: BSD 3-Clause License | ||
|
||
import pytest | ||
from PyQt6 import QtTest, QtWidgets, QtCore | ||
from pytestqt.plugin import QtBot | ||
from tests.QtBot_utils import BotTester | ||
import IQM_Vis | ||
|
||
import sys | ||
import os | ||
sys.path.append(os.path.abspath('..')) | ||
|
||
|
||
def get_UI(): | ||
image1 = IQM_Vis.examples.images.IMAGE1 | ||
|
@@ -50,35 +52,10 @@ def get_UI(): | |
return test_app | ||
|
||
|
||
# building and closing function of UI for testing | ||
@pytest.fixture(scope='function') | ||
def build_IQM_Vis(): | ||
# QtTest.QTest.qWait(5000) | ||
# Setup | ||
test_window = get_UI() | ||
qtbotbis = QtBot(test_window.window) | ||
|
||
yield test_window, qtbotbis | ||
|
||
# Clean up | ||
QtTest.QTest.qWait(100) | ||
|
||
# need to handle the closing dialog | ||
def handle_dialog(): | ||
messagebox = QtWidgets.QApplication.activeWindow() | ||
yes_button = messagebox.button( | ||
QtWidgets.QMessageBox.StandardButton.Yes) | ||
qtbotbis.mouseClick( | ||
yes_button, QtCore.Qt.MouseButton.LeftButton, delay=1) | ||
|
||
QtCore.QTimer.singleShot(100, handle_dialog) | ||
|
||
# test_window.window.quit() | ||
test_window.window.main.close() | ||
# QtTest.QTest.qWait(5000) | ||
build_IQM_Vis = BotTester(get_UI=get_UI).build_IQM_Vis | ||
|
||
|
||
def test_build_2(build_IQM_Vis): | ||
def test_build_1(build_IQM_Vis): | ||
test_window, _ = build_IQM_Vis | ||
assert test_window.showing == True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="0" time="3.470" timestamp="2024-10-09T13:01:49.633122" hostname="Dell-5320" /></testsuites> | ||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="13" time="27.636" timestamp="2024-10-09T16:14:46.626846" hostname="Dell-5320"><testcase classname="tests.test_metrics" name="test_all_metrics_initialise" time="0.247" /><testcase classname="tests.test_metrics" name="test_all_metrics_images_initialise" time="0.252" /><testcase classname="tests.test_metrics" name="test_all_metrics_process_image" time="2.069" /><testcase classname="tests.test_metrics" name="test_all_metric_images_process_image" time="0.280" /><testcase classname="tests.test_transforms" name="test_all_transforms_init_value_no_change_image" time="0.259" /><testcase classname="tests.test_transforms" name="test_all_transforms_min_max_specified" time="0.256" /><testcase classname="tests.test_transforms" name="test_all_transforms_min_change_image" time="0.301" /><testcase classname="tests.test_transforms" name="test_all_transforms_max_change_image" time="0.359" /><testcase classname="tests.UI.test_sliders" name="test_sliders" time="3.176" /><testcase classname="tests.notebook_examples.test_1_making_the_UI" name="test_build_1" time="3.073" /><testcase classname="tests.notebook_examples.test_2_simple_customisation" name="test_build_1" time="3.203" /><testcase classname="tests.notebook_examples.test_3_customisation_details" name="test_build_3" time="3.173" /><testcase classname="tests.notebook_examples.test_4_experiment" name="test_experiment_runs" time="8.071" /></testsuite></testsuites> |