{ "info": { "author": "Applied Brain Research", "author_email": "info@appliedbrainresearch.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Pytest", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "**********\npytest-plt\n**********\n\n``pytest-plt`` provides fixtures for\nquickly creating Matplotlib plots in your tests.\n\nCreate PDF plots in one line with the ``plt`` fixture.\n\n.. code-block:: python\n\n def test_rectification(plt):\n values = list(range(-10, 11))\n rectified = [v if v > 0 else 0 for v in values]\n assert all(v >= 0 for v in rectified)\n plt.plot(values, label=\"Original\")\n plt.plot(rectified, label=\"Rectified\")\n plt.legend()\n\n.. image:: https://i.imgur.com/2BFq2G2.png\n\nTo use these fixtures, install with\n\n.. code-block:: bash\n\n pip install pytest-plt\n\nAnd pass the ``--plots`` option\n\n.. code-block:: bash\n\n pytest --plots\n\nUsage\n=====\n\nThe ``plt`` fixture allows you to create PDF plots with as little as one line.\nIt exposes the ``matplotlib.pyplot``\n`interface `_.\n\nWhen running your tests,\npass the ``--plots`` option (with optional directory name)\nto generate the plots\n(in this case, we save them to the \"my_plots\" directory):\n\n.. code-block:: bash\n\n pytest --plots my_plots\n\nIf no directory name is provided,\nplots will be saved to the \"plots\" directory:\n\n.. code-block:: bash\n\n pytest --plots\n\nIf you do not pass the ``--plots`` option,\nno Matplotlib commands will be executed,\nspeeding up test execution.\n\nCustom filenames and extensions\n-------------------------------\n\n``pytest-plt`` attempts to give each plot\na readable name without being too long.\nSometimes the default name is not good enough,\nso ``plt`` allows you to change it using ``plt.saveas``:\n\n.. code-block:: python\n\n def test_rectification(plt):\n values = list(range(-10, 11))\n rectified = [v if v > 0 else 0 for v in values]\n assert all(v >= 0 for v in rectified)\n plt.plot(values, label=\"Original\")\n plt.plot(rectified, label=\"Rectified\")\n plt.legend()\n plt.saveas = \"test_rec.png\"\n\nThe ``plt.saveas`` attribute contains the\nfilename that will appear in the plots directory.\nYou can modify this attribute within your test\nto change the filename that will be used\nto save the plot for a given test function.\nIn the above example, running pytest with\n``pytest --plots my_plots`` will result in\na ``my_plots/test_rec.png`` file.\n\nIt should be noted that the file extension\nin ``plt.saveas`` will be used when saving the plot.\nThat is, in the example above,\nthe resulting plot will be a true PNG file,\nnot a PDF with an incorrect ``.png`` extension.\nYou can use the following snippet to change\nthe file extension in a specific test\nif the PDF format is unsuitable.\n\n.. code-block:: python\n\n plt.saveas = \"%s.png\" % (plt.saveas[:-4],)\n\nUsing plt.show\n--------------\n\nIf you want to inspect a figure using\nthe GUI that pops up with ``plt.show()``,\nyou can achieve this by saving a plot with the\n``.pkl`` or ``.pickle`` extension.\npytest-plt will pickle the current figure object\nfor later inspection.\n\nBuilding on the previous example,\nyou can change the ``saveas`` attribute like so:\n\n.. code-block:: python\n\n def test_rectification(plt):\n values = list(range(-10, 11))\n rectified = [v if v > 0 else 0 for v in values]\n assert all(v >= 0 for v in rectified)\n plt.plot(values, label=\"Original\")\n plt.plot(rectified, label=\"Rectified\")\n plt.legend()\n plt.saveas = \"test_rec.pkl\"\n\nThen use the following snippet to inspect the figure.\n\n.. code-block:: python\n\n >>> import pickle\n >>> import matplotlib.pyplot as plt\n >>> with open(\"path/to/test_rec.pkl\", \"rb\") as fh:\n ... fig = pickle.load(fh)\n >>> plt.show()\n\nConfiguration\n=============\n\nThe following configuration options exist.\n\nplt_filename_drop\n-----------------\n\n``plt_filename_drop`` accepts a list of regular expressions\nfor parts of the filename to drop.\n\nBy default, plot filenames contain the full ``nodeid``\nfor the test in question,\nwith directory separators (``/``) replaced with dots (``.``).\nIf all tests reside in the same project directory,\nthat name will appear at the start of all plot filenames,\nmaking them unnecessarily long.\n\nIn this case, we use the carat ``^`` to ensure that\nour regex matches the start of the filename only,\nand we remove the trailing dot as well (``\\.``):\n\n.. code-block:: ini\n\n plt_filename_drop =\n ^project\\.\n\nIf your tests always reside in a directory with a particular name\n(e.g. \"tests\"),\nyou can safely remove this name wherever it occurs.\nIn this case, we do not use the carat to allow the regex to match anywhere\nin the filename.\nBe careful, as this will match any directory\nthat ends with \"tests\" (e.g. \"other_tests\"),\nand will remove the ends of these directory names.\n\n.. code-block:: ini\n\n plt_filename_drop =\n ^project\\.\n tests\\.\n\nWhen using ``plt_filename_drop``, take care to avoid collisions\n(situations where plots from two different tests\nwill end up with the same name).\nIn this case, the plots of later tests\nwill override those of earlier tests with the same name.\n\nplt_dirname\n-----------\n\n``plt_dirname`` changes the default directory name for output plots.\n\nThe default ``plt_dirname`` is ``\"plots\"``.\nTo change it to ``\"test_plots\"``, for example, add the following\nto your ``pytest.ini``.\n\n.. code-block:: ini\n\n plt_dirname = test_plots\n\nA directory provided at the command line with the ``--plots`` flag\ntakes priority over ``plt_dirname``.\n\nSee the full\n`documentation `__\nfor more details and configuration options.\n\n***************\nRelease History\n***************\n\n.. Changelog entries should follow this format:\n\n version (release date)\n ======================\n\n **section**\n\n - One-line description of change (link to Github issue/PR)\n\n.. Changes should be organized in one of several sections:\n\n - Added\n - Changed\n - Deprecated\n - Removed\n - Fixed\n\n1.1.0 (August 17, 2020)\n=======================\n\n**Added**\n\n- Added the ability to save plots as pickle files using the\n ``.pkl`` or ``.pickle`` extensions with ``plt.saveas``. (`#23`_)\n\n.. _#23: https://github.com/nengo/pytest-plt/pull/23\n\n1.0.1 (October 28, 2019)\n========================\n\n**Fixed**\n\n- We now use Windows-compatible plot filenames by default.\n Colons in plot filenames are replaced with hyphens.\n Filenames specified through ``plt.saveas`` are not modified.\n (`#17`_, `#21`_)\n\n.. _#17: https://github.com/nengo/pytest-plt/issues/17\n.. _#21: https://github.com/nengo/pytest-plt/pull/21\n\n1.0.0 (August 9, 2019)\n======================\n\nInitial release of ``pytest-plt``!\nThanks to all of the contributors for making this possible!\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://www.nengo.ai/pytest-plt", "keywords": "", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "pytest-plt", "package_url": "https://pypi.org/project/pytest-plt/", "platform": "", "project_url": "https://pypi.org/project/pytest-plt/", "project_urls": { "Homepage": "https://www.nengo.ai/pytest-plt" }, "release_url": "https://pypi.org/project/pytest-plt/1.1.0/", "requires_dist": [ "matplotlib", "pytest", "nbsphinx (>=0.6.0) ; extra == 'all'", "nengo-sphinx-theme (>1.2.2) ; extra == 'all'", "numpydoc (>=0.9.2) ; extra == 'all'", "sphinx ; extra == 'all'", "nbsphinx (>=0.6.0) ; extra == 'docs'", "nengo-sphinx-theme (>1.2.2) ; extra == 'docs'", "numpydoc (>=0.9.2) ; extra == 'docs'", "sphinx ; extra == 'docs'" ], "requires_python": ">=3.5", "summary": "Fixtures for quickly making Matplotlib plots in tests", "version": "1.1.0", "yanked": false, "yanked_reason": null }, "last_serial": 8683531, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "4f4cd0c4f3824ce55d5813a969020354", "sha256": "249a983cd57428595229e90878c0cc21ae6fecad8a418d5717839669da571ee4" }, "downloads": -1, "filename": "pytest_plt-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "4f4cd0c4f3824ce55d5813a969020354", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 10652, "upload_time": "2019-08-09T15:31:19", "upload_time_iso_8601": "2019-08-09T15:31:19.952437Z", "url": "https://files.pythonhosted.org/packages/16/13/7915dc0c6767216c0d0e0034ba0846589005bf111a8f1e378859b9070376/pytest_plt-1.0.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a2ea79df68b45f9b0055136c25cff047", "sha256": "5e218a8b2cc21d64349ae75160b4dd49936e91b2a616fccf85a02adda2d34587" }, "downloads": -1, "filename": "pytest-plt-1.0.0.tar.gz", "has_sig": false, "md5_digest": "a2ea79df68b45f9b0055136c25cff047", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 17488, "upload_time": "2019-08-09T15:31:22", "upload_time_iso_8601": "2019-08-09T15:31:22.223546Z", "url": "https://files.pythonhosted.org/packages/48/c7/ead35cb52fb76d7f7f887a3e2097b5f235d79aea9b6b00cceac89bcfc798/pytest-plt-1.0.0.tar.gz", "yanked": false, "yanked_reason": null } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "4e2cca8a5b32986ca34c96a0b4bf4cff", "sha256": "93abfd2b3416667266612fc8270a2e8b2c17ea581f35abcdd168c7e75b544e09" }, "downloads": -1, "filename": "pytest_plt-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4e2cca8a5b32986ca34c96a0b4bf4cff", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 10571, "upload_time": "2019-10-28T17:16:15", "upload_time_iso_8601": "2019-10-28T17:16:15.464627Z", "url": "https://files.pythonhosted.org/packages/04/34/bd011dc705565bff28690085529bda0c74d7ebd10deffb5edf4a4799c6e5/pytest_plt-1.0.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "646543ddab7b68355d878e0b5eb48411", "sha256": "e581bd9f1d8e1dd7d7eb6d39ef70cf42ccbcc35c49fb3a4888195c7169fb4ccd" }, "downloads": -1, "filename": "pytest-plt-1.0.1.tar.gz", "has_sig": false, "md5_digest": "646543ddab7b68355d878e0b5eb48411", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 17847, "upload_time": "2019-10-28T17:16:16", "upload_time_iso_8601": "2019-10-28T17:16:16.966954Z", "url": "https://files.pythonhosted.org/packages/28/4c/762db5f97a50b54babfa3085118d91167deed27e02fbfeb23d83afa7b709/pytest-plt-1.0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "256e39934988427017bad87c0b875121", "sha256": "857e3df8fabda3697d5d7fd1ed46ae6f21ea2a2fbb881144121621861e693de8" }, "downloads": -1, "filename": "pytest_plt-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "256e39934988427017bad87c0b875121", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11524, "upload_time": "2020-08-17T17:26:44", "upload_time_iso_8601": "2020-08-17T17:26:44.693269Z", "url": "https://files.pythonhosted.org/packages/c0/45/a72cb8ef0a44df6e4cddd425b287a510cac9607f574696dcac118d3d7201/pytest_plt-1.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "26fa10258012519f25c29b3c39db3731", "sha256": "2244cd9627ab157206f5649551f5688ab7d0eb3ec939894269ae4d867052bb17" }, "downloads": -1, "filename": "pytest-plt-1.1.0.tar.gz", "has_sig": false, "md5_digest": "26fa10258012519f25c29b3c39db3731", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 22024, "upload_time": "2020-08-17T17:26:45", "upload_time_iso_8601": "2020-08-17T17:26:45.934589Z", "url": "https://files.pythonhosted.org/packages/bd/13/44d82c1542a7fdf506b595413474a40bd0adfdbb8f4640373d2074233d4d/pytest-plt-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "256e39934988427017bad87c0b875121", "sha256": "857e3df8fabda3697d5d7fd1ed46ae6f21ea2a2fbb881144121621861e693de8" }, "downloads": -1, "filename": "pytest_plt-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "256e39934988427017bad87c0b875121", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5", "size": 11524, "upload_time": "2020-08-17T17:26:44", "upload_time_iso_8601": "2020-08-17T17:26:44.693269Z", "url": "https://files.pythonhosted.org/packages/c0/45/a72cb8ef0a44df6e4cddd425b287a510cac9607f574696dcac118d3d7201/pytest_plt-1.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "26fa10258012519f25c29b3c39db3731", "sha256": "2244cd9627ab157206f5649551f5688ab7d0eb3ec939894269ae4d867052bb17" }, "downloads": -1, "filename": "pytest-plt-1.1.0.tar.gz", "has_sig": false, "md5_digest": "26fa10258012519f25c29b3c39db3731", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5", "size": 22024, "upload_time": "2020-08-17T17:26:45", "upload_time_iso_8601": "2020-08-17T17:26:45.934589Z", "url": "https://files.pythonhosted.org/packages/bd/13/44d82c1542a7fdf506b595413474a40bd0adfdbb8f4640373d2074233d4d/pytest-plt-1.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }