{ "info": { "author": "Wim Glenn", "author_email": "hey@wimglenn.com", "bugtrack_url": null, "classifiers": [ "Framework :: Pytest", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3" ], "description": "|actions|_ |pypi|_ |pyversions|_ |womm|_\n\n.. |actions| image:: https://github.com/wimglenn/pytest-structlog/actions/workflows/tests.yml/badge.svg\n.. _actions: https://github.com/wimglenn/pytest-structlog/actions/workflows/tests.yml/\n\n.. |pypi| image:: https://img.shields.io/pypi/v/pytest-structlog.svg\n.. _pypi: https://pypi.org/project/pytest-structlog\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pytest-structlog.svg\n.. _pyversions:\n\n.. |womm| image:: https://cdn.rawgit.com/nikku/works-on-my-machine/v0.2.0/badge.svg\n.. _womm: https://github.com/nikku/works-on-my-machine\n\n\npytest-structlog\n================\n\nStructured logging assertions. pytest_ + structlog_ = ``pytest-structlog``.\n\n|pytest| |structlog|\n\n\nInstallation:\n-------------\n\n.. code-block:: bash\n\n $ pip install pytest-structlog\n\nUsage:\n------\n\nThe fixture name is ``log``. It has two attributes of interest: ``log.events`` is a list of events from captured log calls, and ``log.has`` is a helper function for asserting a single event was logged within the expected context.\n\nSuppose you have some library module, ``your_lib``, which is using ``structlog``:\n\n.. code-block:: python\n\n # your_lib.py\n from structlog import get_logger\n\n logger = get_logger()\n\n def spline_reticulator():\n logger.info(\"reticulating splines\")\n for i in range(3):\n logger.debug(\"processing\", spline=i)\n logger.info(\"reticulated splines\", n_splines=3)\n\n\nThen your test suite might use assertions such as shown below:\n\n.. code-block:: python\n\n # test_your_lib.py\n from your_lib import spline_reticulator\n\n def test_spline_reticulator(log):\n assert len(log.events) == 0\n spline_reticulator()\n assert len(log.events) == 5\n\n # can assert on the event only\n assert log.has(\"reticulating splines\")\n\n # can assert with subcontext\n assert log.has(\"reticulated splines\")\n assert log.has(\"reticulated splines\", n_splines=3)\n assert log.has(\"reticulated splines\", n_splines=3, level=\"info\")\n\n # but not incorrect context\n assert not log.has(\"reticulated splines\", n_splines=42)\n assert not log.has(\"reticulated splines\", key=\"bogus\")\n\n # can assert with the event dicts directly\n assert log.events == [\n {\"event\": \"reticulating splines\", \"level\": \"info\"},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 0},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 1},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 2},\n {\"event\": \"reticulated splines\", \"level\": \"info\", \"n_splines\": 3},\n ]\n\n # can use membership to check for a single event's data\n assert {\"event\": \"reticulating splines\", \"level\": \"info\"} in log.events\n\n # can use >= to specify only the events you're interested in\n assert log.events >= [\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 0},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 2},\n ]\n\n # or put the comparison the other way around if you prefer\n assert [\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 0},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 2},\n ] <= log.events\n\n # note: comparisons are order sensitive!\n assert not [\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 2},\n {\"event\": \"processing\", \"level\": \"debug\", \"spline\": 0},\n ] <= log.events\n\n\n.. _pytest: https://docs.pytest.org/\n.. _structlog: https://www.structlog.org/\n.. |pytest| image:: https://user-images.githubusercontent.com/6615374/46903931-515eef00-cea2-11e8-8945-980ddbf0a053.png\n.. |structlog| image:: https://user-images.githubusercontent.com/6615374/46903937-5b80ed80-cea2-11e8-9b85-d3f071180fe1.png\n\n\n", "description_content_type": "text/x-rst; charset=UTF-8", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/wimglenn/pytest-structlog", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "pytest-structlog", "package_url": "https://pypi.org/project/pytest-structlog/", "platform": "", "project_url": "https://pypi.org/project/pytest-structlog/", "project_urls": { "Homepage": "https://github.com/wimglenn/pytest-structlog" }, "release_url": "https://pypi.org/project/pytest-structlog/0.5/", "requires_dist": [ "pytest", "structlog" ], "requires_python": "", "summary": "Structured logging assertions", "version": "0.5", "yanked": false, "yanked_reason": null }, "last_serial": 11503284, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2c3292041eb989e0db8113070c025f46", "sha256": "41154e912f4210e42a8b944eef2b83397a0315417563861257118e53051f1947" }, "downloads": -1, "filename": "pytest_structlog-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2c3292041eb989e0db8113070c025f46", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4296, "upload_time": "2018-10-13T10:06:43", "upload_time_iso_8601": "2018-10-13T10:06:43.976822Z", "url": "https://files.pythonhosted.org/packages/c8/1f/dc367638f3f896d8fa4db21f42f923ce7d8c2249c89709f2e24032aedea8/pytest_structlog-0.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "8cda620c20893b51a62824e62f155eae", "sha256": "978f2e7d98d14d5addf4e4caaf9216ceac75bbe9e527d46eed0441a1116c3300" }, "downloads": -1, "filename": "pytest-structlog-0.1.tar.gz", "has_sig": false, "md5_digest": "8cda620c20893b51a62824e62f155eae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4578, "upload_time": "2018-10-13T10:06:57", "upload_time_iso_8601": "2018-10-13T10:06:57.111246Z", "url": "https://files.pythonhosted.org/packages/61/5b/5a7b5843959c46fcd8ae2c8c8af8dd7932f824eb4bb9a4ccaa73e630adea/pytest-structlog-0.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2": [ { "comment_text": "", "digests": { "md5": "61d601af03edb7fb3caf4a4f0e005225", "sha256": "82b387afbdbe343c31e5454deb99a55fd9b876d0c552392bbe0670b26e385ef1" }, "downloads": -1, "filename": "pytest_structlog-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "61d601af03edb7fb3caf4a4f0e005225", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4542, "upload_time": "2019-10-22T03:54:15", "upload_time_iso_8601": "2019-10-22T03:54:15.003375Z", "url": "https://files.pythonhosted.org/packages/80/99/9d20f200c31527a3ad8809a6c566ea8a8cf5c0e7ffe66f7233a6f7ba38e8/pytest_structlog-0.2-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "6b1801c3762295b69031c089c0e228fa", "sha256": "2b76b39aa53d6bcfd8cd5082fa82e759a0be4b58f4dbfad6bceeeee77ee63813" }, "downloads": -1, "filename": "pytest-structlog-0.2.tar.gz", "has_sig": false, "md5_digest": "6b1801c3762295b69031c089c0e228fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4809, "upload_time": "2019-10-22T03:54:29", "upload_time_iso_8601": "2019-10-22T03:54:29.596537Z", "url": "https://files.pythonhosted.org/packages/b7/70/4b407ae4ca9d70437cdc1ba7ca5547049a1b31ec0b71fe8d2da1a16d1bb6/pytest-structlog-0.2.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3": [ { "comment_text": "", "digests": { "md5": "e54ffed1118128eac37958a67c9510db", "sha256": "c07ab9c89ee942ca5776ac81c746387dcb26d52c53466ee850daab67bb5b0281" }, "downloads": -1, "filename": "pytest_structlog-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "e54ffed1118128eac37958a67c9510db", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4556, "upload_time": "2020-07-16T16:48:23", "upload_time_iso_8601": "2020-07-16T16:48:23.211676Z", "url": "https://files.pythonhosted.org/packages/11/3e/310ef54a21ce3d9306d95eeec85ca18f85d7694fe85517f2a621c480efd2/pytest_structlog-0.3-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "dd64ba6c3056c9e654f8b968288b7d4b", "sha256": "be01025a712f03e9e2ede3bfbd9bce7ce79d4b7449d426fc603bebfcb0b7e860" }, "downloads": -1, "filename": "pytest-structlog-0.3.tar.gz", "has_sig": false, "md5_digest": "dd64ba6c3056c9e654f8b968288b7d4b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5144, "upload_time": "2020-07-16T16:48:31", "upload_time_iso_8601": "2020-07-16T16:48:31.052715Z", "url": "https://files.pythonhosted.org/packages/4d/70/9750d441fe2170963e2af0e8c358e41aa8dad6ae01d0617f4a8d19d3dddb/pytest-structlog-0.3.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4": [ { "comment_text": "", "digests": { "md5": "7b92b6a83af7902a7a4c3fa53e7c8ffd", "sha256": "3f2d6fcd3dcb2dbe2b55f90475f64de829acb07afede55243c81259237182387" }, "downloads": -1, "filename": "pytest_structlog-0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7b92b6a83af7902a7a4c3fa53e7c8ffd", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4696, "upload_time": "2021-03-26T17:25:26", "upload_time_iso_8601": "2021-03-26T17:25:26.091045Z", "url": "https://files.pythonhosted.org/packages/83/be/539d0bea13cccc6b440b52f6aa012736d52729a9e36d76a34b219c2fecd4/pytest_structlog-0.4-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1b235dda914f54cf3ed1031e52636bc1", "sha256": "59e32df78942b3ce76d8fa325b0ccfeab8419c806a80fc255f74dc766573dee9" }, "downloads": -1, "filename": "pytest-structlog-0.4.tar.gz", "has_sig": false, "md5_digest": "1b235dda914f54cf3ed1031e52636bc1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5455, "upload_time": "2021-03-26T17:25:33", "upload_time_iso_8601": "2021-03-26T17:25:33.505638Z", "url": "https://files.pythonhosted.org/packages/76/c7/864f54c25a61078987bfb54a33613bc4c668c0d70aaef16eff03edd7c25c/pytest-structlog-0.4.tar.gz", "yanked": false, "yanked_reason": null } ], "0.5": [ { "comment_text": "", "digests": { "md5": "2f0b995f897a784b5a11e772d322abaa", "sha256": "057c9e6b20cedc10071b65623e6dc9af4a025e5a13d73defa992da465e32ac22" }, "downloads": -1, "filename": "pytest_structlog-0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2f0b995f897a784b5a11e772d322abaa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4886, "upload_time": "2021-09-21T01:06:00", "upload_time_iso_8601": "2021-09-21T01:06:00.820020Z", "url": "https://files.pythonhosted.org/packages/d1/73/9a5e29e48ff229fdde040aa599097d970dc67710f881933be255c36d5291/pytest_structlog-0.5-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3ab2657b928a8553f6fd54a3d8c5c398", "sha256": "e2a878e98ee1d4d8883c918ebc318f800fbf7992cdaec1f4792a7b92a0369118" }, "downloads": -1, "filename": "pytest-structlog-0.5.tar.gz", "has_sig": false, "md5_digest": "3ab2657b928a8553f6fd54a3d8c5c398", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5587, "upload_time": "2021-09-21T01:06:06", "upload_time_iso_8601": "2021-09-21T01:06:06.714383Z", "url": "https://files.pythonhosted.org/packages/a2/fa/fe7a8124c2cac88d756a53e1a70be75b1cd637a9d52d6f54542c93f66741/pytest-structlog-0.5.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2f0b995f897a784b5a11e772d322abaa", "sha256": "057c9e6b20cedc10071b65623e6dc9af4a025e5a13d73defa992da465e32ac22" }, "downloads": -1, "filename": "pytest_structlog-0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "2f0b995f897a784b5a11e772d322abaa", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 4886, "upload_time": "2021-09-21T01:06:00", "upload_time_iso_8601": "2021-09-21T01:06:00.820020Z", "url": "https://files.pythonhosted.org/packages/d1/73/9a5e29e48ff229fdde040aa599097d970dc67710f881933be255c36d5291/pytest_structlog-0.5-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "3ab2657b928a8553f6fd54a3d8c5c398", "sha256": "e2a878e98ee1d4d8883c918ebc318f800fbf7992cdaec1f4792a7b92a0369118" }, "downloads": -1, "filename": "pytest-structlog-0.5.tar.gz", "has_sig": false, "md5_digest": "3ab2657b928a8553f6fd54a3d8c5c398", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5587, "upload_time": "2021-09-21T01:06:06", "upload_time_iso_8601": "2021-09-21T01:06:06.714383Z", "url": "https://files.pythonhosted.org/packages/a2/fa/fe7a8124c2cac88d756a53e1a70be75b1cd637a9d52d6f54542c93f66741/pytest-structlog-0.5.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }