Consider we have within same root folder, we have
conftest.py , setup.py ,teardown.py and testsomething.py
----------------------
import pytest
import setup // from setup import Test_Setup
import teardown // from teardown import Test_Teardown
@pytest.fixture(scope='module', autouse=True)
def t(request):
t = getT()
request.addfinalizer(t.cleanup)
return t
@pytest.fixture(scope='module', autouse=True)
def setup(t):
// Here I want to execute class "Test_Setup" as pytest class
@pytest.fixture(scope='module', autouse=True)
def teardown(t):
yield
// Here I want to execute class "Test_TearDown"as pytest class
----------------------
class Test_Setup:
def test_creation(self, t):
//test codes
def test_setp1(self, t):
//test codes
def test_step2(self, t):
//test codes
----------------------
class Test_Teardown:
def test_Reset(self,t):
// some cleanup code
----------------------
class Test_Something:
def test_1(self,t):
// some cleanup code
def test_2(self,t):
// some cleanup code
we know before running test class and its function in testsomething.py pytest will run fixture setup and finally teardown defined in conftest.py
Problem is within these
setup and
teardown fixtures I want to run those pytest test classes defined in
setup.py and
teardown.py respectively.
Please Note : Those Test class execution should be executed as pytest Test class not like general class instantiation and call member function scenario and also we cannot touch
testsometing.py definition, which means it should not related/imported with
setup.py or
teardown.py.
If you can provide a solution for python 2.7 that would be really helpful.
Thank you for the considering.
What I have tried:
I tried instantiation of Test_Setup and Test_Teardown, since this not my intetion, I wanted to run this Test classes as pytest class.