On Tue, 2018-11-06 at 17:20 +0100, Lukáš Doktor wrote: > > The ":avocado: recursive" is used for test discovery. The main > difference is that for test discovery we don't load the modules. > Instead we use static analysis (using `ast`) to detect whether > certain file is python and contains something inherited from > `avocado.Test`.
Ahhh. So that might be related to the issue I'm having: util/apricot/apricot/__init__.py: ``` __all__ = ['ApricotTest'] from apricot.test import ApricotTest ``` util/apricot/apricot/test.py: ```from avocado import Test class ApricotTest(Test): def setUp(self): self.log.info("setUp() executed from Apricot") def some_useful_method(self): return True ``` avocado detects that: util/apricot/test_example.py ``` #!/usr/bin/python ''' bla bla bla ''' import sys sys.path.append('./') from apricot import ApricotTest class MyTest(ApricotTest): """ :avocado: recursive """ def setUp(self): super(MyTest, self).setUp() self.log.info("setUp() executed from test_example.py") def test(self): """ :avocado: tags=all """ print "test()" self.assertTrue(self.some_useful_method()) ``` is an instrumented avocado test and produces: ``` 2018-11-06 12:16:34,560 test L0240 INFO | START 1-util/apricot/test_example.py:MyTest.test 2018-11-06 12:16:34,695 test L0005 INFO | setUp() executed from Apricot 2018-11-06 12:16:34,695 test_example L0018 INFO | setUp() executed from test_example.py 2018-11-06 12:16:34,695 output L0655 DEBUG| test() ``` However when much the same file is in a different location outside of the apricot/ dir: ./test_example.py ``` #!/usr/bin/python ''' bla bla bla ''' import sys sys.path.append('./util/apricot') from apricot import ApricotTest class MyTest(ApricotTest): """ :avocado: recursive """ def setUp(self): super(MyTest, self).setUp() self.log.info("setUp() executed from test_example.py") def test(self): """ :avocado: tags=all """ print "test()" self.assertTrue(self.some_useful_method()) ``` is not detected as an instrumented test and it runs it as a simple test: ``` 2018-11-06 12:22:51,764 test L0240 INFO | START 1-test_example.py 2018-11-06 12:22:51,898 process L0389 INFO | Running '/home/brian/test_example.py' 2018-11-06 12:22:52,275 process L0499 INFO | Command '/home/brian/test_example.py' finished with 0 after 0.372878074646s 2018-11-06 12:22:52,276 test L0858 INFO | Exit status: 0 ``` Why is the latter not being detected as an instrumented avocado test? Cheers, b.
signature.asc
Description: This is a digitally signed message part