From 20e44ad7aeb9107f63cbed9ada955777de135840 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 21 Oct 2020 20:06:08 +0200 Subject: [PATCH] Update tests --- tests/test_dialogs.py | 10 +++++----- tests/test_index.py | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/test_dialogs.py b/tests/test_dialogs.py index abe14b64..e223adae 100644 --- a/tests/test_dialogs.py +++ b/tests/test_dialogs.py @@ -266,7 +266,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp): jsonStats = os.path.join(nwFuncTemp, "sessionStats.json") with open(jsonStats, mode="r", encoding="utf-8") as inFile: - jsonData = json.loads(inFile.read()) + jsonData = json.load(inFile) qtbot.wait(stepDelay) @@ -301,7 +301,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp): jsonStats = os.path.join(nwFuncTemp, "sessionStats.json") with open(jsonStats, mode="r", encoding="utf-8") as inFile: - jsonData = json.loads(inFile.read()) + jsonData = json.load(inFile) assert len(jsonData) == 2 assert jsonData[1]["length"] >= 14.0 @@ -318,7 +318,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp): jsonStats = os.path.join(nwFuncTemp, "sessionStats.json") with open(jsonStats, mode="r", encoding="utf-8") as inFile: - jsonData = json.loads(inFile.read()) + jsonData = json.load(inFile) assert len(jsonData) == 3 @@ -331,7 +331,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp): jsonStats = os.path.join(nwFuncTemp, "sessionStats.json") with open(jsonStats, mode="r", encoding="utf-8") as inFile: - jsonData = json.loads(inFile.read()) + jsonData = json.load(inFile) assert len(jsonData) == 4 @@ -343,7 +343,7 @@ def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp): jsonStats = os.path.join(nwFuncTemp, "sessionStats.json") with open(jsonStats, mode="r", encoding="utf-8") as inFile: - jsonData = json.loads(inFile.read()) + jsonData = json.load(inFile) # Check against both 1 and 2 as this can be 2 if test was started just before midnight. # A failed test should in any case produce a 4 diff --git a/tests/test_index.py b/tests/test_index.py index a86fb017..9fabae5b 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -27,7 +27,6 @@ def testIndexBuildCheck(monkeypatch, nwLipsum, nwDummy, nwTempProj, nwRef): theProject.projTree.setSeed(42) assert theProject.openProject(nwLipsum) - theProject.mainConf.debugInfo = True monkeypatch.setattr("nw.core.index.time", lambda: 123.4) theIndex = NWIndex(theProject, nwDummy) @@ -49,7 +48,7 @@ def testIndexBuildCheck(monkeypatch, nwLipsum, nwDummy, nwTempProj, nwRef): raise Exception # Make the save fail - monkeypatch.setattr(json, "dumps", doPanic) + monkeypatch.setattr(json, "dump", doPanic) assert not theIndex.saveIndex() # Make the save pass @@ -83,7 +82,7 @@ def testIndexBuildCheck(monkeypatch, nwLipsum, nwDummy, nwTempProj, nwRef): assert not theIndex.textCounts # Make the load fail - monkeypatch.setattr(json, "loads", doPanic) + monkeypatch.setattr(json, "load", doPanic) assert not theIndex.loadIndex() # Make the load pass