Enables pytest to execute your Jupyter Notebook as a test
Project description
pytest-testbook
Question
What do you call a Jupyter Notebook filled with test cases?
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
testbookand perform each test steps manually. - Option 2: Trigger the execution of automated test code by running the each cell directly in Jupyter.
- Option 3: Use
pytestto discover tests inside thetestbookand run them. This option enables your tests to run 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
playwrightinstance inside Jupyter Notebook. - Trigger automated tests execution in Jupyter.
- Upload
testbookin CI/CD pipepline for auto-execution usingpytest
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.
Contributing
Contributions are very welcome. Tests can be run with tox_, please ensure
the coverage at least stays the same before you submit a pull request.
License
Distributed under the terms of the MIT_ license, "pytest-testbook" is free and open source software
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_testbook-1.3.5.tar.gz.
File metadata
- Download URL: pytest_testbook-1.3.5.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4aa07b7b8cfd672b5e30bc8fc68ceb35cf3552a6a19441cbe0b556d1c20055a
|
|
| MD5 |
78c3cd3666f0359fb4330a7f81acddc5
|
|
| BLAKE2b-256 |
541bab3ae82f6521929e60db1fe1b1282e3ef98c2a1fece8a2bd407686bedf07
|
File details
Details for the file pytest_testbook-1.3.5-py3-none-any.whl.
File metadata
- Download URL: pytest_testbook-1.3.5-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
419805ea8bd91aa5717d162945263c5db5770388ca113ae8d20cc9c1a7014b3d
|
|
| MD5 |
cc7539e20f73c77d440da4cd02a885d6
|
|
| BLAKE2b-256 |
116e5603cba2437ebaf574d534bab5b1817837d90668eb78e9334453b2cd16b0
|