0

I have a method that does not return anything , but it makes a call to another method that returns a value like

def apply():
    #set some defaults
    try:
        script = _getScript()
    except Exception, ex:
        raise Exception(ex)

    node =  [xyz for xyz in myLst] # myLst is a global list object hat has values based on different scnarios

so how do i test above method using unittest or mox ? any help would be extremely appreciated..

2
Contributors
3
Replies
16
Views
4 Years
Discussion Span
Last Post by krystosan
0

Presumably _getScript() returns an object if all went well, or a none object otherwise. You could test if your script variable is none, provided that your _getScript() function supports returning none values.
Was this your question, or did I interpret it wrong?

0

yes _getScripts returns None resulting an error , since by default it is supposed to return the path of the script...

but then again how would u test using assert ?

0

also, if a method being tested doesn't returns anything can we do this ?

def testUsingMox(self):
    moxObject = mox.Mox()

    moxObject.StubOutWithMock(MyClass,"apply").AndReturn(None)
    moxObject.ReplayAll()
    self.assertRaises(Exception, moxObject, _test_data_)
    moxObject.verifyAll()

Edited by krystosan

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.