changeset 28362:b7e192240c41 stable

tests: adjust for code move in Hypothesis 2.0.0 It appears that the Settings class was renamed to settings, and because of this, the settings module was renamed to configuration. https://github.com/DRMacIver/hypothesis/commit/a0e663b
author Yuya Nishihara <yuya@tcha.org>
date Tue, 26 Jan 2016 22:44:29 +0900
parents 8949d73b2e1f
children 97175d9bf7cf
files tests/hypothesishelpers.py
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/hypothesishelpers.py	Tue Mar 01 18:03:49 2016 -0600
+++ b/tests/hypothesishelpers.py	Tue Jan 26 22:44:29 2016 +0900
@@ -8,9 +8,16 @@
 import sys
 import traceback
 
-from hypothesis.settings import set_hypothesis_home_dir
+try:
+    # hypothesis 2.x
+    from hypothesis.configuration import set_hypothesis_home_dir
+    from hypothesis import settings
+except ImportError:
+    # hypothesis 1.x
+    from hypothesis.settings import set_hypothesis_home_dir
+    from hypothesis import Settings as settings
 import hypothesis.strategies as st
-from hypothesis import given, Settings
+from hypothesis import given
 
 # hypothesis store data regarding generate example and code
 set_hypothesis_home_dir(os.path.join(
@@ -26,7 +33,7 @@
         # Fixed in version 1.13 (released 2015 october 29th)
         f.__module__ = '__anon__'
         try:
-            given(*args, settings=Settings(max_examples=2000), **kwargs)(f)()
+            given(*args, settings=settings(max_examples=2000), **kwargs)(f)()
         except Exception:
             traceback.print_exc(file=sys.stdout)
             sys.exit(1)