Skip to main content

pytest-paia-blockly

pytest 外掛,用於 PAIA Blockly:依 case.json 測資驗證 solution.py 中的 get_solution() 是否正確。


安裝

pip install pytest-paia-blockly

或從原始碼可編輯安裝:

pip install -e .
# 或
uv pip install -e .

使用方式

1. 用 pytest 直接跑(需提供測試檔)

pytest tests/test_framework.py \
  --paia-target-module ./solution.py \
  --paia-testcases ./case.json \
  --paia-result ./var/result.json \
  -v

2. 用指令 paia-blockly-test(套件內建測試入口)

paia-blockly-test \
  --paia-target-module ./solution.py \
  --paia-testcases ./case.json \
  --paia-result ./var/result.json \
  -v

3. 用 python -m 執行

python -m pytest_paia_blockly \
  --paia-target-module ./solution.py \
  --paia-testcases ./case.json \
  --paia-result ./var/result.json \
  -v

命令列選項

選項 必填 說明
--paia-target-module 是 solution.py 的檔案路徑,該模組需提供 get_solution(input: dict)。
--paia-testcases 是 case.json 的路徑,格式見下方。
--paia-result 否 結果 JSON 輸出路徑,預設 ./var/paia_result.json。

選項可用 --option 值 或 --option=值;建議用空格分隔以利 shell 路徑自動補齊。
若未提供任一共用選項,test_verify_case 會參數化為 0 筆,不會執行任何測資。


題目格式

  • case.json:陣列,每筆為 { "index", "input", "expected": { "type", "value" } }。

    [
      { "index": 1, "input": { "list": [1, 2] }, "expected": { "type": "int", "value": 3 } },
      { "index": 2, "input": { "list": [3, 4] }, "expected": { "type": "int", "value": 7 } }
    ]
    
  • solution.py:需定義 get_solution(input: dict),回傳值會與 expected 比對(型別與值)。


範例腳本(本 repo)

專案內 examples/ 為範例題目,可用以下腳本跑對應題目:

目錄 說明
scripts/cli/ 使用 paia-blockly-test 的腳本(如 run_sum_the_list.sh、run_all.sh)。
scripts/python_m/ 使用 python -m pytest_paia_blockly 的腳本。
scripts/pytest/ 使用 pytest tests/test_framework.py 的腳本(檔名以 pytest_ 開頭)。

執行前請先啟動虛擬環境或安裝套件,例如:

bash scripts/cli/run_sum_the_list.sh
# 或
bash scripts/pytest/pytest_sum_the_list.sh

開發

  • 測試:pytest tests/(含 test_plugin.py、test_examples.py 等)。
  • 建構與上傳:bash scripts/build_and_upload.sh(需先設定 PyPI token)。

授權

Copyright (c) 2025 PAIA Technology Inc. All rights reserved.
詳見 LICENSE。

Metadata

Release files for pytest-paia-blockly 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-paia-blockly 0.3.1
File Size Uploaded Provenance
pytest_paia_blockly-0.3.1.tar.gz 35.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-paia-blockly 0.3.1
File Interpreter ABI Platform
pytest_paia_blockly-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 48.3 kB

Release files / pytest_paia_blockly-0.3.1.tar.gz

Download URL pytest_paia_blockly-0.3.1.tar.gz
Size 35.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aba191d02295950b889db8e146c070eae84752b588138e2e0cd64dd6ed88b87d
BLAKE2b-256 checksum
How to use checksums
bbe94a9342035b2061f34598b73772ed7a5c86a86c4d4fced88ad3c7a854ad54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / pytest_paia_blockly-0.3.1-py3-none-any.whl

Download URL pytest_paia_blockly-0.3.1-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8c467c03a527fa8cf38161500bd9a8721aa807c3cb87a1b026ee89d8c77d6e3e
BLAKE2b-256 checksum
How to use checksums
378eb5566e25fcafc34fa261ae56599887d58340c75d49621d3708e495dc0a18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for pytest-paia-blockly 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page