{ "info": { "author": "Yukihiko Shinoda", "author_email": "yuk.hik.future@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Fixture File Handler\n\nThis project helps you to vacate specific file path or deploy resource file into specific file path when unit testing.\n\n## Context\n\nThe most popular setup / teardown tasks about file system on unit testing is\nalmost 2 kinds.\n\n1. vacate specific file path for testing file export function\n2. deploy fixture file / directory into specific file path for testing file import /export function\n\nThen we have to think about how to back up existing file / directory between unit testing\nbecause maybe developer wants to keep those handwritten files for development.\n\n`Fixture File Handler` is framework to realize simply implement\nthe vacate and deploy actions while keeping the existing files.\nOf course, even if there is no file in the target path, it works fine.\n\n## Ubiquitous Language\n\n### target\n\nThe target file path to vacate or deploy file / directory for unit testing.\n\n### backup\n\nThe file path to back up existing file / directory on target file path between unit testing.\n\n### resource\n\nThe file / directory you want to deploy and let product code read / write in unit testing.\nIt may test resource file or template file like `*.dist` file.\n\n## Basic behavior\n\n### Vacator\n\ntarget path|backup path\n---|---\nexisting file /dir| \n\n\u2193 setup\n\ntarget path|backup path\n---|---\n |existing file / dir\n\n\u2193 teardown\n\ntarget path|backup path\n---|---\nexisting file / dir| \n\n\n### Deployer\n\ntarget path|backup path|resource path\n---|---|---\nexisting file / dir| |resource file / dir\n\n\u2193 setup\n\ntarget path|backup path|resource path\n---|---|---\nresource file / dir|existing file /dir|resource file / dir\n\n\u2193 teardown\n\ntarget path|backup path|resource path\n---|---|---\nexisting file / dir| |resource file / dir\n\n\n### Common behavior\n\nIf file / directory already exists on backup path,\nsetup raise `BackupAlreadyExistError`\nbecause it's unexpected situation and developer may want to resque those backup files.\n\n## Quickstart\n\n#### 1. Install\n`pip install fixturefilehandler`\n\n#### 2-1. Case when unittest: implement setUp() and doCleanups()\n\n```python\nfrom pathlib import Path\nimport unittest\n\nfrom fixturefilehandler.factories import VacatorFactory\nfrom fixturefilehandler.file_paths import RelativeVacateFilePath\n\nVACATOR = VacatorFactory.create(\n RelativeVacateFilePath(\n Path('test.txt'),\n Path('test.txt.bak'),\n Path(__file__).parent\n )\n)\n\n\nclass ConfigurableTestCase(unittest.TestCase):\n def setUp(self):\n VACATOR.setup()\n\n def doCleanups(self):\n VACATOR.teardown()\n```\n\n#### 2-2. Case when pytest: implement fixture\n\n```python\nfrom pathlib import Path\nimport pytest\n\nfrom fixturefilehandler.factories import DeployerFactory\nfrom fixturefilehandler.file_paths import RelativeDeployFilePath\n\nDEPLOYER = DeployerFactory.create(\n RelativeDeployFilePath(\n Path('test.txt'),\n Path('test.txt.bak'),\n Path('testresources/test.txt.dist'),\n Path(__file__).parent\n )\n)\n\n\n@pytest.fixture\ndef fixture_file():\n DEPLOYER.setup()\n yield DEPLOYER.FILE_PATH\n DEPLOYER.teardown()\n\n\ndef test_something(fixture_file):\n \"\"\"test something\"\"\"\n```\n\n## API\n\n### file_paths\n\n#### SimpleVacateFilePath\n\nThis instance holds path to target and backup.\nEach path is independent each other.\n\n#### SimpleDeployFilePath\n\nThis instance holds path to target, backup, and resource.\nEach path is independent each other.\n\n#### RelativeVacateFilePath\n\nThis instance holds path to target, backup, and base.\nEach path is relative based on base path.\n\n#### RelativeDeployFilePath\n\nThis instance holds path to target, backup, resource, and base.\nEach path is relative based on base path.\n\n## How do I...\n\n### Use different paths for each test?\n\n`setup()` and `teardown()` also accept file_paths argument.\n\nCase when unittest:\n\n```python\nfrom pathlib import Path\n\nimport unittest\n\nfrom fixturefilehandler import ResourceFileDeployer\nfrom fixturefilehandler.file_paths import RelativeDeployFilePath\n\n\nclass AdvancedConfigurableTestCase(unittest.TestCase):\n @property\n def file_path(self) -> RelativeDeployFilePath:\n return RelativeDeployFilePath(\n Path('test.txt'),\n Path('test.txt.bak'),\n Path(f'testresources/{self._testMethodName}.txt'),\n Path(__file__).parent\n )\n\n def setUp(self):\n ResourceFileDeployer.setup(self.file_path)\n\n def doCleanups(self):\n ResourceFileDeployer.teardown(self.file_path)\n```\n\nCase when pytest:\n\n```python\nfrom pathlib import Path\n\nimport pytest\n\nfrom fixturefilehandler import ResourceFileDeployer\nfrom fixturefilehandler.file_paths import RelativeDeployFilePath\n\n\n@pytest.fixture\ndef fixture_file_advanced(request):\n file_path = RelativeDeployFilePath(\n Path('test.txt'),\n Path('test.txt.bak'),\n Path(f'testresources/{request.node.name}.txt'),\n Path(__file__).parent\n )\n\n ResourceFileDeployer.setup(file_path)\n yield file_path\n ResourceFileDeployer.teardown(file_path)\n\n\ndef test_something(fixture_file_advanced):\n \"\"\"test something\"\"\"\n```\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/yukihiko-shinoda/fixture-file-handler", "keywords": "fixture file vacate deploy unittest pytest testing", "license": "", "maintainer": "", "maintainer_email": "", "name": "fixturefilehandler", "package_url": "https://pypi.org/project/fixturefilehandler/", "platform": "", "project_url": "https://pypi.org/project/fixturefilehandler/", "project_urls": { "Homepage": "https://github.com/yukihiko-shinoda/fixture-file-handler" }, "release_url": "https://pypi.org/project/fixturefilehandler/1.2.0/", "requires_dist": null, "requires_python": ">3.6.0", "summary": "This project helps you to vacate specific file path or deploy resource file into specific file path when unit testing.", "version": "1.2.0" }, "last_serial": 5564106, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "6f21418a4383f2996a052872b2f1902f", "sha256": "47d72b41a4f8c9708a4c2c3b060e342084e371407d489b61b39ba985e5994a89" }, "downloads": -1, "filename": "fixturefilehandler-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "6f21418a4383f2996a052872b2f1902f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5231, "upload_time": "2019-07-09T13:39:59", "url": "https://files.pythonhosted.org/packages/ab/76/295b97bd06999db686d714ff503defe0f51e8be29119b518bb1ee4e8b067/fixturefilehandler-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "94083af2a424e12227e612132bd1bd68", "sha256": "1878efdab6ade4c0d9293fdb720fd4fc366d6f12fc08338140338cc5a2ac5883" }, "downloads": -1, "filename": "fixturefilehandler-1.0.0.tar.gz", "has_sig": false, "md5_digest": "94083af2a424e12227e612132bd1bd68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4530, "upload_time": "2019-07-09T13:40:02", "url": "https://files.pythonhosted.org/packages/e0/0d/96d05aa43d3cf3952bb74a031e6fd4fa93d610f7e0ef5be14773c7fcfaf1/fixturefilehandler-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "c65b78722d6285f273063eca8f5b05ff", "sha256": "b6fcd6997775bdd350673da097c571f17205921c611b437dd2ddb6fb88f0808b" }, "downloads": -1, "filename": "fixturefilehandler-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c65b78722d6285f273063eca8f5b05ff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5500, "upload_time": "2019-07-15T04:26:33", "url": "https://files.pythonhosted.org/packages/0d/71/f01c8e2969771a3aa9582e2181fb101de51c449b3c4acb2d4978cd44299d/fixturefilehandler-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "47e3bbec81119b080b53ba3ff61ac93c", "sha256": "2beebaf1939ebdd0331049c058c26691a7ce2900712c69c7d8eeda3719e10894" }, "downloads": -1, "filename": "fixturefilehandler-1.1.0.tar.gz", "has_sig": false, "md5_digest": "47e3bbec81119b080b53ba3ff61ac93c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4668, "upload_time": "2019-07-15T04:26:35", "url": "https://files.pythonhosted.org/packages/52/e2/3deb8bb1a8306f678e8244ec0baef15bc8a775d5327d471ac6fb4e768d26/fixturefilehandler-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "f2de7023ad6ba5569549ffa4e46ff3ef", "sha256": "df2961f57f32d59615f27a69c032786fc5a910e737d82c30b465bd66b9d17b59" }, "downloads": -1, "filename": "fixturefilehandler-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f2de7023ad6ba5569549ffa4e46ff3ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6.0", "size": 5632, "upload_time": "2019-07-21T18:34:16", "url": "https://files.pythonhosted.org/packages/71/7e/a4151b48e94eebd39e9375e1e052150d01f9ffe775c270b7c50449e743b2/fixturefilehandler-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "14e6a9ffc1bd8b6738e1912d0994d67e", "sha256": "870ebdbf7669fc778aa7f37e631a488757a651e73fe58c184f3e79c220266f69" }, "downloads": -1, "filename": "fixturefilehandler-1.2.0.tar.gz", "has_sig": false, "md5_digest": "14e6a9ffc1bd8b6738e1912d0994d67e", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6.0", "size": 4825, "upload_time": "2019-07-21T18:34:18", "url": "https://files.pythonhosted.org/packages/65/f6/459db7bda62b12e1ee7bb0cff804815a82930412519fb529fb13c6f5660f/fixturefilehandler-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f2de7023ad6ba5569549ffa4e46ff3ef", "sha256": "df2961f57f32d59615f27a69c032786fc5a910e737d82c30b465bd66b9d17b59" }, "downloads": -1, "filename": "fixturefilehandler-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "f2de7023ad6ba5569549ffa4e46ff3ef", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">3.6.0", "size": 5632, "upload_time": "2019-07-21T18:34:16", "url": "https://files.pythonhosted.org/packages/71/7e/a4151b48e94eebd39e9375e1e052150d01f9ffe775c270b7c50449e743b2/fixturefilehandler-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "14e6a9ffc1bd8b6738e1912d0994d67e", "sha256": "870ebdbf7669fc778aa7f37e631a488757a651e73fe58c184f3e79c220266f69" }, "downloads": -1, "filename": "fixturefilehandler-1.2.0.tar.gz", "has_sig": false, "md5_digest": "14e6a9ffc1bd8b6738e1912d0994d67e", "packagetype": "sdist", "python_version": "source", "requires_python": ">3.6.0", "size": 4825, "upload_time": "2019-07-21T18:34:18", "url": "https://files.pythonhosted.org/packages/65/f6/459db7bda62b12e1ee7bb0cff804815a82930412519fb529fb13c6f5660f/fixturefilehandler-1.2.0.tar.gz" } ] }