Pry - AutoTree

AutoTree is a TestContainer class that provides a short-cut for building trees of related tests. Methods of the form test_* are automatically turned into Test objects, and added to the container, with names equal to the method names.

The following code is functionally equivalent to the example given in the previous section:

import libpry

class MyContainer(libpry.AutoTree):
    def setUpAll(self):
        print "setUpAll"

    def tearDownAll(self):
        print "tearDownAll"

    def setUp(self):
        print "\tsetUp"

    def tearDown(self):
        print "\ttearDown"

    def test_one(self):
        print "\t\t%s..."%self.name

    def test_two(self):
        print "\t\t%s..."%self.name

tests = [
    MyContainer()
]
(examples/test_autotree.py)

Test hierarchy:

> pry -l test_autotree.py
./test_autotree
     MyContainer
         test_one
         test_two
Total: 2

Copyright Nullcube 2008