Skip to main content

No project description provided

Project description

expecttest PyPI version

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 instead 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 EXPECTTEST_ACCEPT=1 environment variable to automatically update the expected output.

Somewhat unusually, this file implements inline expect tests: that is to say, the expected output isn't save to an external file, it is saved directly in the Python file (and we modify your Python the 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:

    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 now contain the expected value of the test.

    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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

expecttest-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

expecttest-0.1.2-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file expecttest-0.1.2.tar.gz.

File metadata

  • Download URL: expecttest-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Darwin/20.5.0

File hashes

Hashes for expecttest-0.1.2.tar.gz
Algorithm Hash digest
SHA256 253bfa83939b111c9c02f32808e71723b9a3aeee2a219ae1e4f26230cd736177
MD5 b2b4267dc6cdd29606d581fa3041debf
BLAKE2b-256 3b2d0a81c2a94cb89b0866fa8898a867e891bfc45ae6b0ea5251500ae42b720d

See more details on using hashes here.

File details

Details for the file expecttest-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: expecttest-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.5 Darwin/20.5.0

File hashes

Hashes for expecttest-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1249b2c47e16ef7a0b320fe9ee97f1a4bd3512d364f78dd24f7e9db84f690618
MD5 1649ec36188993635869fd548d35dd9a
BLAKE2b-256 9d8155d9351a41d88c5ab39a023a0e474d324af027f04744469d341f51a338dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page