Imported Upstream version python3-pretend 1.0.9 upstream upstream/1.0.9
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 8 Apr 2021 05:48:41 +0000 (14:48 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 8 Apr 2021 05:48:41 +0000 (14:48 +0900)
LICENSE.rst [new file with mode: 0644]
MANIFEST.in [new file with mode: 0644]
PKG-INFO [new file with mode: 0644]
README.rst [new file with mode: 0644]
pretend.egg-info/PKG-INFO [new file with mode: 0644]
pretend.egg-info/SOURCES.txt [new file with mode: 0644]
pretend.egg-info/dependency_links.txt [new file with mode: 0644]
pretend.egg-info/top_level.txt [new file with mode: 0644]
pretend.py [new file with mode: 0644]
setup.cfg [new file with mode: 0644]
setup.py [new file with mode: 0644]

diff --git a/LICENSE.rst b/LICENSE.rst
new file mode 100644 (file)
index 0000000..4745674
--- /dev/null
@@ -0,0 +1,27 @@
+Copyright (c) Alex Gaynor and individual contributors.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    1. Redistributions of source code must retain the above copyright notice,
+       this list of conditions and the following disclaimer.
+
+    2. Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+
+    3. Neither the name of pretend nor the names of its contributors may be
+       used to endorse or promote products derived from this software without
+       specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644 (file)
index 0000000..fb65fe1
--- /dev/null
@@ -0,0 +1,2 @@
+include README.rst
+include LICENSE.rst
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644 (file)
index 0000000..450256e
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,137 @@
+Metadata-Version: 1.1
+Name: pretend
+Version: 1.0.9
+Summary: A library for stubbing in Python
+Home-page: https://github.com/alex/pretend
+Author: Alex Gaynor
+Author-email: alex.gaynor@gmail.com
+License: BSD
+Description: pretend
+        =======
+        
+        .. image:: https://secure.travis-ci.org/alex/pretend.png
+            :target: https://travis-ci.org/alex/pretend
+        
+        Pretend is a library to make stubbing with Python easier.
+        
+        What is stubbing?
+        -----------------
+        
+        Stubbing is a technique for writing tests. You may hear the term mixed up with
+        mocks, fakes, or doubles. Basically a stub is an object that returns pre-canned
+        responses, rather than doing any computation.
+        
+        Martin Fowler does a good job explaining the terms in his `Mocks Aren't Stubs`_
+        article.
+        
+        .. _`Mocks Aren't Stubs`: http://martinfowler.com/articles/mocksArentStubs.html
+        
+        How do I install ``pretend``?
+        -----------------------------
+        
+        It's easy with ``pip``!
+        
+        .. code:: bash
+        
+            $ pip install pretend
+        
+        How do I use ``pretend``?
+        -------------------------
+        
+        It's easy, the ``stub`` function makes it easy to create a stub:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub
+            >>> x = stub(country_code="US")
+            >>> some_function(x)
+        
+        Here ``x`` will be an object with a single attribute ``country_code`` which has
+        the value ``"US"``. Unlike mocks, ``x`` will not respond to any other attribute
+        or methods, nor does it have any methods for making assertions about what you
+        accessed.
+        
+        If you want to add a method to the stub, simply provide a function to it:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub
+            >>> x = stub(country_code=lambda: "US")
+            >>> x.country_code()
+            'US'
+        
+        It's important to note that functions on stubs *do not* take a ``self``
+        argument, this is because stubs should be returning pre-canned values, not
+        doing computations.
+        
+        Exceptions with ``pretend``
+        ---------------------------
+        
+        Sometimes a method you want to stub doesn't return a value, but instead raises
+        an exception. To make this easy, ``pretend`` provides a helper function,
+        ``raiser``, it can be used like so:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub, raiser
+            >>> x = stub(func=raiser(ValueError))
+            >>> x.func()
+            Traceback (most recent call last):
+              File "<stdin>", line 1, in <module>
+              File "pretend.py", line 74, in inner
+                raise exc
+            ValueError
+        
+        Why is stubbing better?
+        -----------------------
+        
+        Ideally stubbing tests how your system responds to a particular input, rather
+        than which API is used. Stubbing still requires you to write tests that check
+        the results of a computation, rather than looking for side effects. This
+        doesn't always work though, so you do sometimes still need mocking (e.g.
+        sometimes you really want to check for a side effect.)
+        
+        How do I get my stub into place?
+        --------------------------------
+        
+        If you come from other mocking libraries you're probably used to a ``patch``
+        method to put a mock in place. ``pretend`` doesn't include anything like this,
+        a) we believe it's better, where possible, to pass stubs as arguments rather
+        than monkey patch them into place, b) we believe that when you do need to
+        monkey patch something into place you should use something provided by your
+        testing tool. ``py.test`` includes `such a tool`_.
+        
+        .. _`such a tool`: http://pytest.org/latest/monkeypatch.html
+        
+        What if I really need to record the calls?
+        ------------------------------------------
+        
+        If you really really need to, ``pretend`` includes a ``call_recorder`` utility:
+        
+        .. code:: pycon
+        
+            >>> from pretend import call_recorder, call
+            >>> f = call_recorder(lambda a: a + 2)
+            >>> f(3)
+            5
+            >>> assert f.calls == [call(3)]
+        
+        Who wrote this?
+        ---------------
+        
+        ``pretend`` is by Alex Gaynor, who was just tired of not having a good stubbing
+        tool for Python. The name is from Idan Gazit.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: Software Development :: Testing
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+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 :: 3.6
diff --git a/README.rst b/README.rst
new file mode 100644 (file)
index 0000000..7fdb36d
--- /dev/null
@@ -0,0 +1,115 @@
+pretend
+=======
+
+.. image:: https://secure.travis-ci.org/alex/pretend.png
+    :target: https://travis-ci.org/alex/pretend
+
+Pretend is a library to make stubbing with Python easier.
+
+What is stubbing?
+-----------------
+
+Stubbing is a technique for writing tests. You may hear the term mixed up with
+mocks, fakes, or doubles. Basically a stub is an object that returns pre-canned
+responses, rather than doing any computation.
+
+Martin Fowler does a good job explaining the terms in his `Mocks Aren't Stubs`_
+article.
+
+.. _`Mocks Aren't Stubs`: http://martinfowler.com/articles/mocksArentStubs.html
+
+How do I install ``pretend``?
+-----------------------------
+
+It's easy with ``pip``!
+
+.. code:: bash
+
+    $ pip install pretend
+
+How do I use ``pretend``?
+-------------------------
+
+It's easy, the ``stub`` function makes it easy to create a stub:
+
+.. code:: pycon
+
+    >>> from pretend import stub
+    >>> x = stub(country_code="US")
+    >>> some_function(x)
+
+Here ``x`` will be an object with a single attribute ``country_code`` which has
+the value ``"US"``. Unlike mocks, ``x`` will not respond to any other attribute
+or methods, nor does it have any methods for making assertions about what you
+accessed.
+
+If you want to add a method to the stub, simply provide a function to it:
+
+.. code:: pycon
+
+    >>> from pretend import stub
+    >>> x = stub(country_code=lambda: "US")
+    >>> x.country_code()
+    'US'
+
+It's important to note that functions on stubs *do not* take a ``self``
+argument, this is because stubs should be returning pre-canned values, not
+doing computations.
+
+Exceptions with ``pretend``
+---------------------------
+
+Sometimes a method you want to stub doesn't return a value, but instead raises
+an exception. To make this easy, ``pretend`` provides a helper function,
+``raiser``, it can be used like so:
+
+.. code:: pycon
+
+    >>> from pretend import stub, raiser
+    >>> x = stub(func=raiser(ValueError))
+    >>> x.func()
+    Traceback (most recent call last):
+      File "<stdin>", line 1, in <module>
+      File "pretend.py", line 74, in inner
+        raise exc
+    ValueError
+
+Why is stubbing better?
+-----------------------
+
+Ideally stubbing tests how your system responds to a particular input, rather
+than which API is used. Stubbing still requires you to write tests that check
+the results of a computation, rather than looking for side effects. This
+doesn't always work though, so you do sometimes still need mocking (e.g.
+sometimes you really want to check for a side effect.)
+
+How do I get my stub into place?
+--------------------------------
+
+If you come from other mocking libraries you're probably used to a ``patch``
+method to put a mock in place. ``pretend`` doesn't include anything like this,
+a) we believe it's better, where possible, to pass stubs as arguments rather
+than monkey patch them into place, b) we believe that when you do need to
+monkey patch something into place you should use something provided by your
+testing tool. ``py.test`` includes `such a tool`_.
+
+.. _`such a tool`: http://pytest.org/latest/monkeypatch.html
+
+What if I really need to record the calls?
+------------------------------------------
+
+If you really really need to, ``pretend`` includes a ``call_recorder`` utility:
+
+.. code:: pycon
+
+    >>> from pretend import call_recorder, call
+    >>> f = call_recorder(lambda a: a + 2)
+    >>> f(3)
+    5
+    >>> assert f.calls == [call(3)]
+
+Who wrote this?
+---------------
+
+``pretend`` is by Alex Gaynor, who was just tired of not having a good stubbing
+tool for Python. The name is from Idan Gazit.
diff --git a/pretend.egg-info/PKG-INFO b/pretend.egg-info/PKG-INFO
new file mode 100644 (file)
index 0000000..450256e
--- /dev/null
@@ -0,0 +1,137 @@
+Metadata-Version: 1.1
+Name: pretend
+Version: 1.0.9
+Summary: A library for stubbing in Python
+Home-page: https://github.com/alex/pretend
+Author: Alex Gaynor
+Author-email: alex.gaynor@gmail.com
+License: BSD
+Description: pretend
+        =======
+        
+        .. image:: https://secure.travis-ci.org/alex/pretend.png
+            :target: https://travis-ci.org/alex/pretend
+        
+        Pretend is a library to make stubbing with Python easier.
+        
+        What is stubbing?
+        -----------------
+        
+        Stubbing is a technique for writing tests. You may hear the term mixed up with
+        mocks, fakes, or doubles. Basically a stub is an object that returns pre-canned
+        responses, rather than doing any computation.
+        
+        Martin Fowler does a good job explaining the terms in his `Mocks Aren't Stubs`_
+        article.
+        
+        .. _`Mocks Aren't Stubs`: http://martinfowler.com/articles/mocksArentStubs.html
+        
+        How do I install ``pretend``?
+        -----------------------------
+        
+        It's easy with ``pip``!
+        
+        .. code:: bash
+        
+            $ pip install pretend
+        
+        How do I use ``pretend``?
+        -------------------------
+        
+        It's easy, the ``stub`` function makes it easy to create a stub:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub
+            >>> x = stub(country_code="US")
+            >>> some_function(x)
+        
+        Here ``x`` will be an object with a single attribute ``country_code`` which has
+        the value ``"US"``. Unlike mocks, ``x`` will not respond to any other attribute
+        or methods, nor does it have any methods for making assertions about what you
+        accessed.
+        
+        If you want to add a method to the stub, simply provide a function to it:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub
+            >>> x = stub(country_code=lambda: "US")
+            >>> x.country_code()
+            'US'
+        
+        It's important to note that functions on stubs *do not* take a ``self``
+        argument, this is because stubs should be returning pre-canned values, not
+        doing computations.
+        
+        Exceptions with ``pretend``
+        ---------------------------
+        
+        Sometimes a method you want to stub doesn't return a value, but instead raises
+        an exception. To make this easy, ``pretend`` provides a helper function,
+        ``raiser``, it can be used like so:
+        
+        .. code:: pycon
+        
+            >>> from pretend import stub, raiser
+            >>> x = stub(func=raiser(ValueError))
+            >>> x.func()
+            Traceback (most recent call last):
+              File "<stdin>", line 1, in <module>
+              File "pretend.py", line 74, in inner
+                raise exc
+            ValueError
+        
+        Why is stubbing better?
+        -----------------------
+        
+        Ideally stubbing tests how your system responds to a particular input, rather
+        than which API is used. Stubbing still requires you to write tests that check
+        the results of a computation, rather than looking for side effects. This
+        doesn't always work though, so you do sometimes still need mocking (e.g.
+        sometimes you really want to check for a side effect.)
+        
+        How do I get my stub into place?
+        --------------------------------
+        
+        If you come from other mocking libraries you're probably used to a ``patch``
+        method to put a mock in place. ``pretend`` doesn't include anything like this,
+        a) we believe it's better, where possible, to pass stubs as arguments rather
+        than monkey patch them into place, b) we believe that when you do need to
+        monkey patch something into place you should use something provided by your
+        testing tool. ``py.test`` includes `such a tool`_.
+        
+        .. _`such a tool`: http://pytest.org/latest/monkeypatch.html
+        
+        What if I really need to record the calls?
+        ------------------------------------------
+        
+        If you really really need to, ``pretend`` includes a ``call_recorder`` utility:
+        
+        .. code:: pycon
+        
+            >>> from pretend import call_recorder, call
+            >>> f = call_recorder(lambda a: a + 2)
+            >>> f(3)
+            5
+            >>> assert f.calls == [call(3)]
+        
+        Who wrote this?
+        ---------------
+        
+        ``pretend`` is by Alex Gaynor, who was just tired of not having a good stubbing
+        tool for Python. The name is from Idan Gazit.
+        
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Intended Audience :: Developers
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Operating System :: OS Independent
+Classifier: Topic :: Software Development :: Testing
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+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 :: 3.6
diff --git a/pretend.egg-info/SOURCES.txt b/pretend.egg-info/SOURCES.txt
new file mode 100644 (file)
index 0000000..6921bbd
--- /dev/null
@@ -0,0 +1,10 @@
+LICENSE.rst
+MANIFEST.in
+README.rst
+pretend.py
+setup.cfg
+setup.py
+pretend.egg-info/PKG-INFO
+pretend.egg-info/SOURCES.txt
+pretend.egg-info/dependency_links.txt
+pretend.egg-info/top_level.txt
\ No newline at end of file
diff --git a/pretend.egg-info/dependency_links.txt b/pretend.egg-info/dependency_links.txt
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/pretend.egg-info/top_level.txt b/pretend.egg-info/top_level.txt
new file mode 100644 (file)
index 0000000..fbf7aef
--- /dev/null
@@ -0,0 +1 @@
+pretend
diff --git a/pretend.py b/pretend.py
new file mode 100644 (file)
index 0000000..e5e3e6b
--- /dev/null
@@ -0,0 +1,133 @@
+import functools
+import sys
+
+
+PY3K = sys.version_info >= (3,)
+
+
+methods = set([
+    "__iter__",
+    "__len__",
+    "__contains__",
+    "__getitem__",
+    "__setitem__",
+    "__delitem__",
+
+    "__enter__",
+    "__exit__",
+
+    "__lt__",
+    "__le__",
+    "__eq__",
+    "__ne__",
+    "__gt__",
+    "__ge__",
+
+    "__add__",
+    "__and__",
+    "__divmod__",
+    "__floordiv__",
+    "__lshift__",
+    "__mod__",
+    "__mul__",
+    "__or__",
+    "__pow__",
+    "__rshift__",
+    "__sub__",
+    "__truediv__",
+    "__xor__",
+
+    "__call__",
+    "__repr__",
+])
+if PY3K:
+    methods.add("__next__")
+    methods.add("__bool__")
+else:
+    methods.add("__div__")
+    methods.add("__nonzero__")
+MAGIC_METHODS = frozenset(methods)
+del methods
+
+
+def _build_magic_dispatcher(method):
+    def inner(self, *args, **kwargs):
+        return self.__dict__[method](*args, **kwargs)
+    inner.__name__ = method
+    return inner
+
+
+class stub(object):
+    _classes_cache = {}
+
+    def __new__(cls, **kwargs):
+        magic_methods_present = MAGIC_METHODS.intersection(kwargs)
+        if magic_methods_present not in cls._classes_cache:
+            attrs = dict(
+                (method, _build_magic_dispatcher(method))
+                for method in magic_methods_present
+            )
+            attrs["__module__"] = cls.__module__
+            cls._classes_cache[magic_methods_present] = (
+                type("stub", (cls,), attrs)
+            )
+        new_cls = cls._classes_cache[magic_methods_present]
+        return super(stub, new_cls).__new__(new_cls)
+
+    def __init__(self, **kwargs):
+        self.__dict__.update(kwargs)
+
+    def __repr__(self):
+        return '<stub(%s)>' % ', '.join([
+            '%s=%r' % (key, val)
+            for key, val in self.__dict__.items()
+        ])
+
+
+def raiser(exc):
+    if (
+        not (
+            isinstance(exc, BaseException) or
+            isinstance(exc, type) and issubclass(exc, BaseException)
+        )
+    ):
+        raise TypeError("exc must be either an exception instance or class.")
+
+    def inner(*args, **kwargs):
+        raise exc
+    return inner
+
+
+class call(object):
+    def __init__(self, *args, **kwargs):
+        self.args = args
+        self.kwargs = kwargs
+
+    def __eq__(self, other):
+        if not isinstance(other, call):
+            return NotImplemented
+        return self.args == other.args and self.kwargs == other.kwargs
+
+    def __ne__(self, other):
+        return not (self == other)
+
+    def __hash__(self):
+        return hash((
+            self.args,
+            frozenset(self.kwargs.items())
+        ))
+
+    def __repr__(self):
+        args = ", ".join(map(repr, self.args))
+        kwargs = ", ".join("%s=%r" % (k, v) for k, v in self.kwargs.items())
+        comma = ", " if args and kwargs else ""
+        return "<call(%s%s%s)>" % (args, comma, kwargs)
+
+
+def call_recorder(func):
+    @functools.wraps(func)
+    def inner(*args, **kwargs):
+        inner.calls.append(call(*args, **kwargs))
+        return func(*args, **kwargs)
+    inner.calls = []
+    return inner
diff --git a/setup.cfg b/setup.cfg
new file mode 100644 (file)
index 0000000..1e3eb36
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,7 @@
+[wheel]
+universal = 1
+
+[egg_info]
+tag_build = 
+tag_date = 0
+
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..5932acf
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,31 @@
+from setuptools import setup
+
+
+with open("README.rst") as f:
+    readme = f.read()
+
+setup(
+    version="1.0.9",
+    name="pretend",
+    description="A library for stubbing in Python",
+    long_description=readme,
+    author="Alex Gaynor",
+    author_email="alex.gaynor@gmail.com",
+    py_modules=["pretend"],
+    url="https://github.com/alex/pretend",
+    license="BSD",
+    classifiers=[
+        "Development Status :: 5 - Production/Stable",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+        "Topic :: Software Development :: Testing",
+        "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3.2",
+        "Programming Language :: Python :: 3.3",
+        "Programming Language :: Python :: 3.4",
+        "Programming Language :: Python :: 3.5",
+        "Programming Language :: Python :: 3.6",
+    ]
+)