From 159e1c3f755ccb29dc73d699c1dec09a6b18c52d Mon Sep 17 00:00:00 2001 From: Olivier Keshavjee Date: Sun, 19 Nov 2017 00:20:49 +0100 Subject: [PATCH] Adds mainWindow and completes function.py coverage --- .gitignore | 3 ++- manuskript/tests/__init__.py | 14 -------------- manuskript/tests/conftest.py | 21 +++++++++++++++++++++ manuskript/tests/test_functions.py | 25 ++++++++++--------------- 4 files changed, 33 insertions(+), 30 deletions(-) create mode 100644 manuskript/tests/conftest.py diff --git a/.gitignore b/.gitignore index abbe884..d94acef 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ icons/Numix .idea dist build -test-projects \ No newline at end of file +test-projects +.cache diff --git a/manuskript/tests/__init__.py b/manuskript/tests/__init__.py index 652b0d3..772c83c 100644 --- a/manuskript/tests/__init__.py +++ b/manuskript/tests/__init__.py @@ -9,17 +9,3 @@ import pytest # will throw a seg fault. from PyQt5.QtWidgets import QApplication app = QApplication([]) - -@pytest.yield_fixture(scope='session', autouse=True) -def MW(): - - # Creates a mainWindow that can be used for the tests - # Either with functions.mainWindow or by passing argument - # MW to the test - from manuskript.mainWindow import MainWindow - mw = MainWindow() - - yield - - # Properly destructed after. Otherwise: seg fault. - mw.deleteLater() diff --git a/manuskript/tests/conftest.py b/manuskript/tests/conftest.py new file mode 100644 index 0000000..5c00100 --- /dev/null +++ b/manuskript/tests/conftest.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# --!-- coding: utf8 --!-- + +"""Fixtures.""" + +import pytest + +@pytest.fixture(scope='session', autouse=True) +def MW(): + """ + Creates a mainWindow that can be used for the tests + Either with functions.mainWindow or by passing argument + MW to the test + """ + from manuskript.mainWindow import MainWindow + mw = MainWindow() + + yield + + # Properly destructed after. Otherwise: seg fault. + mw.deleteLater() diff --git a/manuskript/tests/test_functions.py b/manuskript/tests/test_functions.py index 367c22b..3a5c999 100644 --- a/manuskript/tests/test_functions.py +++ b/manuskript/tests/test_functions.py @@ -41,9 +41,6 @@ def test_several(): d = F.colorFromProgress(1.5) assert a != b != c != d - # mainWindow - # assert F.mainWindow() == None # Because there is no MW - # iconColor & iconFromColor & iconFromColorString icon = F.iconFromColorString("#ff0000") assert F.iconColor(icon).name().lower() == "#ff0000" @@ -86,15 +83,13 @@ def test_paths(): assert "resources/backgrounds/spacedreams.jpg" in f assert len(F.customIcons()) > 1 -# def test_mainWindow(): -# -# from manuskript.mainWindow import MainWindow -# m = MainWindow() -# -# assert F.mainWindow() is not None -# assert F.MW is not None -# -# F.statusMessage("Test") -# F.printObjects() -# -# m.deleteLater() +def test_mainWindow(): + + from PyQt5.QtWidgets import QWidget + + assert F.mainWindow() is not None + assert F.MW is not None + + F.statusMessage("Test") + F.printObjects() + assert len(F.findWidgetsOfClass(QWidget)) > 0