Blob Blame History Raw
From 0cc70f1c8a41260640dfc7a660c11bcb1a163419 Mon Sep 17 00:00:00 2001
From: Cleber Rosa <crosa@redhat.com>
Date: Thu, 3 May 2018 21:05:43 +0200
Subject: [PATCH] Replay with remote functional test: skip if remote plugin is
 not available

When a plugin is not installed, its command line options are not
registered with the optparse based code.  That is caught earlier than
Avocado's own handling of incompatible options (in this case, the replay
and the remote runner), and results in the errors such as:

  avocado run: error: unrecognized arguments: --remote-hostname

When building RPM packages for Python 3, the remote runner plugin is
not available, and this test should be skipped.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
 selftests/functional/test_replay_basic.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/selftests/functional/test_replay_basic.py b/selftests/functional/test_replay_basic.py
index 56f94d315..6eb944aa2 100644
--- a/selftests/functional/test_replay_basic.py
+++ b/selftests/functional/test_replay_basic.py
@@ -1,9 +1,11 @@
 import glob
 import os
-import tempfile
 import shutil
+import tempfile
 import unittest
 
+import pkg_resources
+
 from avocado.core import exit_codes
 from avocado.utils import process
 
@@ -14,6 +16,14 @@
 AVOCADO = os.environ.get("UNITTEST_AVOCADO_CMD", "./scripts/avocado")
 
 
+def remote_capable():
+    try:
+        pkg_resources.require('avocado-framework-plugin-runner-remote')
+        return True
+    except pkg_resources.DistributionNotFound:
+        return False
+
+
 class ReplayTests(unittest.TestCase):
 
     def setUp(self):
@@ -148,6 +158,8 @@ def test_run_replay_statusfail(self):
                b'INTERRUPT 0')
         self.assertIn(msg, result.stdout)
 
+    @unittest.skipUnless(remote_capable(),
+                         "Remote runner plugin is not available")
     def test_run_replay_remotefail(self):
         """
         Runs a replay job using remote plugin (not supported).