VPP-1498: test/framework.py: AttributeError 10/16010/2
authorPaul Vinciguerra <pvinci@vinciconsulting.com>
Sun, 18 Nov 2018 16:17:34 +0000 (08:17 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 19 Nov 2018 23:02:34 +0000 (23:02 +0000)
Traceback if .send_keep_alive is called before pipe is configured.

Traceback (most recent call last):
      File "/vpp/test/test_span.py", line 27, in setUpClass
        super(TestSpan, cls).setUpClass()
      File "/vpp/test/framework.py", line 411, in setUpClass
        cls.reporter.send_keep_alive(cls, 'setUpClass')
      File "/vpp/test/framework.py", line 172, in send_keep_alive
        if self.pipe is None:
      File "/vpp/test/framework.py", line 160, in pipe
        return self._pipe
    AttributeError: 'KeepAliveReporter' object has no attribute '_pipe'

Change-Id: I561d2748441702478a84fbb4580a4d2667d70ffd
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
test/framework.py

index 06876a1..4c536e0 100644 (file)
@@ -151,6 +151,7 @@ class KeepAliveReporter(object):
 
     def __init__(self):
         self.__dict__ = self._shared_state
+        self._pipe = None
 
     @property
     def pipe(self):
@@ -158,7 +159,7 @@ class KeepAliveReporter(object):
 
     @pipe.setter
     def pipe(self, pipe):
-        if hasattr(self, '_pipe'):
+        if self._pipe is not None:
             raise Exception("Internal error - pipe should only be set once.")
         self._pipe = pipe