Tiny Python library for code demonstrations and small-scale testing
Project description
quickdemo
For when unit tests would be too much!
quickdemo is a tiny Python library for code demonstrations and small-scale testing.
If your debugging tool of choice is printing to stdout, this might be the right library for you.
quickdemo allows you to decorate any module-level function with an invocation or testing directive:
import quickdemo as qd
@qd.expect([1, 2], [0, 1], 1)
@qd.run([1, 2, 3], 5)
def add_to_list(input_list, number):
return [x + number for x in input_list]
The snippet above produces the following output:
add_to_list([1, 2, 3], 5) -> [6, 7, 8]
Passed: add_to_list([0, 1], 1)
Check out the showcase*.py files for more examples!
I developed quickdemo for two reasons:
Firstly, when presenting solutions to other people, I always wrote several print statements per function to demonstrate the correctness of the solution.
The print statements always added up quickly, making it difficult to discern which output corresponded to which function.
Also, changing any function name implied re-writing the invocation code.
This was especially tedious when working with Jupyter Notebooks, where you have to take great care to re-run a cell each time something changes.
Secondly, there is an educational programming language called Pyret, which allows writing short unit tests as part of a function definition.
I believe this to be a sensible choice when targeting beginners.
Unfortunately, Pyret code is neither readable nor particularly fast, so I decided to introduce this feature to Python as a part of quickdemo.
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 quickdemo-0.2.0.tar.gz.
File metadata
- Download URL: quickdemo-0.2.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57f64441e87c0582e6f1455e0717ef1ea0fdd6c83af56bd0e37458b9e4ec6207
|
|
| MD5 |
46c652ecd7abaddf77582a0ca1413a80
|
|
| BLAKE2b-256 |
4aca0ccff8fad3e0899212b24ecdaac75c5ffec809f1438a244c7db8b3f5f2ac
|
File details
Details for the file quickdemo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: quickdemo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8d704596db426d5dabcb3e7a65f50779a17ec00c8418796663aa0a76d62e617
|
|
| MD5 |
934d99fd5b6c0062bf2b3dd15ccddbcd
|
|
| BLAKE2b-256 |
848029bf5fb2b25ab04fed9d867fe7a9d5383d6fed54381e9809e3359682af2b
|