{ "info": { "author": "Dieter Maurer", "author_email": "dieter@handshake.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Zope2", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Utilities" ], "description": "This is a (still small) repository with mockup objects to be used\nin testsuites for Zope 2 applications and application components.\n\nzodb\n====\n\nUsually, the ZODB (Zope Object Database) handles persistency transparently.\nHowever, there are important exceptions: when a mutable attribute\nof a persistent object is modified via its methods, the ZODB does not\nknow about these modifications. Without special measures, such\nmodifications are not persisted or persisted non-deterministically.\nSuch persistency bugs are difficult to detect and, therefore, should\nbe explicitely tested against. This module defines a ZODB mockup\nconnection which facilitates such tests.\n\nThe mockup connection has the following special methods:\n\n``get_state`` (*obj*)\n return the current state of *obj* to be used later in ``verify_state``.\n\n As side effect, *obj* is registered with (added to) the connection\n (if necessary).\n\n``verify_state`` (*state*)\n *state* must have been obtained by a previous call to ``get_state``.\n The call verifies that all modifications to the respective *obj* or\n its subcomponents are correctly registered with the ZODB.\n It raises an ``AssertionError`` with relevant information about the\n failing persistent subobjects.\n\n As side effect, new persistent subobjects encountered during the\n verification are registered with (added to) the connection.\n\n Due to http://bugs.python.org/issue12596, this\n currently works unreliably: Python 2.7 has introduced a (minor)\n optimization which suppresses ``BINPUT`` pickle instructions\n in some (rare) cases. As ``verify_state`` compares the historical\n pickle and the current one in order to detect modifications, this\n bug lets see it changes where there are none. The current release\n tries to work around this problem by not comparing the pickles verbatim\n but checking for equivalence modulo ``*PUT`` operations. The\n implemented equivalence is not perfect (e.g. it does not\n recognize that ``dumps((\"spam\", \"spam\"), 2)`` and\n ``dumps((\"spaml\"[:-1], \"spaml\"[:-1]), 2)`` are equivalent) but\n it might be sufficient for practical use.\n\n``emulate_commit`` ()\n performs a savepoint which has similar effects as commit but\n will be undone by the next transaction abort.\n\nThe module's ``get_mockup_connection``() returns a mockup connection.\nBehind this is a ``DemoStorage`` (i.e. a storage storing its state in memory).\nIn fact, ``get_mockup_connection`` returns a singleton connection, [re]opened,\nassociated with its own ``TransactionManager`` in an aborted transaction.\n\nFollowing is typical test example:\n\n>>> # elementary setup\n... from persistent import Persistent\n>>> from dm.zope.mockup.zodb import get_mockup_connection\n>>> \n>>> class P(Persistent):\n... def __init__(self, id): self.id = id\n... # to get predictable output\n... def __repr__(self): return self.id\n... \n>>> # work around for \"python setup.py test\" peculiarity\n... import __builtin__; __builtin__.P = P\n>>>\n>>> c = get_mockup_connection()\n>>> obj = P('obj')\n\n>>> # normal attribute assignment\n... state = c.get_state(obj)\n>>> obj.l = []\n>>> c.verify_state(state)\n\n>>> # get_mockup_connection aborts the transaction\n... # in our case, it does not change the state of \"obj\" as\n... # this was newly created\n... obj._p_changed\nTrue\n>>> c = get_mockup_connection()\n>>> obj._p_changed\nFalse\n\n>>> # unregistered modification of mutable attribute\n... state = c.get_state(obj)\n>>> obj.l.append(1)\n>>> c.verify_state(state)\nTraceback (most recent call last):\n ...\nAssertionError: ('unregistered modifications', [obj])\n\n>>> # registered modification of mutable attribute\n... state = c.get_state(obj)\n>>> obj._p_changed = True\n>>> obj.l.append(1)\n>>> c.verify_state(state)\n\n>>> # the same works for persistent subobjects as well\n... c = get_mockup_connection()\n>>> \n>>> obj0 = P('obj0')\n>>> obj = obj0.obj = P('obj')\n>>> \n>>> state = c.get_state(obj0)\n>>> obj.l = []\n>>> c.verify_state(state)\n>>> c.emulate_commit()\n>>> \n>>> state = c.get_state(obj0)\n>>> obj.l.append(1)\n>>> c.verify_state(state)\nTraceback (most recent call last):\n ...\nAssertionError: ('unregistered modifications', [obj])\n>>>\n>>> state = c.get_state(obj0)\n>>> obj._p_changed = True\n>>> obj.l.append(1)\n>>> c.verify_state(state)", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://pypi.python.org/pypi/dm.zope.mockup", "keywords": "test mockup", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "dm.zope.mockup", "package_url": "https://pypi.org/project/dm.zope.mockup/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dm.zope.mockup/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://pypi.python.org/pypi/dm.zope.mockup" }, "release_url": "https://pypi.org/project/dm.zope.mockup/0.1.1.2/", "requires_dist": null, "requires_python": null, "summary": "A (still small) repository of mockup objects for Zope [2] tests.", "version": "0.1.1.2" }, "last_serial": 1396500, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "4cf6ba5bf9ccdff676e8f36d34f9ef94", "sha256": "2fc1e80338f45392c8827b9cb62a64b9a56290d10e0c6e71cbab38a5fb70df17" }, "downloads": -1, "filename": "dm.zope.mockup-0.1.tar.gz", "has_sig": false, "md5_digest": "4cf6ba5bf9ccdff676e8f36d34f9ef94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5054, "upload_time": "2010-08-10T11:42:52", "url": "https://files.pythonhosted.org/packages/19/eb/4a60ca7bac14c0ce01c40589f64974d6287150fe85ae209ee9723ff1db1d/dm.zope.mockup-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "8b651d8a5789e946f04ce1645d484538", "sha256": "020af631a6d6d83f0b0fc0643b6f0cce5a6b9c81d3cdc86917980e5600a9d241" }, "downloads": -1, "filename": "dm.zope.mockup-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8b651d8a5789e946f04ce1645d484538", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5111, "upload_time": "2010-08-11T09:47:52", "url": "https://files.pythonhosted.org/packages/f6/f3/13e390b904b11611c9f0d51d2ac3d3cec1be49e283c2d077ff056ec94f45/dm.zope.mockup-0.1.1.tar.gz" } ], "0.1.1.2": [ { "comment_text": "", "digests": { "md5": "4e388ad61687c3d76afcb06fd686ddaa", "sha256": "651021ff4f9a894847789e33778134500606046307a55c7c09a1b73a8ec7440f" }, "downloads": -1, "filename": "dm.zope.mockup-0.1.1.2.tar.gz", "has_sig": false, "md5_digest": "4e388ad61687c3d76afcb06fd686ddaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6122, "upload_time": "2015-01-26T08:27:13", "url": "https://files.pythonhosted.org/packages/14/25/872e85284cd1bcd4010379a0f57c41d43d3efc4ade10f21ae737a9cd8716/dm.zope.mockup-0.1.1.2.tar.gz" } ], "0.1.1p1": [ { "comment_text": "", "digests": { "md5": "b9771e4c51cb127acdd5b6510ef14b02", "sha256": "d62b1eaf833ad66599fddda1518ed8d1015983ba31f4751bbceed1431fc79f3d" }, "downloads": -1, "filename": "dm.zope.mockup-0.1.1p1.tar.gz", "has_sig": false, "md5_digest": "b9771e4c51cb127acdd5b6510ef14b02", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5322, "upload_time": "2013-10-22T09:52:58", "url": "https://files.pythonhosted.org/packages/e0/13/9584f43dea39f4d140471b706d42d6356bac488c7c75d8081fc728e2145a/dm.zope.mockup-0.1.1p1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4e388ad61687c3d76afcb06fd686ddaa", "sha256": "651021ff4f9a894847789e33778134500606046307a55c7c09a1b73a8ec7440f" }, "downloads": -1, "filename": "dm.zope.mockup-0.1.1.2.tar.gz", "has_sig": false, "md5_digest": "4e388ad61687c3d76afcb06fd686ddaa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6122, "upload_time": "2015-01-26T08:27:13", "url": "https://files.pythonhosted.org/packages/14/25/872e85284cd1bcd4010379a0f57c41d43d3efc4ade10f21ae737a9cd8716/dm.zope.mockup-0.1.1.2.tar.gz" } ] }