URL: https://github.com/freeipa/freeipa/pull/369
Author: tiran
 Title: #369: Catch ValueError raised by pytest.config.getoption()
Action: opened

PR body:
"""
pytest.config.getoption() can raise ValueError for unknown options, too.

I ran into the issue while I was working on PR #366 
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/369/head:pr369
git checkout pr369
From ab23ce2d5c1f5e03d75d99efdf54f48e38d9252f Mon Sep 17 00:00:00 2001
From: Christian Heimes <chei...@redhat.com>
Date: Tue, 3 Jan 2017 18:08:05 +0100
Subject: [PATCH] Catch ValueError raised by pytest.config.getoption()

pytest.config.getoption() can raise ValueError for unknown options, too.
---
 ipatests/test_util.py | 6 ++++--
 ipatests/util.py      | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/ipatests/test_util.py b/ipatests/test_util.py
index 0fbd536..f4e7773 100644
--- a/ipatests/test_util.py
+++ b/ipatests/test_util.py
@@ -140,8 +140,10 @@ def test_eq(self):
 
 def test_assert_deepequal():
     f = util.assert_deepequal
-    # pylint: disable=no-member
-    pretty = pytest.config.getoption("pretty_print")
+    try:  # pylint: disable=no-member
+        pretty = pytest.config.getoption("pretty_print")
+    except (AttributeError, ValueError):
+        pretty = False
 
     # LEN and KEYS formats use special function to pretty print structures
     # depending on a pytest environment settings
diff --git a/ipatests/util.py b/ipatests/util.py
index 7b5e317..9320383 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -337,7 +337,7 @@ def assert_deepequal(expected, got, doc='', stack=tuple()):
     """
     try:
         pretty_print = pytest.config.getoption("pretty_print")  # pylint: disable=no-member
-    except AttributeError:
+    except (AttributeError, ValueError):
         pretty_print = False
 
     if pretty_print:
-- 
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