मैं निम्न निर्देशिका लेआउट:क्या यह नियंत्रित करने का कोई तरीका है कि pytest-xdist समानांतर में परीक्षण कैसे चलाता है?
runner.py
lib/
tests/
testsuite1/
testsuite1.py
testsuite2/
testsuite2.py
testsuite3/
testsuite3.py
testsuite4/
testsuite4.py
testsuite * .py मॉड्यूल के प्रारूप इस प्रकार है:
import pytest class testsomething: def setup_class(self): ''' do some setup ''' # Do some setup stuff here def teardown_class(self): '''' do some teardown''' # Do some teardown stuff here def test1(self): # Do some test1 related stuff def test2(self): # Do some test2 related stuff .... .... .... def test40(self): # Do some test40 related stuff if __name__=='__main()__' pytest.main(args=[os.path.abspath(__file__)])समस्या मेरे पास है
है कि मैं 'testsuites' निष्पादित करने के लिए चाहते हैं समानांतर में यानी मैं testuite1, testuite2, testuite3 और testuite4 समानांतर में निष्पादन शुरू करने के लिए चाहता हूं लेकिन परीक्षणों के भीतर व्यक्तिगत परीक्षणों को क्रमशः निष्पादित करने की आवश्यकता है।
जब मैं py.test से 'xdist' प्लगइन का उपयोग करता हूं और 'py.test -n 4' का उपयोग करके परीक्षण बंद कर देता हूं, py.test सभी परीक्षणों को इकट्ठा कर रहा है और यादृच्छिक रूप से 4 श्रमिकों के बीच परीक्षणों को संतुलित करता है। इससे 'testuitex.py' मॉड्यूल (जो मेरे उद्देश्य को हराता है) में प्रत्येक परीक्षण के हर बार निष्पादित करने के लिए 'setup_class' विधि की ओर जाता है। मैं चाहता हूं कि setup_class प्रति वर्ग केवल एक बार निष्पादित किया जाए और परीक्षण के बाद क्रमशः निष्पादित किया जाए)।
अनिवार्य रूप से जो मैं चाहता निष्पादन की तरह लग रहे करने के लिए है:
worker1: executes all tests in testsuite1.py serially worker2: executes all tests in testsuite2.py serially worker3: executes all tests in testsuite3.py serially worker4: executes all tests in testsuite4.py serially
जबकि worker1, worker2, worker3 and worker4
सब समानांतर में क्रियान्वित कर रहे हैं।
क्या 'pytest-xidst' ढांचे में इसे हासिल करने का कोई तरीका है?
def test_execute_func(testsuite_path): subprocess.process('py.test %s' % testsuite_path) if __name__=='__main__': #Gather all the testsuite names for each testsuite: multiprocessing.Process(test_execute_func,(testsuite_path,))
इस पोस्ट को देखने और सोच किसी के लिए किसी भी मुद्दे खोल दिया गया है अगर, मुद्दे हैं: https://github.com/pytest-dev/pytest/issues/175 और https: // github.com/pytest-dev/pytest/issues/738 –
और यह एक: https://github.com/pytest-dev/pytest-xdist/issues/7 –