Velocity Reviews

Velocity Reviews (
-   Python (
-   -   Unit test cases for Object intraction using mox/unittest (

jitendra gupta 03-08-2013 12:36 PM

Unit test cases for Object intraction using mox/unittest

I need to write the unit test cases for similary kind of sitution.

I need to write the unit test case for Foo.testCall. for both case true or
false. I am unalbe to do that.

kindly please help me on this. as function is not returning any thing. from
google i got mox is good for this case. but i did not found any solution
for this case

****************** ********************
from run import RunComp

def enter():
runC = RunComp("ComName", "~/pathToHome")
""" This is based on some database condition we are passing name true or
false """
foo = Foo(true)

if __name__ == "__main__":


Class Foo():

def __init__(self, found):

self.found = found

def testCall(self, SomeClassObject):
if self.found:
RunCompObject.call_run("codeRun -s " + self.found)

************** **************************

from subprocess import call

class RunComp(object):

def __init__(self, com, home):

self.comp = comp

self.home = home

def call_and_raise(*args, **kwargs):

if call(*args, **kwargs):

raise RuntimeError("LDF command failed!")

def call_run(self, command):

if self.comp:

command = " ".join((command,myldfrc))

call(command, cwd=self.home)


Thanks & Regards

All times are GMT. The time now is 02:50 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.