URL: https://github.com/freeipa/freeipa/pull/442
Author: tiran
 Title: #442: Add option to run tests in-tree and out-of-tree mode
Action: opened

PR body:
"""
By default ipa-run-tests and pytest auto-detect the presence of
../ipasetup.py.in and run tests in-tree mode when the file exists. The
option can be overriden with ipa-run-tests --in-tree=true/false.

Signed-off-by: Christian Heimes <chei...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/442/head:pr442
git checkout pr442
From a6df4c03ddcde95d57879238be3a0e239fe19cd0 Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Wed, 8 Feb 2017 13:29:38 +0100
Subject: [PATCH] Add option to run tests in-tree and out-of-tree mode

By default ipa-run-tests and pytest auto-detect the presence of
../ipasetup.py.in and run tests in-tree mode when the file exists. The
option can be overriden with ipa-run-tests --in-tree=true/false.

Signed-off-by: Christian Heimes <chei...@redhat.com>
---
 ipatests/conftest.py | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/ipatests/conftest.py b/ipatests/conftest.py
index 6d8ba60..70947f7 100644
--- a/ipatests/conftest.py
+++ b/ipatests/conftest.py
@@ -11,6 +11,9 @@
     ipaserver = None
 
 
+HERE = os.path.dirname(os.path.abspath(__file__))
+
+
 pytest_plugins = [
     'ipatests.pytest_plugins.additional_config',
     'ipatests.pytest_plugins.beakerlib',
@@ -71,9 +74,30 @@ def pytest_configure(config):
     config.option.doctestmodules = True
 
 
+def pytest_addoption(parser):
+    def truefalse(arg):
+        if arg.lower() == 'true':
+            return True
+        if arg.lower() == 'false':
+            return False
+        return arg  # triggers an error later
+
+    in_tree = os.path.isfile(os.path.join(HERE, os.pardir, 'ipasetup.py.in'))
+    group = parser.getgroup("IPA integration tests")
+    group.addoption(
+        '--in-tree',
+        dest="ipa_in_tree",
+        type=truefalse,
+        choices=(True, False),
+        default=in_tree,
+        help="Run IPA tests in-tree (default: auto-detect ../ipasetup.py.in)"
+    )
+
+
 def pytest_cmdline_main(config):
     api.bootstrap(
-        context=u'cli', in_server=False, in_tree=True, fallback=False
+        context=u'cli', in_server=False, in_tree=config.option.ipa_in_tree,
+        fallback=False
     )
     for klass in cli_plugins:
         api.add_plugin(klass)
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to