Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Connecting multiple test cases in a sort of pipe

Reply
Thread Tools

Connecting multiple test cases in a sort of pipe

 
 
Raghuram Devarakonda
Guest
Posts: n/a
 
      07-30-2009

Hi,

I have three functions - create(), list(), and delete(). create()
creates a new name in the file system hierarchy while list() displays
all such created names and delete() removes them. I would like to
write test cases for each of these functions, say, test_create() ,
test_list(), and test_delete() using the unittest module. It easily
follows that test_list() and test_delete() will need to know the exact
name that was created in test_create() in order to properly validate
list() and delete(). One option is for test_create() to always use a
hard coded name but unfortunately this is not feasible.

Another way would be for test_create() to pass the new name down to
the next test case test_list() which would do the same and pass the
name down to test_delete(). In other words, the requirement is to
connect all three test cases in a kind of pipe. This facility is
obviously not currently present in the unittest module and nor does it
seem to be available in other frameworks (such as py.test and nose, I
only skimmed the feature list).

I am thinking of implementing this feature on top of unittest.TestCase
and would like to know what others think of the idea. Is there a
framework that has similar feature? Or perhaps, given my requirement
as stated above, is there some alternate way of implementing it? I
greatly appreciate any feed back.

Thanks,
Raghu


 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      07-30-2009
Raghuram Devarakonda schrieb:
> Hi,
>
> I have three functions - create(), list(), and delete(). create()
> creates a new name in the file system hierarchy while list() displays
> all such created names and delete() removes them. I would like to
> write test cases for each of these functions, say, test_create() ,
> test_list(), and test_delete() using the unittest module. It easily
> follows that test_list() and test_delete() will need to know the exact
> name that was created in test_create() in order to properly validate
> list() and delete(). One option is for test_create() to always use a
> hard coded name but unfortunately this is not feasible.
>
> Another way would be for test_create() to pass the new name down to
> the next test case test_list() which would do the same and pass the
> name down to test_delete(). In other words, the requirement is to
> connect all three test cases in a kind of pipe. This facility is
> obviously not currently present in the unittest module and nor does it
> seem to be available in other frameworks (such as py.test and nose, I
> only skimmed the feature list).
>
> I am thinking of implementing this feature on top of unittest.TestCase
> and would like to know what others think of the idea. Is there a
> framework that has similar feature? Or perhaps, given my requirement
> as stated above, is there some alternate way of implementing it? I
> greatly appreciate any feed back.


Write a TestCase-subclass that simply works like this:


class FileTests(TestCase):


def test_create(self):
self.created_file = create()
assert something


def test_list(self):
self.test_create()
delete(self.created_file)


Passing state around is one of the reasons objects have been invented
And nobody ever said that you can't invoke a test-method from somewhere
else.

Diez
 
Reply With Quote
 
 
 
 
Raghuram Devarakonda
Guest
Posts: n/a
 
      07-30-2009
On Jul 30, 2:43 am, "Diez B. Roggisch" <(E-Mail Removed)> wrote:
> Write a TestCase-subclass that simply works like this:
>
> class FileTests(TestCase):
>
> def test_create(self):
> self.created_file = create()
> assert something
>
> def test_list(self):
> self.test_create()
> delete(self.created_file)
>
> Passing state around is one of the reasons objects have been invented
> And nobody ever said that you can't invoke a test-method from somewhere
> else.


Just to be clear, are you suggesting that these tests be run by a
custom runnner rather than by the default runner from unittest?

Thanks,
Raghu
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SetUp functions for multiple test cases Georg Schmid Python 4 01-20-2009 06:55 PM
Is it possible to dynamically extend Test::Unit test cases? David Mitchell Ruby 10 07-16-2008 07:52 PM
Home server cases and external firewire cases thingy@nowhere.commy NZ Computing 5 03-14-2006 07:56 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM
test test test test test test test Computer Support 2 07-02-2003 06:02 PM



Advertisments