expecttest


Nameexpecttest JSON
Version 0.2.1 PyPI version JSON
download
home_pagehttps://github.com/ezyang/expecttest
Summary
upload_time2023-12-21 13:33:45
maintainer
docs_urlNone
authorEdward Z. Yang
requires_python>=3.8,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # expecttest [![PyPI version](https://badge.fury.io/py/expecttest.svg)](https://badge.fury.io/py/expecttest)

This library implements expect tests (also known as "golden" tests). Expect
tests are a method of writing tests where instead of hard-coding the expected
output of a test, you run the test to get the output, and the test framework
automatically populates the expected output.  If the output of the test changes,
you can rerun the test with the environment variable `EXPECTTEST_ACCEPT=1` to
automatically update the expected output.

Somewhat unusually, this library implements *inline* expect tests: that is to
say, the expected output isn't saved to an external file, it is saved directly
in the Python file (and we modify your Python file when updating the expect
test.)

The general recipe for how to use this is as follows:

  1. Write your test and use `assertExpectedInline()` instead of a normal
     `assertEqual`.  Leave the expected argument blank with an empty string:
     ```py
     self.assertExpectedInline(some_func(), "")
     ```

  2. Run your test.  It should fail, and you get an error message about
     accepting the output with `EXPECTTEST_ACCEPT=1`

  3. Rerun the test with `EXPECTTEST_ACCEPT=1`.  Now the previously blank string
     literal will contain the expected value of the test.
     ```py
     self.assertExpectedInline(some_func(), "my_value")
     ```

Some tips and tricks:

  - Often, you will want to expect test on a multiline string.  This framework
    understands triple-quoted strings, so you can just write `"""my_value"""`
    and it will turn into triple-quoted strings.

  - Take some time thinking about how exactly you want to design the output
    format of the expect test.  It is often profitable to design an output
    representation specifically for expect tests.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ezyang/expecttest",
    "name": "expecttest",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Edward Z. Yang",
    "author_email": "ezyang@mit.edu",
    "download_url": "https://files.pythonhosted.org/packages/49/f1/ce746b7508496340f780a9ba7c3b0eb8bf5ab4826dabcd86166e5fcd9ff8/expecttest-0.2.1.tar.gz",
    "platform": null,
    "description": "# expecttest [![PyPI version](https://badge.fury.io/py/expecttest.svg)](https://badge.fury.io/py/expecttest)\n\nThis library implements expect tests (also known as \"golden\" tests). Expect\ntests are a method of writing tests where instead of hard-coding the expected\noutput of a test, you run the test to get the output, and the test framework\nautomatically populates the expected output.  If the output of the test changes,\nyou can rerun the test with the environment variable `EXPECTTEST_ACCEPT=1` to\nautomatically update the expected output.\n\nSomewhat unusually, this library implements *inline* expect tests: that is to\nsay, the expected output isn't saved to an external file, it is saved directly\nin the Python file (and we modify your Python file when updating the expect\ntest.)\n\nThe general recipe for how to use this is as follows:\n\n  1. Write your test and use `assertExpectedInline()` instead of a normal\n     `assertEqual`.  Leave the expected argument blank with an empty string:\n     ```py\n     self.assertExpectedInline(some_func(), \"\")\n     ```\n\n  2. Run your test.  It should fail, and you get an error message about\n     accepting the output with `EXPECTTEST_ACCEPT=1`\n\n  3. Rerun the test with `EXPECTTEST_ACCEPT=1`.  Now the previously blank string\n     literal will contain the expected value of the test.\n     ```py\n     self.assertExpectedInline(some_func(), \"my_value\")\n     ```\n\nSome tips and tricks:\n\n  - Often, you will want to expect test on a multiline string.  This framework\n    understands triple-quoted strings, so you can just write `\"\"\"my_value\"\"\"`\n    and it will turn into triple-quoted strings.\n\n  - Take some time thinking about how exactly you want to design the output\n    format of the expect test.  It is often profitable to design an output\n    representation specifically for expect tests.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "",
    "version": "0.2.1",
    "project_urls": {
        "Homepage": "https://github.com/ezyang/expecttest",
        "Repository": "https://github.com/ezyang/expecttest"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "73a89427813686fe043eaf817b99444d4d321ce14f9434e3ffb6bbd1a182a8df",
                "md5": "3ffd16d3aca06436f66727aaa3fcdac2",
                "sha256": "36f07b2f2800c12e5a0a5763d420f9f9b91631329bd54537509ebf17f8f81c36"
            },
            "downloads": -1,
            "filename": "expecttest-0.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3ffd16d3aca06436f66727aaa3fcdac2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 7377,
            "upload_time": "2023-12-21T13:33:43",
            "upload_time_iso_8601": "2023-12-21T13:33:43.945527Z",
            "url": "https://files.pythonhosted.org/packages/73/a8/9427813686fe043eaf817b99444d4d321ce14f9434e3ffb6bbd1a182a8df/expecttest-0.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "49f1ce746b7508496340f780a9ba7c3b0eb8bf5ab4826dabcd86166e5fcd9ff8",
                "md5": "e579d563c28eacd508d8a9814b51ea5a",
                "sha256": "e52b1cf8a6f84506e6962a0bbdd248ea442124d826e849f263ec1c322ebb73f5"
            },
            "downloads": -1,
            "filename": "expecttest-0.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e579d563c28eacd508d8a9814b51ea5a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 6873,
            "upload_time": "2023-12-21T13:33:45",
            "upload_time_iso_8601": "2023-12-21T13:33:45.514061Z",
            "url": "https://files.pythonhosted.org/packages/49/f1/ce746b7508496340f780a9ba7c3b0eb8bf5ab4826dabcd86166e5fcd9ff8/expecttest-0.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-21 13:33:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ezyang",
    "github_project": "expecttest",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "expecttest"
}
        
Elapsed time: 0.20067s