equals


Nameequals JSON
Version 3.1.1 PyPI version JSON
download
home_pagehttps://github.com/smartfastlabs/equals
SummaryFuzzy Mock objects for testing
upload_time2024-02-15 02:35:42
maintainerTodd Sifleet
docs_urlNone
authorTodd Sifleet
requires_python>=3.9,<4.0
licenseMIT
keywords testing mocks mocking stubs stubbing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            A mock equality tool for testing
================================

.. image:: https://badge.fury.io/py/equals.svg
    :target: https://badge.fury.io/py/equals

.. image:: https://readthedocs.org/projects/equals/badge/?version=latest
    :target: https://equals.readthedocs.io/en/latest/?badge=latest

.. image:: https://coveralls.io/repos/github/smartfastlabs/equals/badge.svg?branch=master
    :target: https://coveralls.io/github/smartfastlabs/equals?branch=master


tl;dr Equals is a stricter version of
`Mock.Any <http://www.voidspace.org.uk/python/mock/helpers.html#any>`__.

Equals allows you to assert certain equality constraints between python
objects during testing. There are times where we don't want to assert
absolute equality, e.g. we need to ensure two lists have the same
elements, but don't care about order.  This was designed specifically for
usage with `Mock <https://pypi.python.org/pypi/mock>`_ and `dobles <https://github.com/smartfastlabs/dobles>`_.

API
===
**Full Documentation is available at http://equals.readthedocs.org/en/latest/.**

strings:
--------

::

    from equals import any_string

    any_string.containing('abc') == '123 abc 456'
    any_string.starting_with('abc') == 'abcdef'
    any_string.ending_with('abc') == '123abc'
    any_string.matching('^abc$') == 'abc'

numbers:
--------

::

    from equals import any_number

    any_number.less_than(5) == 4
    any_number.less_than_or_equal_to(5) == 5
    any_number.greater_than(4) == 5
    any_number.greater_than_or_equal_to(5) == 5
    any_number.between(1, 3) == 2

dictionaries:
-------------

::

    from equals import any_dict

    any_dict.containing(1, 2) == {1: 2, 2:3, 4:5}
    any_dict.containing(foo='bar') == {
        'foo': 'bar',
        'bob': 'barker'
    }
    any_dict.not_containing(1, foo=5) == {'foo':3, 4:5}

iterators:
----------

::

    from equals import any_iterable

    any_iterable.containing(1, 2, 3) == [1, 2, 3, 4, 5]
    any_iterable.containing_only(1, 2, 3) == [2, 3, 1]
    any_iterable.not_containing(1, 2) == [3, 4]
    any_iterable.with_length(2) == [3, 4]

objects:
--------

::

    from equals import anything

    anything == None
    anything == True
    anything == {1: 1}
    anything_true == 'dd'
    anything_false == ''

    instance_of(dict) == {}
    anything.with_attrs(foo='bar', bob='barker') == Dummy('bar', 'barker')
    instance_of(Dummy).with_attrs(foo='bar', bob='barker') == Dummy('bar', 'barker')


With Mock:
----------

::

    from mock import Mock
    from equals import any_dict

    test_object = Mock()
    test_object.method({'bob': 'barker'})
    test_object.method.assert_called_with(any_dict)

dobles:
-------

::

    from dobles import expect
    from equals import any_string


    class TestClass(object):
        def method(self, arg):
            return arg


    test_object = TestClass()
    expect(test_object).method.with_args(any_string.containing('bob'))

    test_object.method('bob barker')


Installation:
-------------

::

    >> pip install equals


Development
-----------

Source code is available at https://github.com/smartfastlabs/equals.

To install the dependencies on a fresh clone of the repository, run ``make bootstrap``.

To run the test suite, run ``make test``.

To build the documentation locally, run ``make docs``.


License
-------

MIT: http://opensource.org/licenses/MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/smartfastlabs/equals",
    "name": "equals",
    "maintainer": "Todd Sifleet",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "todd@smartfast.com",
    "keywords": "testing,mocks,mocking,stubs,stubbing",
    "author": "Todd Sifleet",
    "author_email": "todd@smartfast.com",
    "download_url": "https://files.pythonhosted.org/packages/67/a2/e3663adcf20e75cff857b25bb6adb2c8089f8e1a961deafa39b7cfcdff00/equals-3.1.1.tar.gz",
    "platform": null,
    "description": "A mock equality tool for testing\n================================\n\n.. image:: https://badge.fury.io/py/equals.svg\n    :target: https://badge.fury.io/py/equals\n\n.. image:: https://readthedocs.org/projects/equals/badge/?version=latest\n    :target: https://equals.readthedocs.io/en/latest/?badge=latest\n\n.. image:: https://coveralls.io/repos/github/smartfastlabs/equals/badge.svg?branch=master\n    :target: https://coveralls.io/github/smartfastlabs/equals?branch=master\n\n\ntl;dr Equals is a stricter version of\n`Mock.Any <http://www.voidspace.org.uk/python/mock/helpers.html#any>`__.\n\nEquals allows you to assert certain equality constraints between python\nobjects during testing. There are times where we don't want to assert\nabsolute equality, e.g. we need to ensure two lists have the same\nelements, but don't care about order.  This was designed specifically for\nusage with `Mock <https://pypi.python.org/pypi/mock>`_ and `dobles <https://github.com/smartfastlabs/dobles>`_.\n\nAPI\n===\n**Full Documentation is available at http://equals.readthedocs.org/en/latest/.**\n\nstrings:\n--------\n\n::\n\n    from equals import any_string\n\n    any_string.containing('abc') == '123 abc 456'\n    any_string.starting_with('abc') == 'abcdef'\n    any_string.ending_with('abc') == '123abc'\n    any_string.matching('^abc$') == 'abc'\n\nnumbers:\n--------\n\n::\n\n    from equals import any_number\n\n    any_number.less_than(5) == 4\n    any_number.less_than_or_equal_to(5) == 5\n    any_number.greater_than(4) == 5\n    any_number.greater_than_or_equal_to(5) == 5\n    any_number.between(1, 3) == 2\n\ndictionaries:\n-------------\n\n::\n\n    from equals import any_dict\n\n    any_dict.containing(1, 2) == {1: 2, 2:3, 4:5}\n    any_dict.containing(foo='bar') == {\n        'foo': 'bar',\n        'bob': 'barker'\n    }\n    any_dict.not_containing(1, foo=5) == {'foo':3, 4:5}\n\niterators:\n----------\n\n::\n\n    from equals import any_iterable\n\n    any_iterable.containing(1, 2, 3) == [1, 2, 3, 4, 5]\n    any_iterable.containing_only(1, 2, 3) == [2, 3, 1]\n    any_iterable.not_containing(1, 2) == [3, 4]\n    any_iterable.with_length(2) == [3, 4]\n\nobjects:\n--------\n\n::\n\n    from equals import anything\n\n    anything == None\n    anything == True\n    anything == {1: 1}\n    anything_true == 'dd'\n    anything_false == ''\n\n    instance_of(dict) == {}\n    anything.with_attrs(foo='bar', bob='barker') == Dummy('bar', 'barker')\n    instance_of(Dummy).with_attrs(foo='bar', bob='barker') == Dummy('bar', 'barker')\n\n\nWith Mock:\n----------\n\n::\n\n    from mock import Mock\n    from equals import any_dict\n\n    test_object = Mock()\n    test_object.method({'bob': 'barker'})\n    test_object.method.assert_called_with(any_dict)\n\ndobles:\n-------\n\n::\n\n    from dobles import expect\n    from equals import any_string\n\n\n    class TestClass(object):\n        def method(self, arg):\n            return arg\n\n\n    test_object = TestClass()\n    expect(test_object).method.with_args(any_string.containing('bob'))\n\n    test_object.method('bob barker')\n\n\nInstallation:\n-------------\n\n::\n\n    >> pip install equals\n\n\nDevelopment\n-----------\n\nSource code is available at https://github.com/smartfastlabs/equals.\n\nTo install the dependencies on a fresh clone of the repository, run ``make bootstrap``.\n\nTo run the test suite, run ``make test``.\n\nTo build the documentation locally, run ``make docs``.\n\n\nLicense\n-------\n\nMIT: http://opensource.org/licenses/MIT\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fuzzy Mock objects for testing",
    "version": "3.1.1",
    "project_urls": {
        "Homepage": "https://github.com/smartfastlabs/equals",
        "Repository": "https://github.com/smartfastlabs/equals"
    },
    "split_keywords": [
        "testing",
        "mocks",
        "mocking",
        "stubs",
        "stubbing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7cb7d0d351aedf7acdf295b0bda8766572d695c6af815cb2c53c4f8b7bed85da",
                "md5": "bf7faa38a5f8c364bee2667ae4a5829c",
                "sha256": "8558efb1eee7c8a097b9c50d5b52d34a658fa5189c3fdd339af4bc1c27efc5f2"
            },
            "downloads": -1,
            "filename": "equals-3.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf7faa38a5f8c364bee2667ae4a5829c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9,<4.0",
            "size": 10747,
            "upload_time": "2024-02-15T02:35:40",
            "upload_time_iso_8601": "2024-02-15T02:35:40.858102Z",
            "url": "https://files.pythonhosted.org/packages/7c/b7/d0d351aedf7acdf295b0bda8766572d695c6af815cb2c53c4f8b7bed85da/equals-3.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67a2e3663adcf20e75cff857b25bb6adb2c8089f8e1a961deafa39b7cfcdff00",
                "md5": "8d4268124f450e8ce1aa526af4d42958",
                "sha256": "cac467ecd64505e57cb528f5191ee28cad125a0e8dee7cd6715f461f80dd69aa"
            },
            "downloads": -1,
            "filename": "equals-3.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8d4268124f450e8ce1aa526af4d42958",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 6839,
            "upload_time": "2024-02-15T02:35:42",
            "upload_time_iso_8601": "2024-02-15T02:35:42.303846Z",
            "url": "https://files.pythonhosted.org/packages/67/a2/e3663adcf20e75cff857b25bb6adb2c8089f8e1a961deafa39b7cfcdff00/equals-3.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-15 02:35:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "smartfastlabs",
    "github_project": "equals",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "equals"
}
        
Elapsed time: 0.42028s