Добавил тесты на возвращаемые значения shell command

This commit is contained in:
rzaitov 2013-11-14 12:59:16 +04:00
parent a27b3ff8b7
commit aa0b3394ea
2 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1 @@
__author__ = 'rzaitov'

View File

@ -0,0 +1,24 @@
import unittest
from commands.ShellCommandBase import ShellCommandBase
class MyShellCommand(ShellCommandBase):
def __init__(self, execWithError=False):
ShellCommandBase.__init__(self)
self.execWithError = execWithError
def execute(self):
cmdText = 'exit 1' if self.execWithError else 'exit 0'
self.executeShell(cmdText)
class TestShellCommand(unittest.TestCase):
def test_noError(self):
cmd = MyShellCommand(execWithError=False)
cmd.execute()
def test_withError(self):
cmd = MyShellCommand(execWithError=True)
with self.assertRaises(Exception):
cmd.execute()