Adds mainWindow and completes function.py coverage

This commit is contained in:
Olivier Keshavjee 2017-11-19 00:20:49 +01:00
parent 1a5fdc7b1f
commit 159e1c3f75
4 changed files with 33 additions and 30 deletions

3
.gitignore vendored
View file

@ -11,4 +11,5 @@ icons/Numix
.idea .idea
dist dist
build build
test-projects test-projects
.cache

View file

@ -9,17 +9,3 @@ import pytest
# will throw a seg fault. # will throw a seg fault.
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
app = 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()

View file

@ -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()

View file

@ -41,9 +41,6 @@ def test_several():
d = F.colorFromProgress(1.5) d = F.colorFromProgress(1.5)
assert a != b != c != d assert a != b != c != d
# mainWindow
# assert F.mainWindow() == None # Because there is no MW
# iconColor & iconFromColor & iconFromColorString # iconColor & iconFromColor & iconFromColorString
icon = F.iconFromColorString("#ff0000") icon = F.iconFromColorString("#ff0000")
assert F.iconColor(icon).name().lower() == "#ff0000" assert F.iconColor(icon).name().lower() == "#ff0000"
@ -86,15 +83,13 @@ def test_paths():
assert "resources/backgrounds/spacedreams.jpg" in f assert "resources/backgrounds/spacedreams.jpg" in f
assert len(F.customIcons()) > 1 assert len(F.customIcons()) > 1
# def test_mainWindow(): def test_mainWindow():
#
# from manuskript.mainWindow import MainWindow from PyQt5.QtWidgets import QWidget
# m = MainWindow()
# assert F.mainWindow() is not None
# assert F.mainWindow() is not None assert F.MW is not None
# assert F.MW is not None
# F.statusMessage("Test")
# F.statusMessage("Test") F.printObjects()
# F.printObjects() assert len(F.findWidgetsOfClass(QWidget)) > 0
#
# m.deleteLater()