Adds unit test for #225: Manuskript fails to run in Ubuntu 14.04

This commit is contained in:
Olivier Keshavjee 2017-11-22 09:08:54 +01:00
parent ba4fe6b57a
commit f945387066
4 changed files with 37 additions and 1 deletions

View file

@ -17,6 +17,15 @@ def MW():
return MW
@pytest.fixture
def MWNoProject(MW):
"""
Take the MainWindow and close andy possibly open project.
"""
MW.closeProject()
assert MW.currentProject is None
return MW
@pytest.fixture
def MWEmptyProject(MW):
"""

View file

@ -0,0 +1,4 @@
#!/usr/bin/env python
# --!-- coding: utf8 --!--
"""Tests for stuff in ui."""

View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
# --!-- coding: utf8 --!--
"""Tests for the welcome widget."""
def test_autoLoad(MWNoProject):
"""
Tests for the welcome widget using MainWindow with no open project.
"""
MW = MWNoProject
from PyQt5.QtCore import QSettings
# Testing when no autoLoad
QSettings().remove("autoLoad")
autoLoad, path = MW.welcome.getAutoLoadValues()
assert type(autoLoad) == bool
assert autoLoad == False
for v in [True, False, 42, "42", None, True]:
MW.welcome.setAutoLoad(v)
autoLoad, path = MW.welcome.getAutoLoadValues()
assert type(autoLoad) == bool

View file

@ -77,7 +77,8 @@ class welcome(QWidget, Ui_welcome):
return autoLoad, last
def setAutoLoad(self, v):
QSettings().setValue("autoLoad", v)
if type(v) == bool:
QSettings().setValue("autoLoad", v)
###############################################################################
# RECENTS