[Python-modules-commits] [python-hypothesis] 01/04: Import python-hypothesis_1.16.0.orig.tar.gz

Tristan Seligmann mithrandi at moszumanska.debian.org
Fri Dec 11 16:17:58 UTC 2015


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

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

commit 1b81c3bb31828a3dc5c11245fca8758ab604feb2
Author: Tristan Seligmann <mithrandi at debian.org>
Date:   Fri Dec 11 16:54:15 2015 +0200

    Import python-hypothesis_1.16.0.orig.tar.gz
---
 PKG-INFO                                           |  20 +-
 README.rst                                         |  16 +-
 setup.cfg                                          |   2 +-
 setup.py                                           |  23 +-
 src/hypothesis.egg-info/PKG-INFO                   |  20 +-
 src/hypothesis.egg-info/SOURCES.txt                |   9 +-
 src/hypothesis.egg-info/entry_points.txt           |   3 +
 src/hypothesis.egg-info/requires.txt               |  14 +-
 src/hypothesis/__init__.py                         |  20 +-
 src/hypothesis/control.py                          |  63 +++-
 src/hypothesis/core.py                             | 102 +++---
 src/hypothesis/database/__init__.py                |  10 +-
 src/hypothesis/database/backend.py                 |  32 +-
 src/hypothesis/database/formats.py                 |  10 +-
 src/hypothesis/deprecation.py                      |  37 --
 src/hypothesis/errors.py                           |  18 +-
 src/hypothesis/executors/__init__.py               |  10 +-
 src/hypothesis/executors/executors.py              |  10 +-
 src/hypothesis/extra/__init__.py                   |  54 +--
 src/hypothesis/extra/datetime.py                   | 240 ++++++------
 src/hypothesis/extra/django/__init__.py            |  10 +-
 src/hypothesis/extra/django/fixtures.py            |  23 +-
 src/hypothesis/extra/django/models.py              |  13 +-
 src/hypothesis/extra/fakefactory.py                |  13 +-
 src/hypothesis/extra/numpy.py                      |  11 +-
 src/hypothesis/extra/pytestplugin.py               |  77 ++++
 src/hypothesis/internal/__init__.py                |  10 +-
 src/hypothesis/internal/charstree.py               | 310 ++++++++++++++++
 src/hypothesis/internal/chooser.py                 |  10 +-
 src/hypothesis/internal/classmap.py                |  16 +-
 src/hypothesis/internal/compat.py                  | 143 +++++++-
 src/hypothesis/{version.py => internal/compat3.py} |  21 +-
 src/hypothesis/internal/debug.py                   |  39 +-
 src/hypothesis/internal/distributions.py           |  10 +-
 src/hypothesis/internal/examplesource.py           |  16 +-
 src/hypothesis/internal/reflection.py              | 140 ++++---
 src/hypothesis/internal/strategymethod.py          | 214 +++++++++++
 src/hypothesis/internal/tracker.py                 |  12 +-
 src/hypothesis/internal/typechecking.py            |  10 +-
 src/hypothesis/reporting.py                        |  17 +-
 src/hypothesis/searchstrategy/__init__.py          |  24 +-
 src/hypothesis/searchstrategy/basic.py             |  40 +-
 src/hypothesis/searchstrategy/collections.py       |  33 +-
 src/hypothesis/searchstrategy/deferred.py          | 127 +++++++
 src/hypothesis/searchstrategy/flatmapped.py        |  14 +-
 src/hypothesis/searchstrategy/misc.py              |  22 +-
 src/hypothesis/searchstrategy/morphers.py          |  10 +-
 src/hypothesis/searchstrategy/narytree.py          |  20 +-
 src/hypothesis/searchstrategy/numbers.py           |  62 +---
 src/hypothesis/searchstrategy/recursive.py         |  10 +-
 src/hypothesis/searchstrategy/reprwrapper.py       |  10 +-
 src/hypothesis/searchstrategy/shared.py            |  92 +++++
 src/hypothesis/searchstrategy/strategies.py        |  86 ++---
 src/hypothesis/searchstrategy/streams.py           |  19 +-
 src/hypothesis/searchstrategy/strings.py           | 145 +++++---
 src/hypothesis/searchstrategy/wrappers.py          |  13 +-
 src/hypothesis/settings.py                         | 221 ++++++++---
 src/hypothesis/specifiers.py                       |  10 +-
 src/hypothesis/stateful.py                         | 117 ++++--
 src/hypothesis/strategies.py                       | 406 ++++++++++-----------
 src/hypothesis/strategytests.py                    |  27 +-
 src/hypothesis/testrunners/__init__.py             |  10 +-
 src/hypothesis/testrunners/forking.py              |  10 +-
 src/hypothesis/tools/__init__.py                   |  10 +-
 src/hypothesis/tools/mergedbs.py                   |  10 +-
 src/hypothesis/types.py                            |  10 +-
 src/hypothesis/utils/__init__.py                   |  10 +-
 src/hypothesis/utils/conventions.py                |  16 +-
 src/hypothesis/utils/dynamicvariables.py           |  14 +-
 src/hypothesis/utils/extmethod.py                  |  10 +-
 src/hypothesis/utils/idkey.py                      |  16 +-
 src/hypothesis/utils/show.py                       |  10 +-
 src/hypothesis/utils/size.py                       |  16 +-
 src/hypothesis/version.py                          |  16 +-
 74 files changed, 2354 insertions(+), 1140 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 2940314..1db1069 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: hypothesis
-Version: 1.11.0
+Version: 1.16.0
 Summary: A library for property based testing
 Home-page: https://github.com/DRMacIver/hypothesis
 Author: David R. MacIver
@@ -19,9 +19,10 @@ Description: ==========
         unit testing by some way. It's easy to use, stable, and extremely powerful. If
         you're not using Hypothesis to test your project then you're missing out.
         
-        Hypothesis works with most widely used versions of Python. Officially it supports
-        2.6, 2.7 and 3.3+, but 3.0 through 3.2 will probably also work in the unlikely event
-        that you're using them. Both CPython and PyPy are fully supported.
+        Hypothesis works with most widely used versions of Python. It supports implementations
+        compatible with 2.6, 2.7 and 3.3+, and is known to work on CPython and PyPy (but not
+        PyPy3 until they support a 3.3 compatible version of the language). It does *not* currently
+        work on Jython or on Python 3.0 through 3.2.
         
         -----------------
         Links of interest
@@ -41,6 +42,15 @@ Description: ==========
         If you want to hear from people who are already using Hypothesis, some of them `have written
         about it <https://hypothesis.readthedocs.org/en/latest/endorsements.html>`_.
         
+        
+        -------------------
+        Ongoing Development
+        -------------------
+        
+        Development on Hypothesis is a mix of community provided and sponsored. If you wish to contribute,
+        either financially or through code, `you can read more about the process in the documentation 
+        <http://hypothesis.readthedocs.org/en/latest/development.html>`_.
+        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
@@ -52,9 +62,9 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Software Development :: Testing
diff --git a/README.rst b/README.rst
index 9c3c7f8..7293f9c 100644
--- a/README.rst
+++ b/README.rst
@@ -11,9 +11,10 @@ Hypothesis is both extremely practical and also advances the state of the art of
 unit testing by some way. It's easy to use, stable, and extremely powerful. If
 you're not using Hypothesis to test your project then you're missing out.
 
-Hypothesis works with most widely used versions of Python. Officially it supports
-2.6, 2.7 and 3.3+, but 3.0 through 3.2 will probably also work in the unlikely event
-that you're using them. Both CPython and PyPy are fully supported.
+Hypothesis works with most widely used versions of Python. It supports implementations
+compatible with 2.6, 2.7 and 3.3+, and is known to work on CPython and PyPy (but not
+PyPy3 until they support a 3.3 compatible version of the language). It does *not* currently
+work on Jython or on Python 3.0 through 3.2.
 
 -----------------
 Links of interest
@@ -32,3 +33,12 @@ If you're looking for inspiration for writing your own QuickCheck clone,
 
 If you want to hear from people who are already using Hypothesis, some of them `have written
 about it <https://hypothesis.readthedocs.org/en/latest/endorsements.html>`_.
+
+
+-------------------
+Ongoing Development
+-------------------
+
+Development on Hypothesis is a mix of community provided and sponsored. If you wish to contribute,
+either financially or through code, `you can read more about the process in the documentation 
+<http://hypothesis.readthedocs.org/en/latest/development.html>`_.
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..a669c45 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
 [egg_info]
+tag_svn_revision = 0
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/setup.py b/setup.py
index 8e619a6..ae70347 100644
--- a/setup.py
+++ b/setup.py
@@ -1,22 +1,21 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
-from distutils.core import setup
 from setuptools.command.test import test as TestCommand
-from setuptools import find_packages
+from setuptools import find_packages, setup
 import sys
 import os
 
@@ -51,9 +50,10 @@ class PyTest(TestCommand):
 
 extras = {
     'datetime':  ["pytz"],
-    'fakefactory': ["fake-factory==0.5.2"],
+    'fakefactory': ["fake-factory>=0.5.2,<=0.5.3"],
     'django': ['pytz', 'django>=1.7'],
-    'numpy': ['numpy>=1.9.0']
+    'numpy': ['numpy>=1.9.0'],
+    'pytest': ['pytest>=2.7.0'],
 }
 
 extras['all'] = sum(extras.values(), [])
@@ -84,13 +84,16 @@ setup(
         "Programming Language :: Python :: 2.6",
         "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.2",
         "Programming Language :: Python :: 3.3",
         "Programming Language :: Python :: 3.4",
+        "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: Implementation :: CPython",
         "Programming Language :: Python :: Implementation :: PyPy",
         "Topic :: Software Development :: Testing",
     ],
+    entry_points={
+        'pytest11': ['hypothesispytest = hypothesis.extra.pytestplugin'],
+    },
     long_description=open(README).read(),
     tests_require=[
         'pytest', 'flake8'],
diff --git a/src/hypothesis.egg-info/PKG-INFO b/src/hypothesis.egg-info/PKG-INFO
index 2940314..1db1069 100644
--- a/src/hypothesis.egg-info/PKG-INFO
+++ b/src/hypothesis.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: hypothesis
-Version: 1.11.0
+Version: 1.16.0
 Summary: A library for property based testing
 Home-page: https://github.com/DRMacIver/hypothesis
 Author: David R. MacIver
@@ -19,9 +19,10 @@ Description: ==========
         unit testing by some way. It's easy to use, stable, and extremely powerful. If
         you're not using Hypothesis to test your project then you're missing out.
         
-        Hypothesis works with most widely used versions of Python. Officially it supports
-        2.6, 2.7 and 3.3+, but 3.0 through 3.2 will probably also work in the unlikely event
-        that you're using them. Both CPython and PyPy are fully supported.
+        Hypothesis works with most widely used versions of Python. It supports implementations
+        compatible with 2.6, 2.7 and 3.3+, and is known to work on CPython and PyPy (but not
+        PyPy3 until they support a 3.3 compatible version of the language). It does *not* currently
+        work on Jython or on Python 3.0 through 3.2.
         
         -----------------
         Links of interest
@@ -41,6 +42,15 @@ Description: ==========
         If you want to hear from people who are already using Hypothesis, some of them `have written
         about it <https://hypothesis.readthedocs.org/en/latest/endorsements.html>`_.
         
+        
+        -------------------
+        Ongoing Development
+        -------------------
+        
+        Development on Hypothesis is a mix of community provided and sponsored. If you wish to contribute,
+        either financially or through code, `you can read more about the process in the documentation 
+        <http://hypothesis.readthedocs.org/en/latest/development.html>`_.
+        
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Intended Audience :: Developers
@@ -52,9 +62,9 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.2
 Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
+Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Topic :: Software Development :: Testing
diff --git a/src/hypothesis.egg-info/SOURCES.txt b/src/hypothesis.egg-info/SOURCES.txt
index 3e80207..482bff0 100644
--- a/src/hypothesis.egg-info/SOURCES.txt
+++ b/src/hypothesis.egg-info/SOURCES.txt
@@ -1,9 +1,9 @@
 README.rst
+setup.cfg
 setup.py
 src/hypothesis/__init__.py
 src/hypothesis/control.py
 src/hypothesis/core.py
-src/hypothesis/deprecation.py
 src/hypothesis/errors.py
 src/hypothesis/reporting.py
 src/hypothesis/settings.py
@@ -16,6 +16,7 @@ src/hypothesis/version.py
 src/hypothesis.egg-info/PKG-INFO
 src/hypothesis.egg-info/SOURCES.txt
 src/hypothesis.egg-info/dependency_links.txt
+src/hypothesis.egg-info/entry_points.txt
 src/hypothesis.egg-info/not-zip-safe
 src/hypothesis.egg-info/requires.txt
 src/hypothesis.egg-info/top_level.txt
@@ -28,22 +29,27 @@ src/hypothesis/extra/__init__.py
 src/hypothesis/extra/datetime.py
 src/hypothesis/extra/fakefactory.py
 src/hypothesis/extra/numpy.py
+src/hypothesis/extra/pytestplugin.py
 src/hypothesis/extra/django/__init__.py
 src/hypothesis/extra/django/fixtures.py
 src/hypothesis/extra/django/models.py
 src/hypothesis/internal/__init__.py
+src/hypothesis/internal/charstree.py
 src/hypothesis/internal/chooser.py
 src/hypothesis/internal/classmap.py
 src/hypothesis/internal/compat.py
+src/hypothesis/internal/compat3.py
 src/hypothesis/internal/debug.py
 src/hypothesis/internal/distributions.py
 src/hypothesis/internal/examplesource.py
 src/hypothesis/internal/reflection.py
+src/hypothesis/internal/strategymethod.py
 src/hypothesis/internal/tracker.py
 src/hypothesis/internal/typechecking.py
 src/hypothesis/searchstrategy/__init__.py
 src/hypothesis/searchstrategy/basic.py
 src/hypothesis/searchstrategy/collections.py
+src/hypothesis/searchstrategy/deferred.py
 src/hypothesis/searchstrategy/flatmapped.py
 src/hypothesis/searchstrategy/misc.py
 src/hypothesis/searchstrategy/morphers.py
@@ -51,6 +57,7 @@ src/hypothesis/searchstrategy/narytree.py
 src/hypothesis/searchstrategy/numbers.py
 src/hypothesis/searchstrategy/recursive.py
 src/hypothesis/searchstrategy/reprwrapper.py
+src/hypothesis/searchstrategy/shared.py
 src/hypothesis/searchstrategy/strategies.py
 src/hypothesis/searchstrategy/streams.py
 src/hypothesis/searchstrategy/strings.py
diff --git a/src/hypothesis.egg-info/entry_points.txt b/src/hypothesis.egg-info/entry_points.txt
new file mode 100644
index 0000000..6ee4670
--- /dev/null
+++ b/src/hypothesis.egg-info/entry_points.txt
@@ -0,0 +1,3 @@
+[pytest11]
+hypothesispytest = hypothesis.extra.pytestplugin
+
diff --git a/src/hypothesis.egg-info/requires.txt b/src/hypothesis.egg-info/requires.txt
index cb4a604..f85733e 100644
--- a/src/hypothesis.egg-info/requires.txt
+++ b/src/hypothesis.egg-info/requires.txt
@@ -5,11 +5,12 @@ ordereddict
 Counter
 
 [all]
-numpy>=1.9.0
-pytz
 pytz
 django>=1.7
-fake-factory==0.5.2
+pytest>=2.7.0
+pytz
+numpy>=1.9.0
+fake-factory>=0.5.2,<=0.5.3
 
 [datetime]
 pytz
@@ -17,10 +18,13 @@ pytz
 [django]
 pytz
 django>=1.7
-fake-factory==0.5.2
+fake-factory>=0.5.2,<=0.5.3
 
 [fakefactory]
-fake-factory==0.5.2
+fake-factory>=0.5.2,<=0.5.3
 
 [numpy]
 numpy>=1.9.0
+
+[pytest]
+pytest>=2.7.0
diff --git a/src/hypothesis/__init__.py b/src/hypothesis/__init__.py
index 352d7da..69cef23 100644
--- a/src/hypothesis/__init__.py
+++ b/src/hypothesis/__init__.py
@@ -1,17 +1,17 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 """Hypothesis is a library for writing unit tests which are parametrized by
@@ -23,14 +23,11 @@ failing examples it finds.
 """
 
 
-from hypothesis.searchstrategy import strategy
+from hypothesis.searchstrategy.strategies import strategy
 from hypothesis.settings import Settings, Verbosity
 from hypothesis.version import __version_info__, __version__
-from hypothesis.core import given, assume, find, example
-
-# Force strategy extensions to be loaded here
-import hypothesis.strategies as unused
-[unused]
+from hypothesis.control import assume, note
+from hypothesis.core import given, find, example
 
 __all__ = [
     'Settings',
@@ -40,6 +37,7 @@ __all__ = [
     'strategy',
     'find',
     'example',
+    'note',
     '__version__',
     '__version_info__',
 ]
diff --git a/src/hypothesis/control.py b/src/hypothesis/control.py
index 3ea7721..24c5195 100644
--- a/src/hypothesis/control.py
+++ b/src/hypothesis/control.py
@@ -1,17 +1,17 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 from __future__ import division, print_function, absolute_import
@@ -21,6 +21,7 @@ import traceback
 from hypothesis.errors import CleanupFailed, InvalidArgument, \
     UnsatisfiedAssumption
 from hypothesis.reporting import report
+from hypothesis.internal.compat import text_type
 from hypothesis.utils.dynamicvariables import DynamicVariable
 
 
@@ -40,10 +41,25 @@ def assume(condition):
 _current_build_context = DynamicVariable(None)
 
 
+def current_build_context():
+    context = _current_build_context.value
+    if context is None:
+        raise InvalidArgument(
+            u'No build context registered')
+    return context
+
+
 class BuildContext(object):
 
-    def __init__(self):
+    def __init__(self, is_final=False, close_on_capture=True):
         self.tasks = []
+        self.is_final = is_final
+        self.close_on_capture = close_on_capture
+        self.captured = False
+        self.close_on_del = False
+
+    def mark_captured(self):
+        self.captured = True
 
     def __enter__(self):
         self.assign_variable = _current_build_context.with_value(self)
@@ -51,6 +67,21 @@ class BuildContext(object):
         return self
 
     def __exit__(self, exc_type, exc_value, tb):
+        self.assign_variable.__exit__(exc_type, exc_value, tb)
+        if self.captured and not self.close_on_capture:
+            self.close_on_del = True
+        else:
+            if self.close() and exc_type is None:
+                raise CleanupFailed()
+
+    def __del__(self):
+        if self.close_on_del:
+            self.close()
+
+    def local(self):
+        return _current_build_context.with_value(self)
+
+    def close(self):
         any_failed = False
         for task in self.tasks:
             try:
@@ -58,9 +89,7 @@ class BuildContext(object):
             except:
                 any_failed = True
                 report(traceback.format_exc())
-        self.assign_variable.__exit__(exc_type, exc_value, tb)
-        if exc_type is None and any_failed:
-            raise CleanupFailed()
+        return any_failed
 
 
 def cleanup(teardown):
@@ -78,3 +107,19 @@ def cleanup(teardown):
         raise InvalidArgument(
             u'Cannot register cleanup outside of build context')
     context.tasks.append(teardown)
+
+
+def note(value):
+    """Report this value in the final execution.
+
+    Will always call string conversion function of the value even if not
+    printing for consistency of execution
+
+    """
+    value = text_type(value)
+    context = _current_build_context.value
+    if context is None:
+        raise InvalidArgument(
+            u'Cannot make notes outside of build context')
+    if context.is_final:
+        report(value)
diff --git a/src/hypothesis/core.py b/src/hypothesis/core.py
index 56fe6d9..2d6637f 100644
--- a/src/hypothesis/core.py
+++ b/src/hypothesis/core.py
@@ -1,17 +1,17 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 """This module provides the core primitives of Hypothesis, assume and given."""
@@ -29,25 +29,21 @@ from random import Random
 from itertools import islice
 from collections import namedtuple
 
-import hypothesis.strategies as sd
-from hypothesis.extra import load_entry_points
 from hypothesis.errors import Flaky, Timeout, NoSuchExample, \
     Unsatisfiable, BadTemplateDraw, InvalidArgument, \
     UnsatisfiedAssumption, DefinitelyNoSuchExample
-from hypothesis.control import assume  # noqa
 from hypothesis.control import BuildContext
-from hypothesis.settings import Settings, Verbosity
+from hypothesis.settings import Settings, Verbosity, note_deprecation
 from hypothesis.executors import executor
 from hypothesis.reporting import report, debug_report, verbose_report, \
     current_verbosity
-from hypothesis.deprecation import note_deprecation
-from hypothesis.internal.compat import qualname, unicode_safe_repr
+from hypothesis.internal.compat import qualname, getargspec, \
+    unicode_safe_repr
 from hypothesis.internal.tracker import Tracker
-from hypothesis.internal.reflection import arg_string, copy_argspec, \
-    function_digest, fully_qualified_name, convert_positional_arguments, \
-    get_pretty_function_description
+from hypothesis.internal.reflection import arg_string, impersonate, \
+    copy_argspec, function_digest, fully_qualified_name, \
+    convert_positional_arguments, get_pretty_function_description
 from hypothesis.internal.examplesource import ParameterSource
-from hypothesis.searchstrategy.strategies import strategy
 
 
 def time_to_call_it_a_day(settings, start_time):
@@ -244,6 +240,8 @@ def simplify_template_such_that(
                             yield s
                             t = s
                             break
+                        else:
+                            yield t
                     except UnsatisfiedAssumption:
                         pass
                 else:
@@ -347,17 +345,18 @@ def example(*args, **kwargs):
 
 def reify_and_execute(
     search_strategy, template, test,
-    print_example=False, always_print=False, record_repr=None,
+    print_example=False, record_repr=None,
+    is_final=False,
 ):
     def run():
-        with BuildContext():
+        with BuildContext(is_final=is_final):
             args, kwargs = search_strategy.reify(template)
             text_version = arg_string(test, args, kwargs)
             if print_example:
                 report(
                     lambda: u'Falsifying example: %s(%s)' % (
                         test.__name__, text_version,))
-            elif current_verbosity() >= Verbosity.verbose or always_print:
+            elif current_verbosity() >= Verbosity.verbose:
                 report(
                     lambda: u'Trying example: %s(%s)' % (
                         test.__name__, text_version))
@@ -381,15 +380,6 @@ def given(*generator_arguments, **generator_kwargs):
     # if they were keyword specifiers for data to pass to the test.
     provided_random = generator_kwargs.pop(u'random', None)
     settings = generator_kwargs.pop(u'settings', None) or Settings.default
-
-    if (provided_random is not None) and settings.derandomize:
-        raise InvalidArgument(
-            u'Cannot both be derandomized and provide an explicit random')
-
-    if not (generator_arguments or generator_kwargs):
-        raise InvalidArgument(
-            u'given must be called with at least one argument')
-
     if generator_arguments and generator_kwargs:
         note_deprecation(
             u'Mixing positional and keyword arguments in a call to given is '
@@ -397,22 +387,35 @@ def given(*generator_arguments, **generator_kwargs):
         )
 
     def run_test_with_generator(test):
+        original_argspec = getargspec(test)
+
+        def invalid(message):
+            def wrapped_test(*arguments, **kwargs):
+                raise InvalidArgument(message)
+            return wrapped_test
+
+        if (provided_random is not None) and settings.derandomize:
+            return invalid(
+                u'Cannot both be derandomized and provide an explicit random')
+
+        if not (generator_arguments or generator_kwargs):
+            return invalid(
+                u'given must be called with at least one argument')
+
         if settings.derandomize:
-            assert provided_random is None
             random = Random(function_digest(test))
         else:
             random = provided_random or Random()
 
-        original_argspec = inspect.getargspec(test)
         if generator_arguments and original_argspec.varargs:
-            raise InvalidArgument(
+            return invalid(
                 u'varargs are not supported with positional arguments to '
                 u'@given'
             )
         extra_kwargs = [
             k for k in generator_kwargs if k not in original_argspec.args]
         if extra_kwargs and not original_argspec.keywords:
-            raise InvalidArgument(
+            return invalid(
                 u'%s() got an unexpected keyword argument %r' % (
                     test.__name__,
                     extra_kwargs[0]
@@ -420,7 +423,7 @@ def given(*generator_arguments, **generator_kwargs):
         if (
             len(generator_arguments) > len(original_argspec.args)
         ):
-            raise InvalidArgument((
+            return invalid((
                 u'Too many positional arguments for %s() (got %d but'
                 u' expected at most %d') % (
                     test.__name__, len(generator_arguments),
@@ -429,12 +432,18 @@ def given(*generator_arguments, **generator_kwargs):
         specifiers = list(generator_arguments)
         seen_kwarg = None
         for a in arguments:
+            if isinstance(a, list):  # pragma: no cover
+                return invalid((
+                    u'Cannot decorate function %s() because it has '
+                    u'destructuring arguments') % (
+                        test.__name__,
+                ))
             if a in generator_kwargs:
                 seen_kwarg = seen_kwarg or a
                 specifiers.append(generator_kwargs[a])
             else:
                 if seen_kwarg is not None:
-                    raise InvalidArgument((
+                    return invalid((
                         u'Argument %s comes after keyword %s which has been '
                         u'specified, but does not itself have a '
                         u'specification') % (
@@ -452,10 +461,14 @@ def given(*generator_arguments, **generator_kwargs):
         for k in extra_kwargs:
             unused_kwargs[k] = HypothesisProvided(generator_kwargs[k])
 
+        @impersonate(test)
         @copy_argspec(
             test.__name__, argspec
         )
         def wrapped_test(*arguments, **kwargs):
+            import hypothesis.strategies as sd
+            from hypothesis.internal.strategymethod import strategy
+
             selfy = None
             arguments, kwargs = convert_positional_arguments(
                 wrapped_test, arguments, kwargs)
@@ -525,6 +538,7 @@ def given(*generator_arguments, **generator_kwargs):
             )
 
             search_strategy = strategy(given_specifier, settings)
+            search_strategy.validate()
 
             if settings.database:
                 storage = settings.database.storage(
@@ -540,15 +554,12 @@ def given(*generator_arguments, **generator_kwargs):
                 try:
                     test_runner(reify_and_execute(
                         search_strategy, xs, test,
-                        always_print=settings.max_shrinks <= 0,
                         record_repr=record_repr,
                     ))
                     return False
                 except UnsatisfiedAssumption as e:
                     raise e
                 except Exception as e:
-                    if settings.max_shrinks <= 0:
-                        raise e
                     last_exception[0] = traceback.format_exc()
                     repr_for_last_exception[0] = record_repr[0]
                     verbose_report(last_exception[0])
@@ -571,7 +582,7 @@ def given(*generator_arguments, **generator_kwargs):
             with settings:
                 test_runner(reify_and_execute(
                     search_strategy, falsifying_template, test,
-                    print_example=True
+                    print_example=True, is_final=True
                 ))
 
                 report(
@@ -582,15 +593,12 @@ def given(*generator_arguments, **generator_kwargs):
                 test_runner(reify_and_execute(
                     search_strategy, falsifying_template,
                     test_is_flaky(test, repr_for_last_exception[0]),
-                    print_example=True
+                    print_example=True, is_final=True
                 ))
-
-        wrapped_test.__name__ = test.__name__
-        wrapped_test.__doc__ = test.__doc__
+        for attr in dir(test):
+            if attr[0] != '_' and not hasattr(wrapped_test, attr):
+                setattr(wrapped_test, attr, getattr(test, attr))
         wrapped_test.is_hypothesis_test = True
-        wrapped_test.hypothesis_explicit_examples = getattr(
-            test, u'hypothesis_explicit_examples', []
-        )
         return wrapped_test
     return run_test_with_generator
 
@@ -602,6 +610,7 @@ def find(specifier, condition, settings=None, random=None, storage=None):
         max_shrinks=2000,
     )
 
+    from hypothesis.internal.strategymethod import strategy
     search = strategy(specifier, settings)
 
     if storage is None and settings.database is not None:
@@ -646,7 +655,7 @@ def find(specifier, condition, settings=None, random=None, storage=None):
             tracker=tracker, max_parameter_tries=2,
             storage=storage,
         )
-        with BuildContext():
+        with BuildContext(is_final=True, close_on_capture=False):
             return search.reify(template)
     except Timeout:
         raise
@@ -657,6 +666,3 @@ def find(specifier, condition, settings=None, random=None, storage=None):
                 search.template_upper_bound,
             )
         raise NoSuchExample(get_pretty_function_description(condition))
-
-
-load_entry_points()
diff --git a/src/hypothesis/database/__init__.py b/src/hypothesis/database/__init__.py
index 843dd51..4d0ecdf 100644
--- a/src/hypothesis/database/__init__.py
+++ b/src/hypothesis/database/__init__.py
@@ -1,17 +1,17 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 from hypothesis.searchstrategy.strategies import BadData
diff --git a/src/hypothesis/database/backend.py b/src/hypothesis/database/backend.py
index d37c5eb..d83fd0b 100644
--- a/src/hypothesis/database/backend.py
+++ b/src/hypothesis/database/backend.py
@@ -1,22 +1,23 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 from __future__ import division, print_function, absolute_import
 
 import sqlite3
+import threading
 from abc import abstractmethod
 from contextlib import contextmanager
 
@@ -58,24 +59,29 @@ class Backend(object):
     def fetch(self, key):
         """yield the values matching this key."""
 
+    @abstractmethod  # pragma: no cover
+    def close(self):
+        """Close database connection whenever such is used."""
+
 
 class SQLiteBackend(Backend):
 
     def __init__(self, path=u':memory:'):
         self.path = path
         self.db_created = False
-        self.__connection = None
+        self.current_connection = threading.local()
 
     def connection(self):
-        if self.__connection is None:
-            self.__connection = sqlite3.connect(self.path)
-        return self.__connection
+        if not hasattr(self.current_connection, 'connection'):
+            self.current_connection.connection = sqlite3.connect(self.path)
+        return self.current_connection.connection
 
     def close(self):
-        if self.__connection is not None:
-            c = self.__connection
-            self.__connection = None
-            c.close()
+        if hasattr(self.current_connection, 'connection'):
+            try:
+                self.connection().close()
+            finally:
+                del self.current_connection.connection
 
     def __repr__(self):
         return u'%s(%s)' % (self.__class__.__name__, self.path)
diff --git a/src/hypothesis/database/formats.py b/src/hypothesis/database/formats.py
index 0a475b1..6652622 100644
--- a/src/hypothesis/database/formats.py
+++ b/src/hypothesis/database/formats.py
@@ -1,17 +1,17 @@
 # coding=utf-8
-
+#
 # This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
+#
 # Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
+# (david at drmaciver.com), but it contains contributions by others. See
 # https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
 # full list of people who may hold copyright, and consult the git log if you
 # need to determine who owns an individual contribution.
-
+#
 # This Source Code Form is subject to the terms of the Mozilla Public License,
 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
 # obtain one at http://mozilla.org/MPL/2.0/.
-
+#
 # END HEADER
 
 """This is the module responsible for handling conversion of data to and from a
diff --git a/src/hypothesis/deprecation.py b/src/hypothesis/deprecation.py
deleted file mode 100644
index f9921b5..0000000
--- a/src/hypothesis/deprecation.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# coding=utf-8
-
-# This file is part of Hypothesis (https://github.com/DRMacIver/hypothesis)
-
-# Most of this work is copyright (C) 2013-2015 David R. MacIver
-# (david at drmaciver.com), but it contains contributions by other. See
-# https://github.com/DRMacIver/hypothesis/blob/master/CONTRIBUTING.rst for a
-# full list of people who may hold copyright, and consult the git log if you
-# need to determine who owns an individual contribution.
-
-# This Source Code Form is subject to the terms of the Mozilla Public License,
-# v. 2.0. If a copy of the MPL was not distributed with this file, You can
-# obtain one at http://mozilla.org/MPL/2.0/.
-
-# END HEADER
-
-from __future__ import division, print_function, absolute_import
-
-import warnings
-
-from hypothesis.settings import Settings, Verbosity
-
-
-class HypothesisDeprecationWarning(DeprecationWarning):
-    pass
-
-
-warnings.simplefilter(u'once', HypothesisDeprecationWarning)
-
-
-def note_deprecation(message, settings):
-    settings = settings or Settings.default
-    warning = HypothesisDeprecationWarning(message)
-    if settings.strict:
-        raise warning
-    elif settings.verbosity > Verbosity.quiet:
... 5124 lines suppressed ...

-- 
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