{ "info": { "author": "Oliver Cope", "author_email": "oliver@redgecko.org", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Topic :: Software Development :: Testing" ], "description": "tms: Test Match Special\r\n=======================\r\n\r\ntms lets you test values in test code, where you may not be able to test\r\nagainst an exact, known value.\r\n\r\nSome quick examples:\r\n\r\nTest an object's class and instance attributes::\r\n\r\n assert zoo.get('elephant') == tms.InstanceOf(Elephant, name='nelly')\r\n\r\nMatch data structures::\r\n\r\n assert resultset.any() == {'id': tms.InstanceOf(int),\r\n 'name': tms.Contains('bob'),\r\n 'data': tms.Anything()}\r\n\r\nCommon types have shortcuts, eg::\r\n\r\n tms.Bool()\r\n tms.Str()\r\n tms.Unicode()\r\n tms.Bytes()\r\n tms.Int()\r\n tms.Float()\r\n\r\nTest for in / not in::\r\n\r\n assert 'business' == tms.Contains('sin')\r\n assert 'my lunch' == tms.DoesntContain('nuts')\r\n\r\nTest attributes::\r\n\r\n assert Circle(1) == tms.InstanceOf(Circle, radius=1)\r\n\r\n assert Circle(1) == tms.InstanceOf(Circle, radius=tms.InstanceOf(int))\r\n\r\n assert Circle(1) == tms.InstanceOf(Circle, has_attrs=['radius'])\r\n\r\n\r\nTest for arbitrary conditions::\r\n\r\n assert 1 == tms.Int(lambda x: x > 0)\r\n assert Circle(1) == tms.InstanceOf(Circle, lambda x: x.radius == 1)\r\n\r\n\r\nTest dictionaries or dict-like objects::\r\n\r\n # Check that it contains keys and values\r\n assert {'x': 1} == tms.DictLike(x=1)\r\n\r\n # Check that it contains certain keys\r\n assert dict(x=1, y=2) == tms.Contains('x', 'y')\r\n\r\n # Check that it doesn't contain certain keys\r\n assert dict(x=1, y=2) == tms.DoesntContain('foo', 'bar')\r\n\r\n\r\nCombining tests::\r\n\r\n assert mylunch == tms.InstanceOf(Sandwich) & tms.DoesntContain(cheese)\r\n\r\n\r\nUnlike `hamcrest `_, tms uses the\r\n``__eq__`` method to evaluate comparisons. This means it works with python's\r\nbuilt in assert statement. This also means it works well with other test\r\nlibraries: you can drop a ``tms.Matcher`` object into any regular equality\r\ntest and have it work.\r\n\r\nNote that this also means that it may not work for objects that override\r\nthe __eq__ method. If the matcher doesn't seem to be firing, try putting it on\r\nthe left hand side of the comparison::\r\n\r\n >>> import tms\r\n >>> class MySpecialObject(object):\r\n ... def __eq__(self, other):\r\n ... return False\r\n ...\r\n >>> MySpecialObject() == tms.Anything()\r\n False\r\n >>> tms.Anything() == MySpecialObject()\r\n True\r\n\r\n\r\nCHANGELOG\r\n=========\r\n\r\n0.1.2 (released 2015-09-01)\r\n---------------------------\r\n\r\n- Added shortcuts for common builtin types, so you can now write ``tms.Int()``\r\n instead of ``tms.InstanceOf(int)``.\r\n\r\n- Added ``tms.Passes``. This takes an arbitrary function that is expected\r\n to return a boolean,\r\n eg ``assert random.randrange(1, 3) == tms.Passes(lambda x: 1 <= x < 3)``.\r\n This is integrated with ``tms.InstanceOf`` and ``tms.Anything``,\r\n so you can write eg\r\n ``tms.InstanceOf(MyClass, lambda x: x.name.startswith('foo'))``.\r\n\r\n0.1.1\r\n-----\r\n\r\n- Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/ollyc/tms", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "tms", "package_url": "https://pypi.org/project/tms/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tms/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://bitbucket.org/ollyc/tms" }, "release_url": "https://pypi.org/project/tms/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Test match special: fuzzy value matching for test assertions", "version": "0.1.2" }, "last_serial": 1926930, "releases": { "0": [], "0.1.1": [ { "comment_text": "", "digests": { "md5": "fbee0b5e37a746c51c1df6f384c59e7e", "sha256": "43282c68217a28e011c76cc39aa5f7ce20ecaa0b9fba5b59b43963c412812887" }, "downloads": -1, "filename": "tms-0.1.1.tar.gz", "has_sig": false, "md5_digest": "fbee0b5e37a746c51c1df6f384c59e7e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3904, "upload_time": "2013-05-25T15:20:07", "url": "https://files.pythonhosted.org/packages/75/15/ec400020cdad7214eff2dfa5eb9cd29d123372e9c3449791813a8681499c/tms-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "7a611af88bb3001168c43752a0c4be55", "sha256": "ab53400a0266f93feb78cc4fdf0edf2e7720797caa6cc4f521453f54243bc40c" }, "downloads": -1, "filename": "tms-0.1.2.tar.gz", "has_sig": false, "md5_digest": "7a611af88bb3001168c43752a0c4be55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4631, "upload_time": "2015-09-01T15:26:28", "url": "https://files.pythonhosted.org/packages/1b/f9/8da51becccbf8992192070e5fb2c0692693b3ab147bc5f7c9dc2a0746a9a/tms-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7a611af88bb3001168c43752a0c4be55", "sha256": "ab53400a0266f93feb78cc4fdf0edf2e7720797caa6cc4f521453f54243bc40c" }, "downloads": -1, "filename": "tms-0.1.2.tar.gz", "has_sig": false, "md5_digest": "7a611af88bb3001168c43752a0c4be55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4631, "upload_time": "2015-09-01T15:26:28", "url": "https://files.pythonhosted.org/packages/1b/f9/8da51becccbf8992192070e5fb2c0692693b3ab147bc5f7c9dc2a0746a9a/tms-0.1.2.tar.gz" } ] }