{ "info": { "author": "Felipe A. Hernandez", "author_email": "ergoithz@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Topic :: Software Development :: Testing :: Unit" ], "description": "# unittest-resources\n\nDynamic resource-based unittest suites made easy.\n\nOnline documentation available at .\n\n## Usage\n\nFirst and foremost, add this package as a project dependency on your\n`setup.py`.\n\n```python\n\nfrom setuptools import setup\n\nsetup(\n name='mymodule',\n # ...\n test_suite='tests',\n tests_require=['unittest-resources'],\n #...\n )\n\n```\n\nThat said, this module can be used in three ways:\n* [`unittest_resources.ResourceTestCase` base class](#unittest_resources.ResourceTestCase)\n* [`unittest_resources.ResourceTestMeta` metaclass](#unittest_resources.ResourceTestMeta)\n* [`unittest_resources.testing` tool integrations](#unittest_resources.testing)\n\nAnd then you can run your tests as usual.\n\n```sh\npython setup.py test\n```\n\nRemember you still have to include your testing dependencies by yourself\n(like [pycodestyle](https://pypi.org/project/pycodestyle/),\n[pydocstyle](https://pypi.org/project/pydocstyle/),\n[mypy](https://pypi.org/project/mypy/) or\n[radon](https://pypi.org/project/radon/)) even if they're used only\nthrough this package.\n\nOther option, if you feel comfortable about installing all\n**unittest-resources** optional dependencies (ie. especially if you're\nusing all classes defined on `unittest_resources.testing`), is to\nspecify `unittest-resources[testing]` as dependency.\n\n### Using `unittest_resources.ResourceTestCase` base class\n\nWith `unittest_resources.ResourceTestCase` your base (replacing\n`unittest.TestCase`).\n\n```python\n\nimport unittest_resources\n\n\nclass MyTestCase(unittest_resources.ResourceTestCase):\n \"\"\"\n TestCase class with tests autogenerated based on resources.\n\n This regular :class:`unittest.TestCase`-derived class generates\n test methods by recursively inspecting a module for resources,\n based on special class attributes (prefixed by `meta_`).\n\n The following functions from :mod:`importlib.resources` are\n available as :class:`staticmethod`s:\n - :func:`importlib.resources.contents` as `contents`\n - :func:`importlib.resources.is_resource` as `is_resource`\n - :func:`importlib.resources.open_binary` as `open_binary`\n - :func:`importlib.resources.open_text` as `open_text`\n - :func:`importlib.resources.path` as `path`\n - :func:`importlib.resources.read_binary` as `read_binary`\n - :func:`importlib.resources.read_text` as `read_text`\n \"\"\"\n\n meta_module = 'mymodule'\n meta_prefix = 'mytest_'\n meta_resource_pattern = re.compile(r'\\.test_file')\n\n def meta_test(self, module, resource):\n # type: (str, str) -> None\n \"\"\"\n Function will be called with every resource found.\n\n This function received resource-containing module name, and the\n resource name itself.\n\n :param module: resource-containing module name\n :type module: str\n :param resource: resource name (usually a filename)\n :type resource: str\n \"\"\"\n with self.path(module, resource) as path:\n self.assertPathStuff(str(path))\n\n with self.open_text(module, encoding='utf-8') as f:\n self.assertTextFileStuff(f)\n\n with self.open_binary(module) as f:\n self.assertBytesFileStuff(f)\n\n text = self.read_text(module, resource)\n self.assertTextStuff(text)\n\n data = self.read_binary(module, resource)\n self.assertBytesStuff(text)\n\n```\n\n### Using `unittest_resources.ResourceTestMeta` metaclass\n\nOr, alternatively, using the provided metaclass.\n\n```python\n\nimport unittest\nimport unittest_resources\n\n\nclass MyTestCase(unittest.TestCase,\n metaclass=unittest_resources.ResourceTestMeta):\n \"\"\"\n TestCase class with tests autogenerated based on resources.\n\n This regular :class:`unittest.TestCase`-derived class generates\n test methods by recursively inspecting a module for resources,\n based on special class attributes (prefixed by `meta_`).\n\n The following functions from :mod:`importlib.resources` are\n available as :class:`staticmethod`s:\n - :func:`importlib.resources.contents` as `contents`\n - :func:`importlib.resources.is_resource` as `is_resource`\n - :func:`importlib.resources.open_binary` as `open_binary`\n - :func:`importlib.resources.open_text` as `open_text`\n - :func:`importlib.resources.path` as `path`\n - :func:`importlib.resources.read_binary` as `read_binary`\n - :func:`importlib.resources.read_text` as `read_text`\n \"\"\"\n\n meta_module = 'mymodule'\n meta_prefix = 'mytest_'\n meta_resource_pattern = re.compile(r'\\.test_file')\n\n def meta_test(self, module, resource):\n # type: (str, str) -> None\n \"\"\"\n Function will be called with every resource found.\n\n This function received resource-containing module name, and the\n resource name itself.\n\n :param module: resource-containing module name\n :type module: str\n :param resource: resource name (usually a filename)\n :type resource: str\n \"\"\"\n with self.path(module, resource) as path:\n self.assertPathStuff(str(path))\n\n with self.open_text(module, encoding='utf-8') as f:\n self.assertTextFileStuff(f)\n\n with self.open_binary(module) as f:\n self.assertBytesFileStuff(f)\n\n text = self.read_text(module, resource)\n self.assertTextStuff(text)\n\n data = self.read_binary(module, resource)\n self.assertBytesStuff(text)\n\n```\n\n### Using `unittest_resources.testing` tool integrations\n\nThis package provides ready-to-use integrations of some common libraries\n\n```python\n\nimport unittest\nimport unittest_resources.testing\n\n\nclass TestCodeStyle(unittest_resources.testing.CodeStyleTestCase):\n \"\"\"\n This TestCase class applies pycodestyle to each python file located\n inside a python module.\n \"\"\"\n\n meta_module = 'mymodule'\n\n```\n\nRefer to [unittest_resources.testing](https://gitlab.com/ergoithz/unittest-resources/blob/master/unittest_resources/testing.py)\nmodule itself to see the available classes and\n[unittest_resources.tests.test_code](https://gitlab.com/ergoithz/unittest-resources/blob/master/unittest_resources/tests/test_code.py)\nto see how to use them.\n\n## Examples\n\nThis package own [test suite](https://gitlab.com/ergoithz/unittest-resources/blob/master/unittest_resources/tests/test_code.py)\nis self-explanatory, and covers covers the usage of this module to run\n[pycodestyle](https://pypi.org/project/pycodestyle/),\n[pydocstyle](https://pypi.org/project/pydocstyle/),\n[mypy](https://pypi.org/project/mypy/) and\n[radon](https://pypi.org/project/radon/) over project code.\n\nYou can either subclass and customize them to run on your code, or use\nthem as an example to integrate other tools.\n\n## License\n\nMIT (see [LICENSE](https://gitlab.com/ergoithz/unittest-resources/blob/master/LICENSE) file).\n\n## Changelog\n\nSee [CHANGELOG](https://gitlab.com/ergoithz/unittest-resources/blob/master/CHANGELOG) file.\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://gitlab.com/ergoithz/unittest-resources", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "unittest-resources", "package_url": "https://pypi.org/project/unittest-resources/", "platform": "any", "project_url": "https://pypi.org/project/unittest-resources/", "project_urls": { "Homepage": "https://gitlab.com/ergoithz/unittest-resources" }, "release_url": "https://pypi.org/project/unittest-resources/0.2.0/", "requires_dist": [ "six", "importlib-resources ; python_version < \"3.7\"", "pycodestyle ; extra == 'testing'", "pydocstyle ; extra == 'testing'", "radon ; extra == 'testing'", "radon ; extra == 'testing-maintainability'", "pycodestyle ; extra == 'testing-style'", "pydocstyle ; extra == 'testing-style'", "mypy ; extra == 'testing-typing'", "mypy ; (python_version >= \"3.5\") and extra == 'testing'" ], "requires_python": "", "summary": "Dynamic resource-based unittest suites made easy.", "version": "0.2.0" }, "last_serial": 5541083, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "f8bfbdd21a85860e4e854616c34e4cdb", "sha256": "2d7f2139d0e19d97d94661ad09bbdbaf92ecc258e3f5ff755932b476d4de4109" }, "downloads": -1, "filename": "unittest_resources-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f8bfbdd21a85860e4e854616c34e4cdb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11865, "upload_time": "2019-07-08T14:16:36", "url": "https://files.pythonhosted.org/packages/02/71/7be69fbb66aec48d9a893940ef23b419c5677bfd4a95f357d51f2c5e0e9e/unittest_resources-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a687002d763bf78cd7ac3f604ec76526", "sha256": "3a9726673da64050d3bd7e2e13ce9cbb87e3435fc47ad387d5f11ef2a41ec5ff" }, "downloads": -1, "filename": "unittest-resources-0.1.0.tar.gz", "has_sig": false, "md5_digest": "a687002d763bf78cd7ac3f604ec76526", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9962, "upload_time": "2019-07-08T14:16:38", "url": "https://files.pythonhosted.org/packages/ec/bc/a86c92fed30a4dd3b083bac2f6c2f9c2fbfff843a810695946f6a021bc1d/unittest-resources-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "662acfa40c5584b2cb20745465f74f09", "sha256": "0f0c149e8e2a572d55d7e6c4a5663708d5b2ee3e54755aeedda07f5e417d3222" }, "downloads": -1, "filename": "unittest_resources-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "662acfa40c5584b2cb20745465f74f09", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12261, "upload_time": "2019-07-09T11:28:19", "url": "https://files.pythonhosted.org/packages/3a/21/5ceead80a379ee5eba7e13324f06caa52bb1d0157fd99261e7d7fd0ce25f/unittest_resources-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f88d3421a71ad2e14f710e4373da9c8e", "sha256": "33f547bec9d12411f752f3df4fef9f23523d7319c05bde4595689e3b6d1568ab" }, "downloads": -1, "filename": "unittest-resources-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f88d3421a71ad2e14f710e4373da9c8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10752, "upload_time": "2019-07-09T11:28:21", "url": "https://files.pythonhosted.org/packages/01/c1/e2c8b1452be85b624aba5ed6c832139b8fa864703c09ba64045eca51b0bb/unittest-resources-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "570ff6f7a36f5bc31d58195bdd7808ee", "sha256": "c792c3e4bc4f18df3f4b4160dcb235a50c9dec84e177254e4e5af24a85cb0527" }, "downloads": -1, "filename": "unittest_resources-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "570ff6f7a36f5bc31d58195bdd7808ee", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12488, "upload_time": "2019-07-16T14:53:14", "url": "https://files.pythonhosted.org/packages/a9/31/503337c523e643911a4af2cd57c662d7df6cd3b150beabb80de1de3f3eb3/unittest_resources-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce8518d302896ff42e39ff7c85b967af", "sha256": "98256993dd5ec3cc92df8841a16ee7c4cac72ec650c365c7ebd1f2c278daba72" }, "downloads": -1, "filename": "unittest-resources-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ce8518d302896ff42e39ff7c85b967af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11543, "upload_time": "2019-07-16T14:53:17", "url": "https://files.pythonhosted.org/packages/6b/46/bc41370dbe3c448ec3b0331e0c92aaa76df91de7c00e4db5c7a91e30b693/unittest-resources-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "570ff6f7a36f5bc31d58195bdd7808ee", "sha256": "c792c3e4bc4f18df3f4b4160dcb235a50c9dec84e177254e4e5af24a85cb0527" }, "downloads": -1, "filename": "unittest_resources-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "570ff6f7a36f5bc31d58195bdd7808ee", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12488, "upload_time": "2019-07-16T14:53:14", "url": "https://files.pythonhosted.org/packages/a9/31/503337c523e643911a4af2cd57c662d7df6cd3b150beabb80de1de3f3eb3/unittest_resources-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ce8518d302896ff42e39ff7c85b967af", "sha256": "98256993dd5ec3cc92df8841a16ee7c4cac72ec650c365c7ebd1f2c278daba72" }, "downloads": -1, "filename": "unittest-resources-0.2.0.tar.gz", "has_sig": false, "md5_digest": "ce8518d302896ff42e39ff7c85b967af", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11543, "upload_time": "2019-07-16T14:53:17", "url": "https://files.pythonhosted.org/packages/6b/46/bc41370dbe3c448ec3b0331e0c92aaa76df91de7c00e4db5c7a91e30b693/unittest-resources-0.2.0.tar.gz" } ] }