Connecting multiple test cases in a sort of pipe

Raghuram Devarakonda draghuram at gmail.com
Wed Jul 29 23:00:57 EDT 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





More information about the Python-list mailing list