Fam Zheng <[email protected]> writes: > On Wed, 09/14 10:51, Dmitry Monakhov wrote: >> class AvocadoRelease(Test): >> >> def setUp(self): >> self.log.info("do setUp: install requirements, fetch source") >> >> def test_a(self): >> self.log.info("do test_a: inspekt lint") >> >> def test_b(self): >> self.log.info("do test_b: inspekt style") >> >> def tearDown(self): >> self.log.info("do tearDown") >> My assumptions was that test sequence will be: >> do setUp >> do test_a: inspekt lint >> do test_b: inspekt style >> do tearDown >> But it is appeared that each testcase is wrapped with setUp()/teerDown() >> #### >> START 1-simpletest.py:AvocadoReliase.test_a >> do setUp: install requirements, fetch source >> do test_a: inspekt lint >> do tearDown >> PASS 1-simpletest.py:AvocadoReliase.test_a >> START 2-simpletest.py:AvocadoReliase.test_b >> do setUp: install requirements, fetch source >> do test_b: inspekt style >> do tearDown >> PASS 2-simpletest.py:AvocadoReliase.test_b >> #### >> This is not obvious. And makes it hard to divide test to >> fine-grained testcases because setUp/teerDown() for each test may >> be too intrusive. What is convenient way implement this scenario? > > This is the interface of Python's unittest.TestCase (base class of avocado > Test > class). It also offers setUpClass and tearDownClass that do what you want > above. > > See also `pydoc unittest.TestCase`. Indeed. But avocado.Test() does not call setUpClass/tearDownClass. it call only setUp/tearDown. AIFAU this is done that way because each test is executed in supbrocess. See runner.py:TestRunner.run_test: proc = multiprocessing.Process(target=self._run_test, args=(test_factory, queue,))
IMHO this is a bit unusual, but cool because allow to support concurrent test execution in future. IMHO It would be nice document it somewhere, for example add compat mode where: setUpClass/tearDownClass are called similar to setUp/tearDown, but dump warning in a log. BTW: Are any chance to implement parallel executions in near future ? https://trello.com/c/xNeR2slj/255-support-running-tests-in-parallel > Fam
signature.asc
Description: PGP signature
