70 lines
2.2 KiB
Diff
70 lines
2.2 KiB
Diff
From 5276d4e2b23dcefeb0cba419926c9006859d9011 Mon Sep 17 00:00:00 2001
|
|
From: Lumir Balhar <lbalhar@redhat.com>
|
|
Date: Mon, 2 Dec 2019 13:55:11 +0100
|
|
Subject: [PATCH] Disable test with hypothesis when it's not available
|
|
|
|
---
|
|
testing/python/metafunc.py | 31 +++++++++++++++++++------------
|
|
1 file changed, 19 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py
|
|
index d907878..c79d780 100644
|
|
--- a/testing/python/metafunc.py
|
|
+++ b/testing/python/metafunc.py
|
|
@@ -4,9 +4,8 @@ import sys
|
|
import textwrap
|
|
|
|
import attr
|
|
-import hypothesis
|
|
+
|
|
import six
|
|
-from hypothesis import strategies
|
|
|
|
import pytest
|
|
from _pytest import fixtures
|
|
@@ -15,6 +14,13 @@ from _pytest.warnings import SHOW_PYTEST_WARNINGS_ARG
|
|
|
|
PY3 = sys.version_info >= (3, 0)
|
|
|
|
+try:
|
|
+ from hypothesis import strategies
|
|
+ import hypothesis
|
|
+except ImportError:
|
|
+ with_hypothesis = False
|
|
+else:
|
|
+ with_hypothesis = True
|
|
|
|
class TestMetafunc(object):
|
|
def Metafunc(self, func, config=None):
|
|
@@ -196,16 +202,17 @@ class TestMetafunc(object):
|
|
assert metafunc._calls[2].id == "x1-a"
|
|
assert metafunc._calls[3].id == "x1-b"
|
|
|
|
- @hypothesis.given(strategies.text() | strategies.binary())
|
|
- @hypothesis.settings(
|
|
- deadline=400.0
|
|
- ) # very close to std deadline and CI boxes are not reliable in CPU power
|
|
- def test_idval_hypothesis(self, value):
|
|
- from _pytest.python import _idval
|
|
-
|
|
- escaped = _idval(value, "a", 6, None, item=None, config=None)
|
|
- assert isinstance(escaped, six.text_type)
|
|
- escaped.encode("ascii")
|
|
+ if with_hypothesis:
|
|
+ @hypothesis.given(strategies.text() | strategies.binary())
|
|
+ @hypothesis.settings(
|
|
+ deadline=400.0
|
|
+ ) # very close to std deadline and CI boxes are not reliable in CPU power
|
|
+ def test_idval_hypothesis(self, value):
|
|
+ from _pytest.python import _idval
|
|
+
|
|
+ escaped = _idval(value, "a", 6, None, item=None, config=None)
|
|
+ assert isinstance(escaped, six.text_type)
|
|
+ escaped.encode("ascii")
|
|
|
|
def test_unicode_idval(self):
|
|
"""This tests that Unicode strings outside the ASCII character set get
|
|
--
|
|
2.23.0
|
|
|