Skip to main content

Enables pytest to execute your Jupyter Notebook as a test

Project description

pytest-testbook

Build Status See Build Status on AppVeyor

The Question:

What do you call a Jupyter Notebook filled with test cases?

The Answer:

a testbook !

Why invent this plugin?

Because it allows specification, test cases, and automation code to be recorded inside a single Jupyter Notebook. When specification, requirements, test cases, and automation code are written in one place, this place is called a testbook.

How to run the tests?

  • Option 1: Follow the manual steps written in the testbook and perform each test steps manually.
  • Option 2: Trigger the execution of automated test code by running each cell directly in Jupyter Notebook.
  • Option 3: Use pytest to discover tests inside the testbook and run them. This your option when running testbook in CI/CD pipeline.

Features

  • BDD-style specification, requirements, manual test steps, and test automation code.
  • Auto-generated PDF reports to support auditing processes.
  • Plugin managed playwright instance working on its own background thread but can be used inside Jupyter Notebook cells.
  • Trigger automated tests execution in Jupyter.
  • Upload testbook in CI/CD pipepline for auto-execution using pytest

Installation

You will need to install playwright to generate pdf test reports. The side-effect is that you get a free playwright instance that you can use in your Testbooks.

pip install pytest-testbook
pip install jupyterlab
playwright install chromium

Usage

Navigate to where your tests folder are located. Then either run:

jupyter lab

to run tests manually in Jupyter. Or you can run:

pytest -sv

instead to let pytest discover your tests, collect them and execute them.

License

Distributed under the terms of the MIT_ license, "pytest-testbook" is free and open source software

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

pytest_testbook-1.4.3.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

pytest_testbook-1.4.3-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_testbook-1.4.3.tar.gz.

File metadata

  • Download URL: pytest_testbook-1.4.3.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for pytest_testbook-1.4.3.tar.gz
Algorithm Hash digest
SHA256 06473ca859b3304b8f4031a04eb2d8a03413eccc19f9837f0df2a5c5e2fbeca0
MD5 993a647c42c10dc962fd46c5cfafde97
BLAKE2b-256 5e5fde09d5e373224acf2dea2cf77965ae099d7aecd19236d195a2eeb9281b16

See more details on using hashes here.

File details

Details for the file pytest_testbook-1.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_testbook-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8ccaecb257009ecc0e75b72716d58dabd9ed208832ac93d0d1d2b0751eb0583b
MD5 9c64248d9e199c5099d8af35d33cb264
BLAKE2b-256 1772be9b7411c6a8779b7f47b75d2e3c221d85bdad34db797c9002613350bc93

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