Blame avocado-61.0-skip-remote-test-if-plugin-unavailable.patch

c1a2b86
From 0cc70f1c8a41260640dfc7a660c11bcb1a163419 Mon Sep 17 00:00:00 2001
c1a2b86
From: Cleber Rosa <crosa@redhat.com>
c1a2b86
Date: Thu, 3 May 2018 21:05:43 +0200
c1a2b86
Subject: [PATCH] Replay with remote functional test: skip if remote plugin is
c1a2b86
 not available
c1a2b86
c1a2b86
When a plugin is not installed, its command line options are not
c1a2b86
registered with the optparse based code.  That is caught earlier than
c1a2b86
Avocado's own handling of incompatible options (in this case, the replay
c1a2b86
and the remote runner), and results in the errors such as:
c1a2b86
c1a2b86
  avocado run: error: unrecognized arguments: --remote-hostname
c1a2b86
c1a2b86
When building RPM packages for Python 3, the remote runner plugin is
c1a2b86
not available, and this test should be skipped.
c1a2b86
c1a2b86
Signed-off-by: Cleber Rosa <crosa@redhat.com>
c1a2b86
---
c1a2b86
 selftests/functional/test_replay_basic.py | 14 +++++++++++++-
c1a2b86
 1 file changed, 13 insertions(+), 1 deletion(-)
c1a2b86
c1a2b86
diff --git a/selftests/functional/test_replay_basic.py b/selftests/functional/test_replay_basic.py
c1a2b86
index 56f94d315..6eb944aa2 100644
c1a2b86
--- a/selftests/functional/test_replay_basic.py
c1a2b86
+++ b/selftests/functional/test_replay_basic.py
c1a2b86
@@ -1,9 +1,11 @@
c1a2b86
 import glob
c1a2b86
 import os
c1a2b86
-import tempfile
c1a2b86
 import shutil
c1a2b86
+import tempfile
c1a2b86
 import unittest
c1a2b86
 
c1a2b86
+import pkg_resources
c1a2b86
+
c1a2b86
 from avocado.core import exit_codes
c1a2b86
 from avocado.utils import process
c1a2b86
 
c1a2b86
@@ -14,6 +16,14 @@
c1a2b86
 AVOCADO = os.environ.get("UNITTEST_AVOCADO_CMD", "./scripts/avocado")
c1a2b86
 
c1a2b86
 
c1a2b86
+def remote_capable():
c1a2b86
+    try:
c1a2b86
+        pkg_resources.require('avocado-framework-plugin-runner-remote')
c1a2b86
+        return True
c1a2b86
+    except pkg_resources.DistributionNotFound:
c1a2b86
+        return False
c1a2b86
+
c1a2b86
+
c1a2b86
 class ReplayTests(unittest.TestCase):
c1a2b86
 
c1a2b86
     def setUp(self):
c1a2b86
@@ -148,6 +158,8 @@ def test_run_replay_statusfail(self):
c1a2b86
                b'INTERRUPT 0')
c1a2b86
         self.assertIn(msg, result.stdout)
c1a2b86
 
c1a2b86
+    @unittest.skipUnless(remote_capable(),
c1a2b86
+                         "Remote runner plugin is not available")
c1a2b86
     def test_run_replay_remotefail(self):
c1a2b86
         """
c1a2b86
         Runs a replay job using remote plugin (not supported).