howeverwe are not forbidden from writing class-based tests classes can be useful for grouping related tests together or for tests that need to access related attributes or methods on the class this example shows an extended class with passing and failing testwe'll see that the error output is more comprehensive than that provided by the unittest moduleclass testnumbersdef test_int_float(self)assert = def test_int_str(self)assert =" notice that the class doesn' have to extend any special objects to be picked up as test (although py test will run standard unittest testcases just fineif we run py test the output looks like this=============test session starts =============pythonplatform linux -python -pytesttest object class_pytest py class_pytest py ==================failures===================testnumbers test_int_str self def test_int_str(self)assert =" assert =' class_pytest py: assertionerror ===== failed passed in seconds ======