Remove debug print and add test coverage

This commit is contained in:
Veronica K. B. Olsen
2021-02-17 09:53:27 +01:00
parent 7591095f2a
commit fb09066679
8 changed files with 38 additions and 451 deletions
+8
View File
@@ -61,6 +61,14 @@ def refDir():
theDir = os.path.join(testDir, "reference")
return theDir
@pytest.fixture(scope="session")
def filesDir():
"""The folder where additional test files are stored.
"""
testDir = os.path.dirname(__file__)
theDir = os.path.join(testDir, "files")
return theDir
@pytest.fixture(scope="session")
def outDir(tmpDir):
"""An output folder for test results
+10
View File
@@ -91,6 +91,16 @@ class DummyStatusBar():
# END Class DummyStatusBar
class DummyApp:
def __init__(self):
return
def installTranslator(self, theLang):
return
# END Class DummyApp
# =========================================================================== #
# Error Functions
# Dummy functions that will raise errors instead.
+1
View File
@@ -0,0 +1 @@
<クd箆!ソ`。スン
+17 -3
View File
@@ -27,8 +27,8 @@ import configparser
from shutil import copyfile
from dummy import causeOSError
from tools import cmpFiles
from dummy import causeOSError, DummyApp
from tools import cmpFiles, writeFile
from nw.config import Config
from nw.constants import nwConst, nwFiles
@@ -85,7 +85,7 @@ def testBaseConfig_Constructor(monkeypatch):
# END Test testBaseConfig_Constructor
@pytest.mark.base
def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir):
def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir, filesDir):
"""Test config intialisation.
"""
tstConf = Config()
@@ -192,6 +192,20 @@ def testBaseConfig_Init(monkeypatch, tmpDir, fncDir, outDir, refDir):
tstConf.doReplaceSQuote = orDoSng
assert tstConf.saveConfig()
# Localisation
i18nDir = os.path.join(fncDir, "i18n")
os.mkdir(i18nDir)
os.mkdir(os.path.join(i18nDir, "stuff"))
tstConf.nwLangPath = i18nDir
copyfile(os.path.join(filesDir, "nw_en_GB.qm"), os.path.join(fncDir, "nw_en_GB.qm"))
writeFile(os.path.join(i18nDir, "nw_en_GB.ts"), "")
writeFile(os.path.join(i18nDir, "nw_abcd.qm"), "")
tstConf.initLocalisation(DummyApp)
theList = tstConf.listLanguages()
assert theList == [("en_GB", "British English")]
copyfile(confFile, testFile)
assert cmpFiles(testFile, compFile, [2, 9, 10])