Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #40858 > unrolled thread

Unit test cases for Object intraction using mox/unittest

Started byjitendra gupta <jitu.icfai@gmail.com>
First post2013-03-08 18:06 +0530
Last post2013-03-08 18:06 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Unit test cases for Object intraction using mox/unittest jitendra gupta <jitu.icfai@gmail.com> - 2013-03-08 18:06 +0530

#40858 — Unit test cases for Object intraction using mox/unittest

Fromjitendra gupta <jitu.icfai@gmail.com>
Date2013-03-08 18:06 +0530
SubjectUnit test cases for Object intraction using mox/unittest
Message-ID<mailman.3077.1362746207.2939.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web