[TIP] Hint on TestClass
thijs at buckazoids.com
Wed Jul 11 07:26:05 PDT 2012
I am currently running multiple tests (using py.test) on a series of
objects which are relatively expensive to retrieve. My thinking was to
group the tests on the same object into one class, potentially using the
setup/teardown at class level to retrieve the object under test.
As mentioned there is a series of these objects, hence I would like to
parametrize the class holding all the individual tests. Via the search
on the py.test I actually landed on a page which seems to describe
exactly what I am after:
http://pytest.org/dev/example/resources_attic.html, although I could not
complete figure out the given example with self.db.
This is about what I hoping to archive:
Use parametrize to run the test in TestSession for a list of
def __init__(self, session_id):
self.session = expensive_database_query(session_id)
assert session.id > 0
assert session.date >= date(2012, 1, 1)
assert periods in range(1, 26)
Is the resource_attic link indeed describing what I am after?
More information about the testing-in-python