A decorator for marking and running example functions
Project description
run-it
一个用于标记和运行示例函数的装饰器。
设计目的:方便测试和学习小代码块。
使用@run_it装饰器标记的函数将被视为可执行的示例函数。在主程序中,我们会遍历当前文件的所有函数,如果函数被@run_it装饰,则会执行该函数。主程序将负责执行这些函数。
构建并发布
poetry publish --build
安装
pip install run-it-for-test
在项目中使用:
from run_it import run_it, run_examples
@run_it
def example1() -> None:
"""示例函数1"""
print("Running example 1")
@run_it
def example2() -> None:
"""示例函数2"""
print("Running example 2")
def normal_function() -> None:
"""普通函数,不会被执行"""
print("This won't run")
if __name__ == "__main__":
# 自动执行所有被 @run_it 标记的函数
run_examples()
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
run_it_for_test-0.2.tar.gz
(2.3 kB
view details)
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 run_it_for_test-0.2.tar.gz.
File metadata
- Download URL: run_it_for_test-0.2.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f336759553bdf296cebcd30beae357480042f3ffb298b8919a8be00ae1eda4c
|
|
| MD5 |
420452a4d3222a2e51a9ce646e13482e
|
|
| BLAKE2b-256 |
f02733df07d31c0f2211f866214a7b24c5f0ffe3defb46102bec782f31e1a06b
|
File details
Details for the file run_it_for_test-0.2-py3-none-any.whl.
File metadata
- Download URL: run_it_for_test-0.2-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.9.19 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b48d05e4b33a23c1e10dc7ed666c0f6a6dd48b3d8864c5dd5ad193fc46a9af17
|
|
| MD5 |
1f8c8f207a2055bf7cc8c53ee48926a2
|
|
| BLAKE2b-256 |
a96484f03edeceb720f49846835cf8c2e2a1cba8d35e0edaaa4133d9256ca5ae
|