Unit test cases for Object intraction using mox/unittest

Discussion in 'Python' started by jitendra gupta, Mar 8, 2013.

  1. Hi

    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

    ****************** Enter.py ********************
    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)
    foo.testCall(runC)

    if __name__ == "__main__":
    enter()

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

    ***************** foo.py************************
    Class Foo():

    def __init__(self, found):

    self.found = found


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

    ************** run.py **************************

    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
    Jitu
    jitendra gupta, Mar 8, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott David Daniels

    Failing unittest Test cases

    Scott David Daniels, Jan 9, 2006, in forum: Python
    Replies:
    18
    Views:
    500
    Scott David Daniels
    Jan 13, 2006
  2. Terry

    ignored test cases in unittest

    Terry, Aug 16, 2009, in forum: Python
    Replies:
    3
    Views:
    326
    David House
    Aug 17, 2009
  3. sripathi
    Replies:
    0
    Views:
    853
    sripathi
    Dec 31, 2009
  4. Replies:
    9
    Views:
    118
    Eric Hodel
    Nov 15, 2005
  5. David Mitchell
    Replies:
    10
    Views:
    244
Loading...

Share This Page