Skip to content

Commit

Permalink
add test for issue DataBiosphere#3004
Browse files Browse the repository at this point in the history
Test to reproduce `TypeError: can only concatenate str (not "bytes") to str` error.
  • Loading branch information
johnbradley committed Mar 10, 2020
1 parent 98a48ee commit b25601e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/toil/test/utils/utilsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from toil.common import Toil, Config
from toil.provisioners import clusterFactory
from toil.version import python
from mock import patch, mock_open

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -387,6 +388,22 @@ def testGetStatusSuccessfulCWLWF(self):
wf.wait()
self.check_status('COMPLETED', status_fn=ToilStatus.getStatus)

@needs_cwl
@needs_docker
@patch('toil.utils.toilStatus.Toil')
@patch('builtins.print')
def testPrintJobLog(self, mock_print, mock_toil):

# mock getLogFileHandle so the fake error log contents will be returned
open_log_file = mock_open(read_data=b'ERROR file not found')
mock_toil.resumeJobStore.return_value.load.return_value.getLogFileHandle = open_log_file

status = ToilStatus(self.toilDir, specifiedJobs=[Job()])
status.printJobLog()
mock_print.assert_called_with("LOG_FILE_OF_JOB:{} LOG: =======>\nERROR file not found<=========".format(
mock_toil.resumeJobStore.return_value.load.return_value
))


def printUnicodeCharacter():
# We want to get a unicode character to stdout but we can't print it directly because of
Expand Down

0 comments on commit b25601e

Please sign in to comment.