I am trying to create a Base class with different settings that I need for my tests. I want all my tests to be inherited from this Base class. As a runner, I use py.test .
But when I try to do this, py.test does not collect these tests inherited from the Base class, and as a result, it does not run them. Did not find useful information in the documentation.
Perhaps someone has encountered such problems before? Any ideas?
Thanks.
PS When tests are inherited from an object , everything works fine. Py.test see them and run correctly.
Code example:
My base class:
class BaseClass(object): """BaseClass""" def __init__(self): super(BaseClass, self).__init__() self.bla = 'bla'
My testing class:
import pytest from base_class import BaseClass class TestSmth(BaseClass): def test_test(self): test_instatnce = TestSmth() print test_instatnce.bla if __name__ == '__main__': pytest.main([__file__, '-v'])
Conclusion:
============================= test session starts ============================== platform darwin -- Python 2.7.2 -- pytest-2.3.3 -- /usr/bin/python collecting ... collected 0 items =============================== in 0.01 seconds =============================== [Finished in 0.4s]
source share