Skip to content

Commit

Permalink
StringDownload step: more informative error message
Browse files Browse the repository at this point in the history
Changed error message when buildbot.steps.transfer.StringDownload
is instantiated with invalid 'mode' argument. Include more context
on which 'mode' is invalid.
  • Loading branch information
Elmir Jagudin committed Sep 3, 2013
1 parent 2ffeba0 commit edc1ef1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion master/buildbot/steps/transfer.py
Expand Up @@ -481,7 +481,8 @@ def __init__(self, s, slavedest,
self.blocksize = blocksize
if not isinstance(mode, (int, type(None))):
config.error(
'mode must be an integer or None')
"StringDownload step's mode must be an integer or None,"
" got '%s'" % mode)
self.mode = mode

def start(self):
Expand Down
10 changes: 10 additions & 0 deletions master/buildbot/test/unit/test_steps_transfer.py
Expand Up @@ -183,6 +183,16 @@ def upload_behavior(command):
return d

class TestStringDownload(unittest.TestCase):

# check that ConfigErrors is raised on invalid 'mode' argument
def testModeConfError(self):
self.assertRaisesRegexp(
config.ConfigErrors,
"StringDownload step's mode must be an integer or None,"
" got 'not-a-number'",
transfer.StringDownload,
"string", "file", mode="not-a-number")

def testBasic(self):
s = transfer.StringDownload("Hello World", "hello.txt")
s.build = Mock()
Expand Down

0 comments on commit edc1ef1

Please sign in to comment.