Skip to content
This repository has been archived by the owner on Dec 11, 2021. It is now read-only.

Commit

Permalink
Add assert in tests to validate whether outputFile already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ferrier committed Mar 16, 2015
1 parent bce15a3 commit 7ff3cd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tests/BaseTestClasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def addHeaders(self, frm=DEFAULT_FROM, to=DEFAULT_TO, subject=DEFAULT_SUBJECT):

self.msg['Date'] = formatdate()

def invokeAsSubprocess(self, inputFile=False, outputDirectory=None, outputFile=None, extraParams=[], expectOutput=False):
def invokeAsSubprocess(self, inputFile=False, outputDirectory=None, outputFile=None, extraParams=[], expectOutput=False, okToExist=False):
bytesMessage = self.msg.as_bytes()

options = [Email2PDFTestCase.COMMAND]
Expand All @@ -130,6 +130,8 @@ def invokeAsSubprocess(self, inputFile=False, outputDirectory=None, outputFile=N

if outputFile:
options.extend(['-o', outputFile])
if not okToExist:
assert(not os.path.exists(outputFile))

options.extend(extraParams)

Expand Down
2 changes: 1 addition & 1 deletion tests/Subprocess/test_Subprocess_Basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_plaincontent_outputfileoverrides(self):
def test_plaincontent_fileexist(self):
self.setPlainContent("Hello!")
with tempfile.NamedTemporaryFile() as tmpfile:
(rc, output, error) = self.invokeAsSubprocess(outputFile=tmpfile.name)
(rc, output, error) = self.invokeAsSubprocess(outputFile=tmpfile.name, okToExist=True)
self.assertEqual(2, rc)
self.assertRegex(error, "file.*exist")

Expand Down

0 comments on commit 7ff3cd3

Please sign in to comment.