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..

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?

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 ?

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()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.