[Avocado-devel] Test assumptions question.

Fam Zheng famz at redhat.com
Wed Sep 14 08:00:54 UTC 2016


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`.

Fam




More information about the Avocado-devel mailing list