Fix variable formatting for DocX and ODT
This commit is contained in:
@@ -321,7 +321,7 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreDocBuild_DocX(monkeypatch, mockGUI, prjLipsum, fncPath):
|
||||
def testCoreDocBuild_DocX(mockGUI, prjLipsum, fncPath):
|
||||
"""Test building a Word manuscript."""
|
||||
project = NWProject()
|
||||
project.openProject(prjLipsum)
|
||||
@@ -352,22 +352,41 @@ def testCoreDocBuild_DocX(monkeypatch, mockGUI, prjLipsum, fncPath):
|
||||
assert docFile.is_file()
|
||||
assert zipfile.is_zipfile(docFile)
|
||||
|
||||
# Check Error Handling
|
||||
# ====================
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("builtins.open", causeOSError)
|
||||
@pytest.mark.core
|
||||
def testCoreDocBuild_PDF(mockGUI, prjLipsum, fncPath):
|
||||
"""Test building a PDF manuscript."""
|
||||
project = NWProject()
|
||||
project.openProject(prjLipsum)
|
||||
|
||||
docFile = fncPath / "Lorem Ipsum Err.fodt"
|
||||
for _ in docBuild.iterBuildDocument(docFile, nwBuildFmt.FODT):
|
||||
pass
|
||||
build = BuildSettings()
|
||||
build.unpack(BUILD_CONF)
|
||||
|
||||
assert docBuild.error == "OSError: Mock OSError"
|
||||
assert not docFile.is_file()
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
|
||||
# Check Build
|
||||
# ===========
|
||||
|
||||
docFile = fncPath / "Lorem Ipsum.pdf"
|
||||
|
||||
count = 0
|
||||
error = []
|
||||
for _, success in docBuild.iterBuildDocument(docFile, nwBuildFmt.PDF):
|
||||
count += 1 if success else 0
|
||||
if docBuild.error:
|
||||
error.append(docBuild.error)
|
||||
|
||||
assert count == 19
|
||||
assert error == []
|
||||
|
||||
assert docFile.is_file()
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
def testCoreDocBuild_NWD(mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
"""Test building a NWD manuscript."""
|
||||
project = NWProject()
|
||||
project.openProject(prjLipsum)
|
||||
@@ -420,19 +439,6 @@ def testCoreDocBuild_NWD(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
copyfile(docFile, tstFile)
|
||||
assert cmpFiles(tstFile, cmpFile, ignoreLines=[5, 6])
|
||||
|
||||
# Check Error Handling
|
||||
# ====================
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("builtins.open", causeOSError)
|
||||
|
||||
docFile = fncPath / "Lorem Ipsum Err.md"
|
||||
for _ in docBuild.iterBuildDocument(docFile, nwBuildFmt.NWD):
|
||||
pass
|
||||
|
||||
assert docBuild.error == "OSError: Mock OSError"
|
||||
assert not docFile.is_file()
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreDocBuild_Custom(mockGUI, fncPath: Path):
|
||||
|
||||
Reference in New Issue
Block a user