{ "info": { "author": "Tilman Blumenbach", "author_email": "tilman+pypi@ax86.net", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Testing" ], "description": "datadir-ng plugin for pytest |pypi-badge|\n=========================================\n\nThe ``datadir-ng`` plugin for pytest_ provides the ``datadir``\nand ``datadir_copy`` fixtures which allow test functions to easily access resources\nin data directories. It was inspired by the `pytest-datadir plugin`_ and is intended\nto be a more flexible version of that plugin (hence the \"ng\" part in its name -- as\nin \"next generation\").\n\nThis plugin provides two fixtures:\n\n- The datadir_ fixture allows test functions and methods to access resources in\n so-called \"data directories\".\n- The `datadir_copy`_ fixture is similar to the datadir_ fixture, but it copies the\n requested resources to a temporary directory first so that test functions or\n methods can modify their resources on-disk without affecting other test functions\n and methods.\n\nInstallation\n------------\n\nJust do::\n\n pip install pytest-datadir-ng\n\n.. _datadir:\n\nThe datadir fixture\n-------------------\n\nThe \"datadir\" fixture allows test functions and methods to access resources in\nso-called \"data directories\".\n\nThe fixture behaves like a dictionary. Currently, only retrieving items using the\n``d[key]`` syntax is supported. Things like iterators, ``len(d)`` etc. are not.\n\nHow the fixture looks for resources is best described by an example.\nLet us assume the following directory structure for your tests::\n\n tests/\n +-- test_one.py\n +-- test_two.py\n +-- data/\n | +-- global.dat\n +-- test_one/\n | +-- test_func/\n | +-- data.txt\n +-- test_two/\n +-- TestClass/\n +-- test_method/\n +-- strings.prop\n\nThe file ``test_one.py`` contains the following function:\n\n.. code:: python\n\n def test_func(datadir):\n data_path = datadir[\"data.txt\"]\n\n # ...\n\nThe file ``test_two.py`` contains the following class:\n\n.. code:: python\n\n class TestClass(object):\n def test_method(self, datadir):\n strings_path = datadir[\"strings.prop\"]\n\n # ...\n\nWhen the ``test_func()`` function asks for the ``data.txt`` resource, the\nfollowing directories are searched for a file or directory named ``data.txt``,\nin this order:\n\n- ``tests/test_one/test_func/``\n- ``tests/test_one/``\n- ``tests/data/test_one/test_func/``\n- ``tests/data/test_one/``\n- ``tests/data/``\n\nThe path to the first existing file (or directory) is returned as a\npy.path.local_ object. In this case, the returned path would be\n``tests/test_one/test_func/data.txt``.\n\nWhen the ``test_method()`` method asks for the ``strings.prop`` resource,\nthe following directories are searched for a file or directory with the name\n``strings.prop``, in this order:\n\n- ``tests/test_two/TestClass/test_method/``\n- ``tests/test_two/TestClass/``\n- ``tests/test_two/``\n- ``tests/data/test_two/TestClass/test_method/``\n- ``tests/data/test_two/TestClass/``\n- ``tests/data/test_two/``\n- ``tests/data/``\n\nHere, this would return the path\n``tests/test_two/TestClass/test_method/strings.prop``.\n\nAs you can see, the searched directory hierarchy is slighly different if a\n*method* instead of a *function* asks for a resource. This allows you to\nload different resources based on the name of the test class, if you wish.\n\nFinally, if a test function or test method would ask for a resource named\n``global.dat``, then the resulting path would be ``tests/data/global.dat``\nsince no other directory in the searched directory hierarchy contains\na file named ``global.dat``. In other words, the ``tests/data/`` directory\nis the place for global (or fallback) resources.\n\nIf a resource cannot be found in *any* of the searched directories, a\n`KeyError` is raised.\n\n.. _datadir_copy:\n\nThe datadir_copy fixture\n------------------------\n\nThe \"datadir_copy\" fixture is similar to the datadir_ fixture, but copies the requested resources to a\ntemporary directory first so that test functions or methods can modify their resources on-disk without affecting\nother test functions and methods.\n\nEach test function or method gets its own temporary directory and thus its own fresh copies of the resources it\nrequests.\n\n**Caveat:** Each time a resource is requested using the dictionary notation, a fresh copy of the resource is made.\nThis also applies if a test function or method requests the same resource multiple times. Thus, if you modify a\nresource and need to access the *modified* version of the resource later, save its path in a variable and use that\nvariable to access the resource later instead of using the dictionary notation multiple times:\n\n.. code:: python\n\n def test_foo(datadir_copy):\n # This creates the initial fresh copy of data.txt and saves\n # its path in the variable \"resource1\".\n resource1 = datadir_copy[\"data.txt\"]\n\n # ...modify resource1 on-disk...\n\n # You now want to access the modified version of data.txt.\n\n # WRONG way: This will overwrite your modified version of the\n # resource with a fresh copy!\n fh = datadir_copy[\"data.txt\"].open(\"rb\")\n\n # CORRECT way: This will let you access the modified version\n # of the resource.\n fh = resource1.open(\"rb\")\n\nVersion history\n---------------\n\nVersion 1.1.0\n+++++++++++++\n\n- Allow per-test directories under ``data/`` (thanks, Alexander Lukanin).\n\nVersion 1.0.1\n+++++++++++++\n\n- Added this `Version history`_ section. :-)\n- Fixed bad usage of py.path.local_ objects in code examples.\n\nVersion 1.0.0\n+++++++++++++\n\n- Initial release\n\n\n..\n NB: Without a trailing question mark in the following image URL, the\n generated HTML will contain an element instead of an \n element, which apparently cannot be made into a link (i. e. a\n \"clickable\" image).\n.. |pypi-badge| image:: https://img.shields.io/pypi/v/pytest-datadir-ng.svg?\n :align: middle\n :target: https://pypi.python.org/pypi/pytest-datadir-ng\n\n.. _pytest: http://pytest.org/\n.. _pytest-datadir plugin: https://github.com/gabrielcnr/pytest-datadir\n.. _py.path.local: http://pylib.readthedocs.org/en/latest/path.html", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Tblue/pytest-datadir-ng", "keywords": "py.test resources files data directory directories", "license": "BSD 3-Clause License", "maintainer": "", "maintainer_email": "", "name": "pytest-datadir-ng", "package_url": "https://pypi.org/project/pytest-datadir-ng/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pytest-datadir-ng/", "project_urls": { "Homepage": "https://github.com/Tblue/pytest-datadir-ng" }, "release_url": "https://pypi.org/project/pytest-datadir-ng/1.1.0/", "requires_dist": [ "pytest" ], "requires_python": "", "summary": "Fixtures for pytest allowing test functions/methods to easily retrieve test resources from the local filesystem.", "version": "1.1.0" }, "last_serial": 2093504, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "6d7c0de9c69ce78f12d432e6ad8303ff", "sha256": "7a8ddec86b929779ed781576d27d28181c0fee30d17b889fcc27a32b0b727304" }, "downloads": -1, "filename": "pytest_datadir_ng-1.0.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "6d7c0de9c69ce78f12d432e6ad8303ff", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9149, "upload_time": "2015-12-26T21:37:20", "url": "https://files.pythonhosted.org/packages/9f/84/1f4728484b7d5230e78953c6781f6287570fc133eba8bbe34292f8dc9321/pytest_datadir_ng-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38ed8afc7d6c82e6f62e24636e936991", "sha256": "e211de0c0090e636e4d09bd9c3c5a9e6462abbbcfa95752b3a9d91296448fe96" }, "downloads": -1, "filename": "pytest-datadir-ng-1.0.0.tar.gz", "has_sig": true, "md5_digest": "38ed8afc7d6c82e6f62e24636e936991", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5363, "upload_time": "2015-12-26T21:37:26", "url": "https://files.pythonhosted.org/packages/32/97/340f10e97db8d5c65b52d974bcd4a22f69407aec43785f4a7bd59f459378/pytest-datadir-ng-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "1e8e363e2e142c00b8a20bbf9ba0c048", "sha256": "0b130b33a5d427598458e157908c30d9c1b14d036b941773a9b744cd439019a6" }, "downloads": -1, "filename": "pytest_datadir_ng-1.0.1-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "1e8e363e2e142c00b8a20bbf9ba0c048", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9256, "upload_time": "2016-01-08T22:19:34", "url": "https://files.pythonhosted.org/packages/6b/91/b70e62c3abc554934393db8322c0abad527726418383998107c09d689922/pytest_datadir_ng-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "eb08121e2bb393a7eba71c242670f379", "sha256": "11859d8290375883e66377fac075c77e6dd6544f88cef31beed9ebdaa84ed986" }, "downloads": -1, "filename": "pytest-datadir-ng-1.0.1.tar.gz", "has_sig": true, "md5_digest": "eb08121e2bb393a7eba71c242670f379", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5453, "upload_time": "2016-01-08T22:19:44", "url": "https://files.pythonhosted.org/packages/a3/94/6ea8dc95b3a6effb6e290136bde72055cf9b454f7d47df5d1dba4f832f57/pytest-datadir-ng-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "5e9864404eea20c1885ce8d426146ee2", "sha256": "4f15158369338d1ed67a7ddc85a6cd0e597732018578186b30bcfd73373fc6ee" }, "downloads": -1, "filename": "pytest_datadir_ng-1.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "5e9864404eea20c1885ce8d426146ee2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9797, "upload_time": "2016-05-01T14:20:19", "url": "https://files.pythonhosted.org/packages/8d/1d/d9075251702d714e7b8b720065df9c765920ceb2e88c0b1ec44efe635ad8/pytest_datadir_ng-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36bf7e1d92e3c708e118df5d5b0c41ec", "sha256": "0d9aee98b5b69e1dc47aaa295469fd3cce8e4a1a0dadcfe24c257c821c46f4c9" }, "downloads": -1, "filename": "pytest-datadir-ng-1.1.0.tar.gz", "has_sig": true, "md5_digest": "36bf7e1d92e3c708e118df5d5b0c41ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6584, "upload_time": "2016-05-01T14:20:38", "url": "https://files.pythonhosted.org/packages/37/b6/a1d339a1915bc8460a57fec8b38fd1e0e1373035c7105acd7ccbef9bd4e0/pytest-datadir-ng-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5e9864404eea20c1885ce8d426146ee2", "sha256": "4f15158369338d1ed67a7ddc85a6cd0e597732018578186b30bcfd73373fc6ee" }, "downloads": -1, "filename": "pytest_datadir_ng-1.1.0-py2.py3-none-any.whl", "has_sig": true, "md5_digest": "5e9864404eea20c1885ce8d426146ee2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 9797, "upload_time": "2016-05-01T14:20:19", "url": "https://files.pythonhosted.org/packages/8d/1d/d9075251702d714e7b8b720065df9c765920ceb2e88c0b1ec44efe635ad8/pytest_datadir_ng-1.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "36bf7e1d92e3c708e118df5d5b0c41ec", "sha256": "0d9aee98b5b69e1dc47aaa295469fd3cce8e4a1a0dadcfe24c257c821c46f4c9" }, "downloads": -1, "filename": "pytest-datadir-ng-1.1.0.tar.gz", "has_sig": true, "md5_digest": "36bf7e1d92e3c708e118df5d5b0c41ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6584, "upload_time": "2016-05-01T14:20:38", "url": "https://files.pythonhosted.org/packages/37/b6/a1d339a1915bc8460a57fec8b38fd1e0e1373035c7105acd7ccbef9bd4e0/pytest-datadir-ng-1.1.0.tar.gz" } ] }