From aa8572048bdc4947520de728fe2a3fec3b61815f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Fri, 11 Sep 2020 13:54:40 -0400 Subject: [PATCH] uitests: Add a fixture for passing in VMMDogtailApp Reproducing what the custom unittest TestCase does. Convert test_about as a demo Signed-off-by: Cole Robinson --- tests/uitests/conftest.py | 17 +++++++++++++++++ tests/uitests/test_about.py | 31 +++++++++++++------------------ tests/uitests/test_details.py | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 tests/uitests/conftest.py diff --git a/tests/uitests/conftest.py b/tests/uitests/conftest.py new file mode 100644 index 000000000..61cabdd97 --- /dev/null +++ b/tests/uitests/conftest.py @@ -0,0 +1,17 @@ +# This work is licensed under the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +import pytest + + +@pytest.fixture +def app(): + """ + Custom pytest fixture to a VMMDogtailApp instance to the testcase + """ + from .lib.app import VMMDogtailApp + testapp = VMMDogtailApp() + try: + yield testapp + finally: + testapp.stop() diff --git a/tests/uitests/test_about.py b/tests/uitests/test_about.py index 07368f5bc..06c09d780 100644 --- a/tests/uitests/test_about.py +++ b/tests/uitests/test_about.py @@ -6,24 +6,19 @@ import datetime from . import lib -class VMMAbout(lib.testcase.UITestCase): - """ - UI tests for the 'About' dialog - """ +################################### +# UI tests for the 'About' dialog # +################################### - ############## - # Test cases # - ############## +def testAbout(app): + app.root.find("Help", "menu").click() + app.root.find("About", "menu item").click() + win = app.root.find_fuzzy("About", "dialog") + l = win.find_fuzzy("Copyright", "label") - def testAbout(self): - self.app.root.find("Help", "menu").click() - self.app.root.find("About", "menu item").click() - win = self.app.root.find_fuzzy("About", "dialog") - l = win.find_fuzzy("Copyright", "label") + curyear = datetime.datetime.today().strftime("%Y") + if curyear not in l.text: + print("Current year=%s not in about.ui dialog!" % curyear) - curyear = datetime.datetime.today().strftime("%Y") - if curyear not in l.text: - print("Current year=%s not in about.ui dialog!" % curyear) - - win.keyCombo("") - lib.utils.check(lambda: win.visible is False) + win.keyCombo("") + lib.utils.check(lambda: win.visible is False) diff --git a/tests/uitests/test_details.py b/tests/uitests/test_details.py index 6418529f6..13c36d98b 100644 --- a/tests/uitests/test_details.py +++ b/tests/uitests/test_details.py @@ -57,7 +57,7 @@ class Details(lib.testcase.UITestCase): return win def testDetailsHardwareSmokeTest(self): - self._testSmokeTest(None) + self._testSmokeTest("test-many-devices") def testDetailsHardwareSmokeTestAlternate(self): self.app.open(keyfile="allstats.ini")