Make project xml class and tests use pathlib instead of os

This commit is contained in:
Veronica Berglyd Olsen
2022-11-03 22:17:25 +01:00
parent dfd9e15951
commit bd81ea0880
3 changed files with 77 additions and 48 deletions
+31
View File
@@ -24,6 +24,8 @@ import sys
import pytest
import shutil
from pathlib import Path
from mock import MockGuiMain
from tools import cleanProject
@@ -62,6 +64,35 @@ def tmpDir():
return theDir
@pytest.fixture(scope="session")
def tstPaths(tmpDir):
"""Returns an object that can provide the various paths needed for
running tests.
"""
class _Store:
testDir = Path(__file__).parent
filesDir = testDir / "files"
refDir = testDir / "reference"
outDir = testDir / tmpDir / "results"
store = _Store()
store.outDir.mkdir(exist_ok=True)
return store
@pytest.fixture(scope="function")
def fncPath(tmpDir):
"""A temporary folder for a single test function.
"""
fncPath = Path(tmpDir) / "f_temp"
if fncPath.is_dir():
shutil.rmtree(fncPath)
if not fncPath.is_dir():
fncPath.mkdir()
return fncPath
@pytest.fixture(scope="session")
def refDir():
"""The folder where all the reference files are stored for verifying