[Python-modules-commits] [python-hypothesis] 01/03: Import python-hypothesis_3.0.2.orig.tar.gz

Tristan Seligmann mithrandi at moszumanska.debian.org
Thu Feb 18 20:27:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

mithrandi pushed a commit to branch master
in repository python-hypothesis.

commit e02565e779b906462139aacf2b5363d03884b334
Author: Tristan Seligmann <mithrandi at debian.org>
Date:   Thu Feb 18 22:05:50 2016 +0200

    Import python-hypothesis_3.0.2.orig.tar.gz
---
 Makefile                                    |  2 +-
 docs/changes.rst                            | 15 ++++++++++++++-
 setup.py                                    |  2 +-
 src/hypothesis/searchstrategy/recursive.py  |  4 ++++
 src/hypothesis/searchstrategy/strategies.py |  3 +++
 src/hypothesis/version.py                   |  2 +-
 tests/cover/test_simple_collections.py      |  2 +-
 tests/cover/test_validation.py              | 23 ++++++++++++++++++++++-
 tests/nocover/test_recursive.py             |  3 +++
 tests/numpy/test_gen_data.py                |  2 +-
 10 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 18d32b5..b588631 100644
--- a/Makefile
+++ b/Makefile
@@ -63,7 +63,7 @@ $(ISORT_VIRTUALENV): $(PY34)
 format: $(PYFORMAT) $(ISORT)
 	$(TOOL_PYTHON) scripts/enforce_header.py
 	# isort will sort packages differently depending on whether they're installed
-	$(ISORT_VIRTUALENV)/bin/python -m pip install django pytz pytest fake-factory numpy
+	$(ISORT_VIRTUALENV)/bin/python -m pip install django pytz pytest fake-factory numpy flaky
 	env -i PATH=$(PATH) $(ISORT) -p hypothesis -ls -m 2 -w 75 \
 			-a  "from __future__ import absolute_import, print_function, division" \
 			-rc src tests examples
diff --git a/docs/changes.rst b/docs/changes.rst
index f77048b..197ecc1 100644
--- a/docs/changes.rst
+++ b/docs/changes.rst
@@ -21,6 +21,19 @@ Hypothesis APIs come in three flavours:
 You should generally assume that an API is internal unless you have specific
 information to the contrary.
 
+
+------------------
+3.0.2 - 2016-02-18
+------------------
+
+* Under certain circumstances, strategies involving text() buried inside some
+  other strategy (e.g. text().filter(...) or recursive(text(), ...)) would cause
+  a test to fail its health checks the first time it ran. This was caused by having
+  to compute some related data and cache it to disk. On travis or anywhere else
+  where the .hypothesis directory was recreated this would have caused the tests
+  to fail their health check on every run. This is now fixed for all the known cases,
+  although there could be others lurking.
+
 ------------------
 3.0.1 - 2016-02-18
 ------------------
@@ -29,7 +42,7 @@ information to the contrary.
   running certain flaky stateful tests.
 * Improve shrinking of large stateful tests by eliminating a case where it was
   hard to delete early steps.
-* Improve efficiency of drawing binary(min_size=n, max_size=n0 significantly by
+* Improve efficiency of drawing binary(min_size=n, max_size=n) significantly by
   provide a custom implementation for fixed size blocks that can bypass a lot
   of machinery.
 * Set default home directory based on the current working directory at the
diff --git a/setup.py b/setup.py
index dcfbcb8..904367b 100644
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,7 @@ extras = {
     'pytest': ['pytest>=2.7.0'],
 }
 
-extras['all'] = sum(extras.values(), [])
+extras['all'] = sorted(sum(extras.values(), []))
 extras['django'].extend(extras['fakefactory'])
 extras[":python_version == '2.6'"] = [
     'importlib', 'ordereddict', 'Counter', 'enum34']
diff --git a/src/hypothesis/searchstrategy/recursive.py b/src/hypothesis/searchstrategy/recursive.py
index e59a24b..2c3cbde 100644
--- a/src/hypothesis/searchstrategy/recursive.py
+++ b/src/hypothesis/searchstrategy/recursive.py
@@ -65,6 +65,10 @@ class RecursiveStrategy(SearchStrategy):
                 extend(OneOfStrategy(tuple(strategies), bias=0.8)))
         self.strategy = OneOfStrategy(strategies)
 
+    def validate(self):
+        self.base.validate()
+        self.extend(self.base).validate()
+
     def do_draw(self, data):
         while True:
             try:
diff --git a/src/hypothesis/searchstrategy/strategies.py b/src/hypothesis/searchstrategy/strategies.py
index f286508..3a2e8fa 100644
--- a/src/hypothesis/searchstrategy/strategies.py
+++ b/src/hypothesis/searchstrategy/strategies.py
@@ -284,6 +284,9 @@ class FilteredStrategy(SearchStrategy):
             )
         return self._cached_repr
 
+    def validate(self):
+        self.filtered_strategy.validate()
+
     def do_draw(self, data):
         for _ in hrange(3):
             start_index = data.index
diff --git a/src/hypothesis/version.py b/src/hypothesis/version.py
index db28c25..6c56165 100644
--- a/src/hypothesis/version.py
+++ b/src/hypothesis/version.py
@@ -16,5 +16,5 @@
 
 from __future__ import division, print_function, absolute_import
 
-__version_info__ = (3, 0, 1)
+__version_info__ = (3, 0, 2)
 __version__ = '.'.join(map(str, __version_info__))
diff --git a/tests/cover/test_simple_collections.py b/tests/cover/test_simple_collections.py
index 259e646..30d0af9 100644
--- a/tests/cover/test_simple_collections.py
+++ b/tests/cover/test_simple_collections.py
@@ -20,8 +20,8 @@ from random import Random
 from collections import namedtuple
 
 import pytest
-
 from flaky import flaky
+
 from hypothesis import find, given, settings
 from hypothesis.strategies import sets, text, lists, builds, tuples, \
     booleans, integers, frozensets, dictionaries, fixed_dictionaries
diff --git a/tests/cover/test_validation.py b/tests/cover/test_validation.py
index cff2d54..d550062 100644
--- a/tests/cover/test_validation.py
+++ b/tests/cover/test_validation.py
@@ -22,7 +22,7 @@ from hypothesis import find, given, settings
 from hypothesis.errors import InvalidArgument
 from tests.common.utils import fails_with
 from hypothesis.strategies import sets, lists, floats, booleans, \
-    integers, frozensets
+    integers, recursive, frozensets
 
 
 def test_errors_when_given_varargs():
@@ -148,6 +148,27 @@ def test_min_before_max():
         integers(min_value=1, max_value=0).validate()
 
 
+def test_filter_validates():
+    with pytest.raises(InvalidArgument):
+        integers(min_value=1, max_value=0).filter(bool).validate()
+
+
+def test_recursion_validates_base_case():
+    with pytest.raises(InvalidArgument):
+        recursive(
+            integers(min_value=1, max_value=0),
+            lists,
+        ).validate()
+
+
+def test_recursion_validates_recursive_step():
+    with pytest.raises(InvalidArgument):
+        recursive(
+            integers(),
+            lambda x: lists(x, min_size=3, max_size=1),
+        ).validate()
+
+
 @fails_with(InvalidArgument)
 @given(x=integers())
 def test_stuff_keyword(x=1):
diff --git a/tests/nocover/test_recursive.py b/tests/nocover/test_recursive.py
index 4f9cc68..8be549b 100644
--- a/tests/nocover/test_recursive.py
+++ b/tests/nocover/test_recursive.py
@@ -18,6 +18,8 @@ from __future__ import division, print_function, absolute_import
 
 from random import Random
 
+from flaky import flaky
+
 import hypothesis.strategies as st
 from hypothesis import find, given, example, settings
 from hypothesis.internal.debug import timeout
@@ -126,6 +128,7 @@ def test_can_use_recursive_data_in_sets(rnd):
     )
 
 
+ at flaky(max_runs=2, min_passes=1)
 def test_can_form_sets_of_recursive_data():
     trees = st.sets(st.recursive(
         st.booleans(),
diff --git a/tests/numpy/test_gen_data.py b/tests/numpy/test_gen_data.py
index 47d382b..dc3d8fc 100644
--- a/tests/numpy/test_gen_data.py
+++ b/tests/numpy/test_gen_data.py
@@ -18,9 +18,9 @@ from __future__ import division, print_function, absolute_import
 
 import numpy as np
 import pytest
+from flaky import flaky
 
 import hypothesis.strategies as st
-from flaky import flaky
 from hypothesis import find, given, settings
 from hypothesis.extra.numpy import arrays, from_dtype
 from hypothesis.strategytests import strategy_test_suite

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-hypothesis.git



More information about the Python-modules-commits mailing list