lollipop-hypothesis


Namelollipop-hypothesis JSON
Version 0.2 PyPI version JSON
download
home_pagehttps://github.com/maximkulkin/lollipop-hypothesis
SummaryLibrary to generate random test data using Hypothesis based on Lollipop schema
upload_time2017-05-16 07:06:36
maintainer
docs_urlNone
authorMaxim Kulkin
requires_python
licenseMIT
keywords lollipop hypothesis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            *******************
lollipop-hypothesis
*******************

.. image:: https://img.shields.io/pypi/l/lollipop-hypothesis.svg
    :target: https://github.com/maximkulkin/lollipop-hypothesis/blob/master/LICENSE
    :alt: License: MIT

.. image:: https://img.shields.io/travis/maximkulkin/lollipop-hypothesis.svg
    :target: https://travis-ci.org/maximkulkin/lollipop-hypothesis
    :alt: Build Status

.. image:: https://img.shields.io/pypi/v/lollipop-hypothesis.svg
    :target: https://pypi.python.org/pypi/lollipop-hypothesis
    :alt: PyPI

Library to generate random test data using Hypothesis based on Lollipop schema.

Example
=======
.. code:: python

    from collections import namedtuple
    import lollipop.types as lt
    import lollipop.validators as lv
    import string

    EMAIL_REGEXP = r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]{2,}\.[a-zA-Z0-9-.]{2,}$"
    Email = lt.validated_type(lt.String, 'Email', lv.Regexp(EMAIL_REGEXP))

    User = namedtuple('User', ['name', 'email', 'age'])

    USER = lt.Object({
        'name': lt.String(validate=lv.Length(min=1)),
        'email': Email(),
        'age': lt.Optional(lt.Integer(validate=lv.Range(min=18))),
    }, constructor=User)

    import hypothesis as h
    import hypothesis.strategies as hs
    import lollipop_hypothesis as lh

    # Write a test using data generation strategy based on Lollipop schema
    @h.given(lh.type_strategy(USER))
    def test_can_register_any_valid_user(user):
        register(user)

    # Configure custom strategy for Email type
    lh.register(
        Email,
        lambda _, type, context=None: \
            hs.tuples(
                hs.text('abcdefghijklmnopqrstuvwxyz'
                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                        '0123456789'
                        '_.+-', min_size=1),
                hs.lists(
                    hs.text('abcdefghijklmnopqrstuvwxyz'
                            'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
                            '0123456789', min_size=2),
                    min_size=2,
                    average_size=3,
                )
            ).map(lambda (name, domain_parts): name + '@' + '.'.join(domain_parts)),
    )

    # Or configure custom strategy for the whole type instance
    lh.register(
        USER,
        lambda registry, type, context=None: \
            hs.builds(
                User,
                name=hs.text(min_size=1),
                email=registry.convert(Email(), context),
                age=hs.integers(min_value=0, max_value=100),
            )
    )


Installation
============
::

    $ pip install lollipop-hypothesis

    # install optional package for regex support
    $ pip install lollipop-hypothesis[regex]

Requirements
============

- Python >= 2.7 and <= 3.6
- `lollipop <https://pypi.python.org/pypi/lollipop>`_ >= 1.1.3
- `hypothesis <https://pypi.python.org/pypi/hypothesis>`_ >= 3.8
- (optional) `hypothesis-regex <https://pypi.python.org/pypi/hypothesis-regex>`_ >= 0.1

Project Links
=============

- PyPI: https://pypi.python.org/pypi/lollipop-hypothesis
- Issues: https://github.com/maximkulkin/lollipop-hypothesis/issues

License
=======

MIT licensed. See the bundled `LICENSE <https://github.com/maximkulkin/lollipop-hypothesis/blob/master/LICENSE>`_ file for more details.
            

Raw data

            {
    "_id": null,
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "cheesecake_code_kwalitee_id": null,
    "keywords": "lollipop,hypothesis",
    "upload_time": "2017-05-16 07:06:36",
    "author": "Maxim Kulkin",
    "home_page": "https://github.com/maximkulkin/lollipop-hypothesis",
    "github_user": "maximkulkin",
    "download_url": "https://pypi.python.org/packages/30/59/1c7e8f0db3ae2437db3bcca96e18beebaf3d8f1900ca9587ec72e70a42e6/lollipop-hypothesis-0.2.tar.gz",
    "platform": "UNKNOWN",
    "version": "0.2",
    "cheesecake_documentation_id": null,
    "description": "*******************\r\nlollipop-hypothesis\r\n*******************\r\n\r\n.. image:: https://img.shields.io/pypi/l/lollipop-hypothesis.svg\r\n    :target: https://github.com/maximkulkin/lollipop-hypothesis/blob/master/LICENSE\r\n    :alt: License: MIT\r\n\r\n.. image:: https://img.shields.io/travis/maximkulkin/lollipop-hypothesis.svg\r\n    :target: https://travis-ci.org/maximkulkin/lollipop-hypothesis\r\n    :alt: Build Status\r\n\r\n.. image:: https://img.shields.io/pypi/v/lollipop-hypothesis.svg\r\n    :target: https://pypi.python.org/pypi/lollipop-hypothesis\r\n    :alt: PyPI\r\n\r\nLibrary to generate random test data using Hypothesis based on Lollipop schema.\r\n\r\nExample\r\n=======\r\n.. code:: python\r\n\r\n    from collections import namedtuple\r\n    import lollipop.types as lt\r\n    import lollipop.validators as lv\r\n    import string\r\n\r\n    EMAIL_REGEXP = r\"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]{2,}\\.[a-zA-Z0-9-.]{2,}$\"\r\n    Email = lt.validated_type(lt.String, 'Email', lv.Regexp(EMAIL_REGEXP))\r\n\r\n    User = namedtuple('User', ['name', 'email', 'age'])\r\n\r\n    USER = lt.Object({\r\n        'name': lt.String(validate=lv.Length(min=1)),\r\n        'email': Email(),\r\n        'age': lt.Optional(lt.Integer(validate=lv.Range(min=18))),\r\n    }, constructor=User)\r\n\r\n    import hypothesis as h\r\n    import hypothesis.strategies as hs\r\n    import lollipop_hypothesis as lh\r\n\r\n    # Write a test using data generation strategy based on Lollipop schema\r\n    @h.given(lh.type_strategy(USER))\r\n    def test_can_register_any_valid_user(user):\r\n        register(user)\r\n\r\n    # Configure custom strategy for Email type\r\n    lh.register(\r\n        Email,\r\n        lambda _, type, context=None: \\\r\n            hs.tuples(\r\n                hs.text('abcdefghijklmnopqrstuvwxyz'\r\n                        'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n                        '0123456789'\r\n                        '_.+-', min_size=1),\r\n                hs.lists(\r\n                    hs.text('abcdefghijklmnopqrstuvwxyz'\r\n                            'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n                            '0123456789', min_size=2),\r\n                    min_size=2,\r\n                    average_size=3,\r\n                )\r\n            ).map(lambda (name, domain_parts): name + '@' + '.'.join(domain_parts)),\r\n    )\r\n\r\n    # Or configure custom strategy for the whole type instance\r\n    lh.register(\r\n        USER,\r\n        lambda registry, type, context=None: \\\r\n            hs.builds(\r\n                User,\r\n                name=hs.text(min_size=1),\r\n                email=registry.convert(Email(), context),\r\n                age=hs.integers(min_value=0, max_value=100),\r\n            )\r\n    )\r\n\r\n\r\nInstallation\r\n============\r\n::\r\n\r\n    $ pip install lollipop-hypothesis\r\n\r\n    # install optional package for regex support\r\n    $ pip install lollipop-hypothesis[regex]\r\n\r\nRequirements\r\n============\r\n\r\n- Python >= 2.7 and <= 3.6\r\n- `lollipop <https://pypi.python.org/pypi/lollipop>`_ >= 1.1.3\r\n- `hypothesis <https://pypi.python.org/pypi/hypothesis>`_ >= 3.8\r\n- (optional) `hypothesis-regex <https://pypi.python.org/pypi/hypothesis-regex>`_ >= 0.1\r\n\r\nProject Links\r\n=============\r\n\r\n- PyPI: https://pypi.python.org/pypi/lollipop-hypothesis\r\n- Issues: https://github.com/maximkulkin/lollipop-hypothesis/issues\r\n\r\nLicense\r\n=======\r\n\r\nMIT licensed. See the bundled `LICENSE <https://github.com/maximkulkin/lollipop-hypothesis/blob/master/LICENSE>`_ file for more details.",
    "tox": true,
    "lcname": "lollipop-hypothesis",
    "name": "lollipop-hypothesis",
    "github": true,
    "bugtrack_url": "",
    "license": "MIT",
    "travis_ci": true,
    "github_project": "lollipop-hypothesis",
    "summary": "Library to generate random test data using Hypothesis based on Lollipop schema",
    "split_keywords": [
        "lollipop",
        "hypothesis"
    ],
    "author_email": "maxim.kulkin@gmail.com",
    "urls": [
        {
            "has_sig": false,
            "upload_time": "2017-05-16T07:06:36",
            "comment_text": "",
            "python_version": "source",
            "url": "https://pypi.python.org/packages/30/59/1c7e8f0db3ae2437db3bcca96e18beebaf3d8f1900ca9587ec72e70a42e6/lollipop-hypothesis-0.2.tar.gz",
            "md5_digest": "3be38f4bcc9c1220a2e7a2e77b70df04",
            "downloads": 0,
            "filename": "lollipop-hypothesis-0.2.tar.gz",
            "packagetype": "sdist",
            "path": "30/59/1c7e8f0db3ae2437db3bcca96e18beebaf3d8f1900ca9587ec72e70a42e6/lollipop-hypothesis-0.2.tar.gz",
            "size": 7183
        },
        {
            "has_sig": false,
            "upload_time": "2017-05-16T07:06:34",
            "comment_text": "",
            "python_version": "py2.py3",
            "url": "https://pypi.python.org/packages/d2/23/3b7b5cc5ab64cc096c4bcc61e15b7a91d14ba14f0d9f95267a1074a9eeda/lollipop_hypothesis-0.2-py2.py3-none-any.whl",
            "md5_digest": "69eb89e51151b8a70a2b6205cf77bce1",
            "downloads": 0,
            "filename": "lollipop_hypothesis-0.2-py2.py3-none-any.whl",
            "packagetype": "bdist_wheel",
            "path": "d2/23/3b7b5cc5ab64cc096c4bcc61e15b7a91d14ba14f0d9f95267a1074a9eeda/lollipop_hypothesis-0.2-py2.py3-none-any.whl",
            "size": 7140
        }
    ],
    "cheesecake_installability_id": null,
    "coveralls": true
}
        
Elapsed time: 0.06481s